Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update setup.py / pyproject.toml to follow latest numpy and cython docs #271

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools>=64", "Cython", "oldest-supported-numpy", 'setuptools_scm[toml]>=8']
requires = ["setuptools>=64", "Cython", "numpy>=1.25", 'setuptools_scm[toml]>=8']
build-backend = "setuptools.build_meta"
5 changes: 2 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ classifiers =
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3 :: Only
Topic :: Scientific/Engineering :: Astronomy
Topic :: Scientific/Engineering :: Physics
Expand Down
78 changes: 29 additions & 49 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,43 @@
from setuptools import setup
from setuptools import setup, Extension
import os
from Cython.Build import cythonize
import numpy as np


kwargs = dict(
include_dirs=[np.get_include()],
define_macros=[
# fixes a warning when compiling
("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"),
# defines the oldest numpy we want to be compatible with
("NPY_TARGET_VERSION", "NPY_1_21_API_VERSION"),
]
)

# make sure users without cython can install our extensions
try:
from Cython.Distutils.extension import Extension
from Cython.Distutils import build_ext as _build_ext
USE_CYTHON = True
except ImportError:
from setuptools import Extension
from setuptools.command.build_ext import build_ext as _build_ext
USE_CYTHON = False

print('using cython', USE_CYTHON)


# make sure numpy is installed before we try to build
# the extenion
class build_ext(_build_ext):
def finalize_options(self):
super().finalize_options()
import numpy
self.include_dirs.append(numpy.get_include())


# if we have cython, use the cython file if not the c file
ext = '.pyx' if USE_CYTHON else '.c'
extensions = [
Extension('eventio.header', sources=['src/eventio/header' + ext]),
Extension('eventio.var_int', sources=['src/eventio/var_int' + ext]),
Extension(
'eventio.header',
sources=['src/eventio/header.pyx'],
**kwargs,
),
Extension(
'eventio.var_int',
sources=['src/eventio/var_int.pyx'],
**kwargs,
),
Extension(
'eventio.simtel.parsing',
sources=['src/eventio/simtel/parsing' + ext]
sources=['src/eventio/simtel/parsing.pyx'],
**kwargs,
),
]
cmdclass = {'build_ext': build_ext}

# give a nice error message if people cloned the
# repository and do not have cython installed
if ext == '.c':
sources = []
for ext in extensions:
sources.extend(ext.sources)
if not all(os.path.isfile(s) for s in sources):
raise ImportError('You need `Cython` to build this project locally')


setup(
use_scm_version={"write_to": os.path.join("src", "eventio", "_version.py")},

ext_modules=extensions,
cmdclass=cmdclass,

package_data={
'eventio': ['*.c'],
'eventio.simtel': ['*.c'],
},
python_requires='>=3.8',
ext_modules=cythonize(extensions),
python_requires='>=3.9',
install_requires=[
'numpy',
'numpy >= 1.21',
'corsikaio ~= 0.3.3',
'zstandard > 0.11.1', # memory leak in zstandard 0.11.1
'setuptools_scm',
Expand Down
Loading