From 8f62941e0d541014c49305db16b41a18e2792774 Mon Sep 17 00:00:00 2001 From: samwaseda Date: Tue, 18 Jun 2024 15:47:51 +0000 Subject: [PATCH] follow ChatGPT's suggestion --- .github/workflows/testing.yml | 14 +++++++------- setup.py | 13 +++++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index bfa3d48..1dfbad5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -16,18 +16,18 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - uses: conda-incubator/setup-miniconda@v2 + - name: Set up Python + uses: actions/setup-python@v4 with: - miniforge-variant: Mambaforge - activate-environment: mamonca-test - channel-priority: strict - environment-file: .ci_support/environment.yml python-version: ${{ matrix.python-version }} - use-only-tar-bz2: true + + - name: Install dependencies + run: | + pip install numpy cython scipy + pip install . - name: run tests shell: bash -l {0} run: | - pip install -e . python -m unittest discover tests/ diff --git a/setup.py b/setup.py index 1d696ad..0e9cee3 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,20 @@ from setuptools.command.build_ext import build_ext from setuptools import setup, Extension +import numpy +# Check if Cython is available +try: + from Cython.Build import cythonize +except ImportError: + def cythonize(module_list): + return module_list +# Define the extension module ext = Extension( 'mamonca', sources=["mamonca/mc.pyx"], language="c++", + include_dirs=[numpy.get_include()], extra_compile_args=['-std=c++11'], ) @@ -23,12 +32,12 @@ author_email='waseda@mpie.de', license='BSD', cmdclass={"build_ext": build_ext}, - ext_modules=[ext], + ext_modules=cythonize([ext]), options={'build': {'build_lib': 'mamonca'}}, setup_requires=[ - # Setuptools 18.0 properly handles Cython extensions. 'setuptools>=18.0', 'cython', 'numpy', ], ) +