diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index a6d26e8..d964221 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -82,6 +82,12 @@ jobs: - run: zip -r ${{ matrix.container }}-${{ matrix.compiler}} lib share - run: pip3 install -r test/requirements.txt + - run: pip3 install -r cython/requirements.txt + - run: | + cd cython/ + python setup.py build_ext --inplace + pip3 install . + cd .. - run: python3 -m pytest - name: Upload Debug Spectrum diff --git a/.gitignore b/.gitignore index 7b8d44b..cd3f0ad 100644 --- a/.gitignore +++ b/.gitignore @@ -88,4 +88,5 @@ src/sme/hlinprof.c debug_radiative_transfer.npz origin/ **/.deps/ -test/cywrapper.cpp +cython/smelib.egg-info/ +cython/smelib.cpp diff --git a/cython/README.md b/cython/README.md new file mode 100644 index 0000000..174b876 --- /dev/null +++ b/cython/README.md @@ -0,0 +1,4 @@ +Installing Cython +================= + +Run python setup.py build_ext --inplace diff --git a/cython/requirements.txt b/cython/requirements.txt new file mode 100644 index 0000000..513352a --- /dev/null +++ b/cython/requirements.txt @@ -0,0 +1,2 @@ +numpy +cython \ No newline at end of file diff --git a/cython/setup.py b/cython/setup.py new file mode 100644 index 0000000..afcda0e --- /dev/null +++ b/cython/setup.py @@ -0,0 +1,19 @@ +from os.path import join, realpath, dirname +from distutils.core import setup +from distutils.extension import Extension +from Cython.Build import cythonize + +lib_path = realpath(join(dirname(__file__), "../lib")) +file_path = realpath(join(dirname(__file__), "smelib.pyx")) + +examples_extension = Extension( + name="smelib", + sources=[file_path], + libraries=["gfortran", "sme"], + library_dirs=[lib_path], + runtime_library_dirs=[lib_path], +) +setup( + name="smelib", + ext_modules=cythonize([examples_extension], language_level=3) +) \ No newline at end of file diff --git a/test/cywrapper.pyx b/cython/smelib.pyx similarity index 100% rename from test/cywrapper.pyx rename to cython/smelib.pyx diff --git a/test/cython_call.py b/test/cython_call.py index e85833c..5d3b19c 100644 --- a/test/cython_call.py +++ b/test/cython_call.py @@ -1,8 +1,7 @@ from os.path import dirname, join, realpath, exists import numpy as np import logging -import cywrapper -import cywrapper as dll +import smelib as dll logger = logging.getLogger(__name__) def check_data_files_exist(): diff --git a/test/test_cython.py b/test/test_cython.py index c7b3e76..4811966 100644 --- a/test/test_cython.py +++ b/test/test_cython.py @@ -4,9 +4,8 @@ import numpy as np import logging -# from sme_synth import SME_DLL -# from cwrapper import get_lib_name -import cywrapper as dll +# Run python setup.py build_ext --inplace +import smelib as dll logger = logging.getLogger(__name__)