Skip to content

Commit e7ce051

Browse files
authored
Use PEP-508 compliant dependency specifiers
This allows correctly resolving the numpy version requirement via PyPI metadata, using the same metadata regardless of what version of Python the package was built with or which wheel is uploaded to PyPI first.
1 parent 84bfd76 commit e7ce051

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

setup.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,15 @@ def main():
2222
build_headless = get_build_env_var_by_name("headless")
2323
build_java = "ON" if get_build_env_var_by_name("java") else "OFF"
2424

25-
if sys.version_info[:2] >= (3, 6):
26-
minimum_supported_numpy = "1.13.3"
27-
if sys.version_info[:2] >= (3, 7):
28-
minimum_supported_numpy = "1.14.5"
29-
if sys.version_info[:2] >= (3, 8):
30-
minimum_supported_numpy = "1.17.3"
31-
if sys.version_info[:2] >= (3, 9):
32-
minimum_supported_numpy = "1.19.3"
33-
if sys.version_info[:2] >= (3, 10):
34-
minimum_supported_numpy = "1.21.2"
35-
36-
# linux arm64 is a special case
37-
if sys.platform.startswith("linux") and sys.version_info[:2] >= (3, 6) and platform.machine() == "aarch64":
38-
minimum_supported_numpy = "1.19.3"
39-
40-
# macos arm64 is a special case
41-
if sys.platform == "darwin" and sys.version_info[:2] >= (3, 6) and platform.machine() == "arm64":
42-
minimum_supported_numpy = "1.21.0"
43-
44-
numpy_version = "numpy>=%s" % minimum_supported_numpy
25+
install_requires = [
26+
'numpy>=1.13.3; python_version<"3.7"',
27+
'numpy>=1.14.5; python_version>="3.7"',
28+
'numpy>=1.17.3; python_version>="3.8"',
29+
'numpy>=1.19.3; python_version>="3.9"',
30+
'numpy>=1.21.2; python_version>="3.10"',
31+
'numpy>=1.19.3; python_version>="3.6" and platform_system=="Linux" and platform_machine=="aarch64"',
32+
'numpy>=1.21.2; python_version>="3.6" and platform_system=="Darwin" and platform_machine=="arm64"',
33+
]
4534

4635
python_version = cmaker.CMaker.get_python_version()
4736
python_lib_path = cmaker.CMaker.get_python_library(python_version).replace(
@@ -257,7 +246,7 @@ def main():
257246
package_data=package_data,
258247
maintainer="Olli-Pekka Heinisuo",
259248
ext_modules=EmptyListWithLength(),
260-
install_requires=numpy_version,
249+
install_requires=install_requires,
261250
python_requires=">=3.6",
262251
classifiers=[
263252
"Development Status :: 5 - Production/Stable",

0 commit comments

Comments
 (0)