Skip to content

Commit

Permalink
add simple build workflow, update setup.py
Browse files Browse the repository at this point in the history
* remove hard-coded paths from setup.py
* remove unused distutils import in setup.py
  (Note that distutils has been removed in Python 3.12)
* skip Ubuntu and Windows for now
  • Loading branch information
JostMigenda committed Jun 7, 2024
1 parent 7fbe9f4 commit 7170bc3
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 6 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build EMEWS

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
strategy:
fail-fast: false
matrix:
os: [macos-latest] # [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.12'] # ['3.9', '3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies (all OSes)
run: |
python -m pip install --upgrade pip
pip install setuptools wheel pybind11
- name: Install dependencies (macOS)
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
brew install libomp
echo "LIBOMP_INCLUDE=`brew --prefix`/opt/libomp/include" >> $GITHUB_ENV
- name: Install dependencies (Ubuntu)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
exit 1 # TODO: Add Ubuntu dependencies here
- name: Install dependencies (Windows)
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
exit 1 # TODO: Add Windows dependencies here
- name: Install EMEWS
run: |
python setup.py sdist bdist_wheel
ls -al dist/
pip install dist/*.whl
- name: Run example script
run: |
python EMEWS_example.py
20 changes: 14 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@


import os
from distutils.command.sdist import sdist as DistutilsSdist
from setuptools import setup, find_packages
from setuptools.extension import Extension
import sysconfig
import pybind11

#
# Begin setup
Expand Down Expand Up @@ -52,13 +53,20 @@
'docs':['numpydoc']
}

LIBOMP_INCLUDE = os.environ['LIBOMP_INCLUDE']
PYBIND11_INCLUDE = os.path.join(pybind11.__path__[0], "include")
if os.name == 'posix': # macOS or Linux
LIBDIR = sysconfig.get_config_var('LIBDIR')
elif os.name == 'nt': # Windows
LIBDIR = sysconfig.get_config_var('LIBDEST')

EMEWS = Extension('EMEWS',
define_macros = [('MAJOR_VERSION', '1'), ('MINOR_VERSION', '0')],
include_dirs = ['/usr/local/lib/python3.9/site-packages/pybind11/include', './src', './src/mstl', './src/mstl/math2', './src/mstl/math2/algebra', './src/mstl/math2/analysis', './src/mstl/math2/spline', './src/mstl/physics'],
libraries = ['stdc++', 'm', 'gomp', 'python3'],
library_dirs = ['/usr/lib64'],
extra_compile_args = ['-std=c++17', '-fopenmp', '-fPIC', '-nostartfiles'],
extra_link_args = ['-shared'],
include_dirs = [LIBOMP_INCLUDE, PYBIND11_INCLUDE, './src', './src/mstl', './src/mstl/math2', './src/mstl/math2/algebra', './src/mstl/math2/analysis', './src/mstl/math2/spline', './src/mstl/physics'],
# libraries = ['stdc++', 'm', 'gomp', 'python3'],
library_dirs = [LIBDIR],
extra_compile_args = ['-std=c++17', '-fPIC', '-nostartfiles'],
# extra_link_args = ['-shared'],
sources = ['./src/EMEWS.cpp', './src/adiabatic_basis.cpp', './src/eigenvalues.cpp', './src/flavour_basis.cpp', './src/input_class.EMEWS.cpp', './src/jacobians.cpp', './src/mixing_angles.cpp', './src/output.EMEWS.cpp', './src/output_matrix.EMEWS.cpp', './src/parameters.cpp', './src/potentials.cpp', './src/RK.EMEWS.cpp', './src/update.EMEWS.cpp', './src/mstl/errors2.cpp', './src/mstl/messages.cpp', './src/mstl/miscellaneous functions.cpp', './src/mstl/stdarg2.cpp', './src/mstl/math2/algebra/column and row vectors.cpp', './src/mstl/math2/algebra/linear algebra.cpp', './src/mstl/math2/algebra/mmatrix.cpp', './src/mstl/math2/analysis/algorithm3.cpp', './src/mstl/math2/analysis/complex2.cpp', './src/mstl/math2/analysis/derivative.cpp', './src/mstl/math2/analysis/polynomial.cpp', './src/mstl/math2/analysis/roots.cpp', './src/mstl/math2/analysis/runge kutta.cpp', './src/mstl/math2/analysis/special functions.cpp', './src/mstl/math2/spline/discontinuous.cpp', './src/mstl/math2/spline/interpolation data.cpp', './src/mstl/physics/units and constants.cpp'])

setup_keywords['ext_modules'] = [EMEWS]
Expand Down

0 comments on commit 7170bc3

Please sign in to comment.