Skip to content

Commit

Permalink
Merge pull request #2 from SNEWS2/JostMigenda/buildWorkflow
Browse files Browse the repository at this point in the history
Build EMEWS in GitHub Actions
  • Loading branch information
jpkneller authored Jun 19, 2024
2 parents e5c10ae + 3cfd9d5 commit 37aa78d
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 18 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
20 changes: 9 additions & 11 deletions src/mstl/functional2.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ template <typename AType1,typename AType2,typename AType3,typename AType4,typena
template <class CType,typename RType> struct nullary_member_function : public nullary_function<RType>
{ typedef CType class_type;};

template <class CType,typename AType,typename RType> struct unary_member_function : public std::unary_function<AType,RType>
template <class CType,typename AType,typename RType> struct unary_member_function
{ typedef CType class_type;};

template <class CType,typename AType1,typename AType2,typename RType> struct binary_member_function : public std::binary_function<AType1,AType2,RType>
template <class CType,typename AType1,typename AType2,typename RType> struct binary_member_function
{ typedef CType class_type;};

template <class CType,typename AType1,typename AType2,typename AType3,typename RType> struct ternary_member_function : public ternary_function<AType1,AType2,AType3,RType>
Expand Down Expand Up @@ -328,27 +328,27 @@ class pointer_to_quaternary_member_function : public quaternary_member_function<
// *******************************************************
// *******************************************************

template <typename Type> struct equal : public std::unary_function<Type,Type>{
template <typename Type> struct equal {
Type operator()(const Type &x) const { return x;}
};

template <typename Type> struct plus : public std::unary_function<Type,Type>{
template <typename Type> struct plus {
Type operator()(const Type &x) const { return x;}
};

template <typename Type> struct square : public std::unary_function<Type,Type>{
template <typename Type> struct square {
Type operator()(const Type &x) const { return x*x;}
};

template <typename Type> struct cube : public std::unary_function<Type,Type>{
template <typename Type> struct cube {
Type operator()(const Type &x) const { return x*x*x;}
};

// *******************************************************
// *******************************************************
// *******************************************************

template <typename Type> struct exclusive_or : public std::binary_function<Type,Type,Type>{
template <typename Type> struct exclusive_or {
Type operator()(const Type &x,const Type &y) const { return x^y;}
};

Expand All @@ -364,15 +364,13 @@ public nullary_function<RType>
};

template <typename AType,typename RType>
class UNARYFUNCTORBASE :
public std::unary_function<AType,RType>
class UNARYFUNCTORBASE
{ public : virtual ~UNARYFUNCTORBASE(void){;}
virtual RType operator()(AType) const =0;
};

template <typename AType1,typename AType2,typename RType>
class BINARYFUNCTORBASE :
public std::binary_function<AType1,AType2,RType>
class BINARYFUNCTORBASE
{ public : virtual ~BINARYFUNCTORBASE(void){;}
virtual RType operator()(AType1,AType2) const =0;
};
Expand Down
2 changes: 1 addition & 1 deletion src/mstl/math2/analysis/special functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ double Gamma(double N){ return tgamma(N);}
}*/

// see Numerical Recipes for the algorithm
double logGamma(double N){ return gamma(N);}
double logGamma(double N){ return lgamma(N);}
/*{ if(N<0.){ throw NEGATIVE_NUMBER("logGamma(double)");}
double ser; double n=N;
double c[6]={ 76.18009172947146,-86.50532032941677, 24.01409824083091,
Expand Down

0 comments on commit 37aa78d

Please sign in to comment.