blob: cd5f7934080539e455fb42ad37866aa4ef0c2570 [file] [log] [blame]
Changqing Li583901a2020-03-04 08:22:401#!/usr/bin/env python3
Travis Oliphantda9c6da2006-01-04 17:31:072"""
hannah6c2fa302022-11-01 16:28:363Numpy build options can be modified with a site.cfg file.
4See site.cfg.example for a template and more information.
5"""
Pearu Petersonc415fd12002-11-18 22:39:316
Pearu Petersone8fa0132003-03-07 18:08:287import os
hannahce57eea2022-10-31 03:00:038from pathlib import Path
Pearu Petersone8fa0132003-03-07 18:08:289import sys
David Cournapeau5623a7c2009-04-02 16:21:3010import subprocess
Ralf Gommers99e99e92015-12-29 14:24:2211import textwrap
Hugo van Kemenadef3a6b332020-10-04 09:09:5212import warnings
Charles Harris40fd17e2020-12-02 20:06:5113import builtins
Charles Harris9a37cd92021-05-25 19:35:4214import re
Pearu Petersonc415fd12002-11-18 22:39:3115
Ralf Gommersf66d5db2020-12-22 20:11:5016
17# Python supported version checks. Keep right after stdlib imports to ensure we
18# get a sensible error for older Python versions
Sebastian Berg3dcbecc2021-11-07 17:42:4719if sys.version_info[:2] < (3, 8):
Charles Harris9a176d02021-08-13 15:53:4120 raise RuntimeError("Python version >= 3.8 required.")
Ralf Gommersf66d5db2020-12-22 20:11:5021
22
23import versioneer
24
25
Charles Harris40fd17e2020-12-02 20:06:5126# This is a bit hackish: we are setting a global variable so that the main
27# numpy __init__ can detect if it is being loaded by the setup routine, to
28# avoid attempting to load components that aren't built yet. While ugly, it's
29# a lot more robust than what was previously being used.
30builtins.__NUMPY_SETUP__ = True
Ralf Gommers17716d72013-12-06 19:45:4031
Charles Harris40fd17e2020-12-02 20:06:5132# Needed for backwards code compatibility below and in some CI scripts.
33# The version components are changed from ints to strings, but only VERSION
34# seems to matter outside of this module and it was already a str.
35FULLVERSION = versioneer.get_version()
Charles Harris9a37cd92021-05-25 19:35:4236
37# Capture the version string:
38# 1.22.0.dev0+ ... -> ISRELEASED == False, VERSION == 1.22.0
39# 1.22.0rc1+ ... -> ISRELEASED == False, VERSION == 1.22.0
40# 1.22.0 ... -> ISRELEASED == True, VERSION == 1.22.0
41# 1.22.0rc1 ... -> ISRELEASED == True, VERSION == 1.22.0
42ISRELEASED = re.search(r'(dev|\+)', FULLVERSION) is None
Matthew Brett9db73b52021-10-23 11:05:3143_V_MATCH = re.match(r'(\d+)\.(\d+)\.(\d+)', FULLVERSION)
44if _V_MATCH is None:
45 raise RuntimeError(f'Cannot parse version {FULLVERSION}')
46MAJOR, MINOR, MICRO = _V_MATCH.groups()
Charles Harris40fd17e2020-12-02 20:06:5147VERSION = '{}.{}.{}'.format(MAJOR, MINOR, MICRO)
48
Dimitri Papadopoulos Orfanos3cf2ca12022-10-07 19:34:4749# The first version not in the `Programming Language :: Python :: ...` classifiers below
Charles Harrisf06a3152022-08-17 14:36:0450if sys.version_info >= (3, 12):
Charles Harrisca11e4e2020-12-12 15:17:0151 fmt = "NumPy {} may not yet support Python {}.{}."
Charles Harris40fd17e2020-12-02 20:06:5152 warnings.warn(
Charles Harrisca11e4e2020-12-12 15:17:0153 fmt.format(VERSION, *sys.version_info[:2]),
54 RuntimeWarning)
55 del fmt
David Cournapeau2b517692009-12-03 15:53:2956
Charles Harris40fd17e2020-12-02 20:06:5157# BEFORE importing setuptools, remove MANIFEST. Otherwise it may not be
58# properly updated when the contents of directories change (true for distutils,
59# not sure about setuptools).
60if os.path.exists('MANIFEST'):
61 os.remove('MANIFEST')
62
63# We need to import setuptools here in order for it to persist in sys.modules.
Charles Harrisfed25092020-12-10 18:58:4764# Its presence/absence is used in subclassing setup in numpy/distutils/core.py.
65# However, we need to run the distutils version of sdist, so import that first
66# so that it is in sys.modules
67import numpy.distutils.command.sdist
Charles Harris40fd17e2020-12-02 20:06:5168import setuptools
Charles Harrisc62e1db2022-01-06 23:51:2069if int(setuptools.__version__.split('.')[0]) >= 60:
Andrew J. Hesforddedc0952022-02-01 15:34:2670 # setuptools >= 60 switches to vendored distutils by default; this
71 # may break the numpy build, so make sure the stdlib version is used
72 try:
73 setuptools_use_distutils = os.environ['SETUPTOOLS_USE_DISTUTILS']
74 except KeyError:
75 os.environ['SETUPTOOLS_USE_DISTUTILS'] = "stdlib"
76 else:
77 if setuptools_use_distutils != "stdlib":
78 raise RuntimeError("setuptools versions >= '60.0.0' require "
79 "SETUPTOOLS_USE_DISTUTILS=stdlib in the environment")
Charles Harris40fd17e2020-12-02 20:06:5180
81# Initialize cmdclass from versioneer
82from numpy.distutils.core import numpy_cmdclass
83cmdclass = versioneer.get_cmdclass(numpy_cmdclass)
Ralf Gommers17716d72013-12-06 19:45:4084
Travis Oliphantda9c6da2006-01-04 17:31:0785CLASSIFIERS = """\
Robert Kern19da9712008-06-18 22:53:4486Development Status :: 5 - Production/Stable
Travis Oliphantda9c6da2006-01-04 17:31:0787Intended Audience :: Science/Research
88Intended Audience :: Developers
johnthagen5cb80d62020-10-22 12:43:0389License :: OSI Approved :: BSD License
Travis Oliphantda9c6da2006-01-04 17:31:0790Programming Language :: C
91Programming Language :: Python
rgommerscdac1202011-01-25 14:02:4092Programming Language :: Python :: 3
Grzegorz Bokotac861a362019-10-24 18:29:0993Programming Language :: Python :: 3.8
Hugo van Kemenade79a8e162020-10-04 11:59:5394Programming Language :: Python :: 3.9
Charles Harris9a176d02021-08-13 15:53:4195Programming Language :: Python :: 3.10
Charles Harrisf06a3152022-08-17 14:36:0496Programming Language :: Python :: 3.11
Jon Dufresne334201d2019-08-27 04:18:3597Programming Language :: Python :: 3 :: Only
Alex Willmer193668a2015-08-05 09:29:3998Programming Language :: Python :: Implementation :: CPython
Travis Oliphantda9c6da2006-01-04 17:31:0799Topic :: Software Development
100Topic :: Scientific/Engineering
Bas van Beeke592c272020-10-04 13:10:42101Typing :: Typed
Travis Oliphantda9c6da2006-01-04 17:31:07102Operating System :: Microsoft :: Windows
103Operating System :: POSIX
104Operating System :: Unix
105Operating System :: MacOS
106"""
107
Ralf Gommers17716d72013-12-06 19:45:40108
Hugo van Kemenade2ebb4532020-10-04 09:41:47109def configuration(parent_package='', top_path=None):
Pearu Peterson471196b2006-03-31 08:59:36110 from numpy.distutils.misc_util import Configuration
111
Pearu Peterson17d7cfe2006-04-04 12:26:14112 config = Configuration(None, parent_package, top_path)
Pearu Peterson471196b2006-03-31 08:59:36113 config.set_options(ignore_setup_xxx_py=True,
114 assume_default_configuration=True,
115 delegate_options_to_subpackages=True,
116 quiet=True)
Jarrod Millman0b77f0e2007-10-29 14:58:18117
Pearu Peterson471196b2006-03-31 08:59:36118 config.add_subpackage('numpy')
Charles Harris054d93a2017-11-29 18:53:21119 config.add_data_files(('numpy', 'LICENSE.txt'))
scodere1211b82020-08-05 04:28:30120 config.add_data_files(('numpy', 'numpy/*.pxd'))
Jarrod Millman0b77f0e2007-10-29 14:58:18121
Hugo van Kemenade2ebb4532020-10-04 09:41:47122 config.get_version('numpy/version.py') # sets config.version
Travis Oliphant00a35872007-05-31 04:57:01123
Pearu Peterson471196b2006-03-31 08:59:36124 return config
125
Ralf Gommers4b0ed792015-12-29 10:29:38126
Julian Taylor4cd72742014-01-29 21:59:19127def check_submodules():
128 """ verify that the submodules are checked out and clean
129 use `git submodule update --init`; on failure
130 """
131 if not os.path.exists('.git'):
132 return
133 with open('.gitmodules') as f:
Hugo van Kemenade2ebb4532020-10-04 09:41:47134 for line in f:
135 if 'path' in line:
136 p = line.split('=')[-1].strip()
Julian Taylor4cd72742014-01-29 21:59:19137 if not os.path.exists(p):
Wojciech Rzadkowskidabf31c2020-05-22 15:43:08138 raise ValueError('Submodule {} missing'.format(p))
Julian Taylor4cd72742014-01-29 21:59:19139
Julian Taylor4cd72742014-01-29 21:59:19140 proc = subprocess.Popen(['git', 'submodule', 'status'],
141 stdout=subprocess.PIPE)
142 status, _ = proc.communicate()
143 status = status.decode("ascii", "replace")
144 for line in status.splitlines():
145 if line.startswith('-') or line.startswith('+'):
Wojciech Rzadkowskidabf31c2020-05-22 15:43:08146 raise ValueError('Submodule not clean: {}'.format(line))
Julian Taylor4cd72742014-01-29 21:59:19147
Ralf Gommers4b0ed792015-12-29 10:29:38148
Ralf Gommersa08fb602019-05-03 14:44:23149class concat_license_files():
Ralf Gommers33415902019-05-07 09:00:50150 """Merge LICENSE.txt and LICENSES_bundled.txt for sdist creation
Ralf Gommersa08fb602019-05-03 14:44:23151
152 Done this way to keep LICENSE.txt in repo as exact BSD 3-clause (see
153 gh-13447). This makes GitHub state correctly how NumPy is licensed.
154 """
155 def __init__(self):
156 self.f1 = 'LICENSE.txt'
Ralf Gommers33415902019-05-07 09:00:50157 self.f2 = 'LICENSES_bundled.txt'
Ralf Gommersa08fb602019-05-03 14:44:23158
159 def __enter__(self):
Ralf Gommers33415902019-05-07 09:00:50160 """Concatenate files and remove LICENSES_bundled.txt"""
Ralf Gommersa08fb602019-05-03 14:44:23161 with open(self.f1, 'r') as f1:
162 self.bsd_text = f1.read()
163
164 with open(self.f1, 'a') as f1:
165 with open(self.f2, 'r') as f2:
166 self.bundled_text = f2.read()
167 f1.write('\n\n')
168 f1.write(self.bundled_text)
169
Ralf Gommersa08fb602019-05-03 14:44:23170 def __exit__(self, exception_type, exception_value, traceback):
171 """Restore content of both files"""
172 with open(self.f1, 'w') as f:
173 f.write(self.bsd_text)
174
Ralf Gommersa08fb602019-05-03 14:44:23175
Charles Harrisfed25092020-12-10 18:58:47176# Need to inherit from versioneer version of sdist to get the encoded
177# version information.
178class sdist_checked(cmdclass['sdist']):
Julian Taylor4cd72742014-01-29 21:59:19179 """ check submodules on sdist to prevent incomplete tarballs """
180 def run(self):
181 check_submodules()
Ralf Gommersa08fb602019-05-03 14:44:23182 with concat_license_files():
Charles Harrisfed25092020-12-10 18:58:47183 super().run()
Travis Oliphant14db4192005-09-14 22:08:46184
Ralf Gommers4b0ed792015-12-29 10:29:38185
mattip18af8e02020-01-04 20:47:47186def get_build_overrides():
187 """
mattipc2f93002020-01-05 15:00:30188 Custom build commands to add `-std=c99` to compilation
mattip18af8e02020-01-04 20:47:47189 """
190 from numpy.distutils.command.build_clib import build_clib
191 from numpy.distutils.command.build_ext import build_ext
Charles Harrisdf8d1fd2022-02-04 23:21:58192 from numpy.compat import _pep440
mattip18af8e02020-01-04 20:47:47193
mattip10dcfb02020-07-28 08:56:35194 def _needs_gcc_c99_flag(obj):
195 if obj.compiler.compiler_type != 'unix':
196 return False
197
198 cc = obj.compiler.compiler[0]
199 if "gcc" not in cc:
200 return False
201
202 # will print something like '4.2.1\n'
Mike Taves69a39462022-10-26 21:19:42203 out = subprocess.run([cc, '-dumpversion'],
204 capture_output=True, text=True)
mattip10dcfb02020-07-28 08:56:35205 # -std=c99 is default from this version on
Charles Harrisdf8d1fd2022-02-04 23:21:58206 if _pep440.parse(out.stdout) >= _pep440.Version('5.0'):
mattip10dcfb02020-07-28 08:56:35207 return False
208 return True
mattip18af8e02020-01-04 20:47:47209
210 class new_build_clib(build_clib):
211 def build_a_library(self, build_info, lib_name, libraries):
serge-sans-paille91a3e3a2022-04-29 11:53:23212 from numpy.distutils.ccompiler_opt import NPY_CXX_FLAGS
mattip10dcfb02020-07-28 08:56:35213 if _needs_gcc_c99_flag(self):
serge-sans-paille2ae7aeb2021-08-19 07:28:09214 build_info['extra_cflags'] = ['-std=c99']
serge-sans-paille91a3e3a2022-04-29 11:53:23215 build_info['extra_cxxflags'] = NPY_CXX_FLAGS
mattip18af8e02020-01-04 20:47:47216 build_clib.build_a_library(self, build_info, lib_name, libraries)
217
218 class new_build_ext(build_ext):
219 def build_extension(self, ext):
mattip10dcfb02020-07-28 08:56:35220 if _needs_gcc_c99_flag(self):
mattipc2f93002020-01-05 15:00:30221 if '-std=c99' not in ext.extra_compile_args:
222 ext.extra_compile_args.append('-std=c99')
mattip18af8e02020-01-04 20:47:47223 build_ext.build_extension(self, ext)
224 return new_build_clib, new_build_ext
225
226
Julian Taylorc9fd6342014-04-05 11:13:13227def generate_cython():
Charles Harrisdf8d1fd2022-02-04 23:21:58228 # Check Cython version
229 from numpy.compat import _pep440
230 try:
231 # try the cython in the installed python first (somewhat related to
232 # scipy/scipy#2397)
233 import Cython
234 from Cython.Compiler.Version import version as cython_version
235 except ImportError as e:
236 # The `cython` command need not point to the version installed in the
237 # Python running this script, so raise an error to avoid the chance of
238 # using the wrong version of Cython.
239 msg = 'Cython needs to be installed in Python as a module'
240 raise OSError(msg) from e
241 else:
242 # Note: keep in sync with that in pyproject.toml
Mariusz Felisiak73a9e8e2022-05-16 11:43:33243 # Update for Python 3.11
Mariusz Felisiakc0696c5f22022-05-18 05:19:02244 required_version = '0.29.30'
Charles Harrisdf8d1fd2022-02-04 23:21:58245
246 if _pep440.parse(cython_version) < _pep440.Version(required_version):
247 cython_path = Cython.__file__
248 msg = 'Building NumPy requires Cython >= {}, found {} at {}'
249 msg = msg.format(required_version, cython_version, cython_path)
250 raise RuntimeError(msg)
251
252 # Process files
Julian Taylorc9fd6342014-04-05 11:13:13253 cwd = os.path.abspath(os.path.dirname(__file__))
254 print("Cythonizing sources")
mattip4e6a8122019-05-23 04:54:47255 for d in ('random',):
mattipfa8af412019-03-20 10:39:53256 p = subprocess.call([sys.executable,
Hugo van Kemenade2ebb4532020-10-04 09:41:47257 os.path.join(cwd, 'tools', 'cythonize.py'),
258 'numpy/{0}'.format(d)],
259 cwd=cwd)
mattipfa8af412019-03-20 10:39:53260 if p != 0:
261 raise RuntimeError("Running cythonize failed!")
Julian Taylorc9fd6342014-04-05 11:13:13262
Ralf Gommers4b0ed792015-12-29 10:29:38263
Ralf Gommersb9f48092015-12-29 11:05:30264def parse_setuppy_commands():
Ralf Gommers99e99e92015-12-29 14:24:22265 """Check the commands and respond appropriately. Disable broken commands.
266
267 Return a boolean value for whether or not to run the build or not (avoid
268 parsing Cython and template files if False).
269 """
Eric Wieserb8b2a0e2018-03-12 08:29:52270 args = sys.argv[1:]
271
272 if not args:
Ralf Gommersb9f48092015-12-29 11:05:30273 # User forgot to give an argument probably, let setuptools handle that.
Ralf Gommers99e99e92015-12-29 14:24:22274 return True
Ralf Gommersb9f48092015-12-29 11:05:30275
Ralf Gommers99e99e92015-12-29 14:24:22276 info_commands = ['--help-commands', '--name', '--version', '-V',
277 '--fullname', '--author', '--author-email',
278 '--maintainer', '--maintainer-email', '--contact',
279 '--contact-email', '--url', '--license', '--description',
280 '--long-description', '--platforms', '--classifiers',
Charles Harris9b3f6502020-12-20 23:35:37281 '--keywords', '--provides', '--requires', '--obsoletes',
282 'version',]
Ralf Gommers99e99e92015-12-29 14:24:22283
284 for command in info_commands:
Eric Wieserb8b2a0e2018-03-12 08:29:52285 if command in args:
Ralf Gommers99e99e92015-12-29 14:24:22286 return False
287
288 # Note that 'alias', 'saveopts' and 'setopt' commands also seem to work
289 # fine as they are, but are usually used together with one of the commands
290 # below and not standalone. Hence they're not added to good_commands.
291 good_commands = ('develop', 'sdist', 'build', 'build_ext', 'build_py',
Ralf Gommersab5c6d02016-01-16 14:21:23292 'build_clib', 'build_scripts', 'bdist_wheel', 'bdist_rpm',
Ralf Gommers491d26b2021-01-27 21:48:58293 'bdist_wininst', 'bdist_msi', 'bdist_mpkg', 'build_src',
294 'bdist_egg')
Ralf Gommers99e99e92015-12-29 14:24:22295
Ralf Gommersb9f48092015-12-29 11:05:30296 for command in good_commands:
Eric Wieserb8b2a0e2018-03-12 08:29:52297 if command in args:
Ralf Gommers99e99e92015-12-29 14:24:22298 return True
Ralf Gommersb9f48092015-12-29 11:05:30299
Ralf Gommersab5c6d02016-01-16 14:21:23300 # The following commands are supported, but we need to show more
Ralf Gommers99e99e92015-12-29 14:24:22301 # useful messages to the user
Eric Wieserb8b2a0e2018-03-12 08:29:52302 if 'install' in args:
Ralf Gommers99e99e92015-12-29 14:24:22303 print(textwrap.dedent("""
304 Note: if you need reliable uninstall behavior, then install
305 with pip instead of using `setup.py install`:
306
307 - `pip install .` (from a git repo or downloaded source
308 release)
Nihaal Sangha5ab126b2022-01-20 16:58:11309 - `pip install numpy` (last NumPy release on PyPI)
Ralf Gommers99e99e92015-12-29 14:24:22310
311 """))
312 return True
313
Eric Wieserb8b2a0e2018-03-12 08:29:52314 if '--help' in args or '-h' in sys.argv[1]:
Ralf Gommers99e99e92015-12-29 14:24:22315 print(textwrap.dedent("""
Pierre de Buyl3f6672a2016-09-06 12:54:08316 NumPy-specific help
Ralf Gommers99e99e92015-12-29 14:24:22317 -------------------
318
Pierre de Buyl3f6672a2016-09-06 12:54:08319 To install NumPy from here with reliable uninstall, we recommend
320 that you use `pip install .`. To install the latest NumPy release
Nihaal Sangha5ab126b2022-01-20 16:58:11321 from PyPI, use `pip install numpy`.
Ralf Gommers99e99e92015-12-29 14:24:22322
323 For help with build/installation issues, please ask on the
324 numpy-discussion mailing list. If you are sure that you have run
325 into a bug, please report it at https://github.com/numpy/numpy/issues.
326
327 Setuptools commands help
328 ------------------------
329 """))
330 return False
331
332 # The following commands aren't supported. They can only be executed when
333 # the user explicitly adds a --force command-line argument.
Ralf Gommersb9f48092015-12-29 11:05:30334 bad_commands = dict(
335 test="""
336 `setup.py test` is not supported. Use one of the following
337 instead:
338
339 - `python runtests.py` (to build and test)
340 - `python runtests.py --no-build` (to test installed numpy)
341 - `>>> numpy.test()` (run tests for installed numpy
342 from within an interpreter)
343 """,
344 upload="""
345 `setup.py upload` is not supported, because it's insecure.
346 Instead, build what you want to upload and upload those files
347 with `twine upload -s <filenames>` instead.
348 """,
Ralf Gommersb9f48092015-12-29 11:05:30349 clean="""
350 `setup.py clean` is not supported, use one of the following instead:
351
352 - `git clean -xdf` (cleans all files)
353 - `git clean -Xdf` (cleans all versioned files, doesn't touch
354 files that aren't checked into the git repo)
355 """,
Ralf Gommers99e99e92015-12-29 14:24:22356 build_sphinx="""
357 `setup.py build_sphinx` is not supported, use the
358 Makefile under doc/""",
359 flake8="`setup.py flake8` is not supported, use flake8 standalone",
Ralf Gommersb9f48092015-12-29 11:05:30360 )
Ralf Gommers99e99e92015-12-29 14:24:22361 bad_commands['nosetests'] = bad_commands['test']
Luca Mussi69d2cc82016-04-07 11:24:49362 for command in ('upload_docs', 'easy_install', 'bdist', 'bdist_dumb',
Hugo van Kemenade2ebb4532020-10-04 09:41:47363 'register', 'check', 'install_data', 'install_headers',
364 'install_lib', 'install_scripts', ):
Ralf Gommers99e99e92015-12-29 14:24:22365 bad_commands[command] = "`setup.py %s` is not supported" % command
366
Ralf Gommersb9f48092015-12-29 11:05:30367 for command in bad_commands.keys():
Eric Wieserb8b2a0e2018-03-12 08:29:52368 if command in args:
Ralf Gommersb9f48092015-12-29 11:05:30369 print(textwrap.dedent(bad_commands[command]) +
370 "\nAdd `--force` to your command to use it anyway if you "
371 "must (unsupported).\n")
372 sys.exit(1)
373
Eric Wieserb8b2a0e2018-03-12 08:29:52374 # Commands that do more than print info, but also don't need Cython and
375 # template parsing.
Charles Harris9b3f6502020-12-20 23:35:37376 other_commands = ['egg_info', 'install_egg_info', 'rotate', 'dist_info']
Eric Wieserb8b2a0e2018-03-12 08:29:52377 for command in other_commands:
378 if command in args:
379 return False
380
Ralf Gommers99e99e92015-12-29 14:24:22381 # If we got here, we didn't detect what setup.py command was given
Charles Harris9b3f6502020-12-20 23:35:37382 raise RuntimeError("Unrecognized setuptools command: {}".format(args))
Ralf Gommersb9f48092015-12-29 11:05:30383
384
Eric Wieserfb47ba62020-06-20 16:28:51385def get_docs_url():
Charles Harris40fd17e2020-12-02 20:06:51386 if 'dev' in VERSION:
Eric Wieserfb47ba62020-06-20 16:28:51387 return "https://numpy.org/devdocs"
388 else:
Nihaal Sangha5ab126b2022-01-20 16:58:11389 # For releases, this URL ends up on PyPI.
Eric Wieserfb47ba62020-06-20 16:28:51390 # By pinning the version, users looking at old PyPI releases can get
391 # to the associated docs easily.
392 return "https://numpy.org/doc/{}.{}".format(MAJOR, MINOR)
393
394
Ralf Gommers17716d72013-12-06 19:45:40395def setup_package():
mattip8b266552019-07-03 22:24:42396 src_path = os.path.dirname(os.path.abspath(__file__))
Pauli Virtanen68159432009-12-06 11:56:18397 old_path = os.getcwd()
398 os.chdir(src_path)
399 sys.path.insert(0, src_path)
400
Charles Harrisf22a33b2018-08-22 17:57:48401 # The f2py scripts that will be installed
402 if sys.platform == 'win32':
403 f2py_cmds = [
404 'f2py = numpy.f2py.f2py2e:main',
405 ]
406 else:
407 f2py_cmds = [
408 'f2py = numpy.f2py.f2py2e:main',
409 'f2py%s = numpy.f2py.f2py2e:main' % sys.version_info[:1],
410 'f2py%s.%s = numpy.f2py.f2py2e:main' % sys.version_info[:2],
411 ]
412
Charles Harris40fd17e2020-12-02 20:06:51413 cmdclass["sdist"] = sdist_checked
Ralf Gommers17716d72013-12-06 19:45:40414 metadata = dict(
Hugo van Kemenade2ebb4532020-10-04 09:41:47415 name='numpy',
416 maintainer="NumPy Developers",
417 maintainer_email="numpy-discussion@python.org",
hannah6c2fa302022-11-01 16:28:36418 description="Fundamental package for array computing in Python",
419 long_description=Path("README.md").read_text(encoding="utf-8"),
hannahce57eea2022-10-31 03:00:03420 long_description_content_type="text/markdown",
Hugo van Kemenade2ebb4532020-10-04 09:41:47421 url="https://www.numpy.org",
422 author="Travis E. Oliphant et al.",
423 download_url="https://pypi.python.org/pypi/numpy",
Jarrod Millman0486b6d2019-04-12 01:11:21424 project_urls={
425 "Bug Tracker": "https://github.com/numpy/numpy/issues",
Eric Wieserfb47ba62020-06-20 16:28:51426 "Documentation": get_docs_url(),
Jarrod Millman0486b6d2019-04-12 01:11:21427 "Source Code": "https://github.com/numpy/numpy",
428 },
Frazer McLean033503c2022-10-28 16:53:09429 license='BSD-3-Clause',
Ralf Gommers17716d72013-12-06 19:45:40430 classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
Hugo van Kemenade2ebb4532020-10-04 09:41:47431 platforms=["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
Charles Harrisb3b6cc02020-05-18 22:26:10432 test_suite='pytest',
Charles Harris40fd17e2020-12-02 20:06:51433 version=versioneer.get_version(),
mattip18af8e02020-01-04 20:47:47434 cmdclass=cmdclass,
Charles Harris9a176d02021-08-13 15:53:41435 python_requires='>=3.8',
Nathaniel J. Smithf46e7162018-01-23 08:02:04436 zip_safe=False,
Charles Harrisf22a33b2018-08-22 17:57:48437 entry_points={
Matthew Barberdf6d2852021-08-31 09:23:14438 'console_scripts': f2py_cmds,
439 'array_api': ['numpy = numpy.array_api'],
bwoodsendbac9d0e2022-01-06 00:55:16440 'pyinstaller40': ['hook-dirs = numpy:_pyinstaller_hooks_dir'],
Charles Harrisf22a33b2018-08-22 17:57:48441 },
Ralf Gommers17716d72013-12-06 19:45:40442 )
443
Ralf Gommers99e99e92015-12-29 14:24:22444 if "--force" in sys.argv:
445 run_build = True
Ralf Gommers20c3c2a2017-06-20 10:09:40446 sys.argv.remove('--force')
Ralf Gommers99e99e92015-12-29 14:24:22447 else:
448 # Raise errors for unsupported commands, improve help output, etc.
449 run_build = parse_setuppy_commands()
Ralf Gommersb9f48092015-12-29 11:05:30450
Charles Harris9b3f6502020-12-20 23:35:37451 if run_build:
Mike Taves07bf33f2020-02-04 19:21:51452 # patches distutils, even though we don't use it
Charles Harris40fd17e2020-12-02 20:06:51453 #from setuptools import setup
Ralf Gommers17716d72013-12-06 19:45:40454 from numpy.distutils.core import setup
Charles Harris40fd17e2020-12-02 20:06:51455
Hugo van Kemenade2ebb4532020-10-04 09:41:47456 if 'sdist' not in sys.argv:
Ralf Gommersd630d962019-09-08 05:01:41457 # Generate Cython sources, unless we're generating an sdist
Julian Taylorc9fd6342014-04-05 11:13:13458 generate_cython()
Ralf Gommers4b0ed792015-12-29 10:29:38459
Ralf Gommers17716d72013-12-06 19:45:40460 metadata['configuration'] = configuration
mattip18af8e02020-01-04 20:47:47461 # Customize extension building
462 cmdclass['build_clib'], cmdclass['build_ext'] = get_build_overrides()
Ralf Gommers99e99e92015-12-29 14:24:22463 else:
Charles Harris40fd17e2020-12-02 20:06:51464 #from numpy.distutils.core import setup
Mike Taves07bf33f2020-02-04 19:21:51465 from setuptools import setup
Charles Harris8b942712022-12-19 01:17:51466 # workaround for broken --no-build-isolation with newer setuptools,
467 # see gh-21288
Ralf Gommers5b0bc0d2022-11-29 11:04:04468 metadata["packages"] = []
Pauli Virtanen68159432009-12-06 11:56:18469
Pearu Petersone8fa0132003-03-07 18:08:28470 try:
Ralf Gommers17716d72013-12-06 19:45:40471 setup(**metadata)
Pearu Petersone8fa0132003-03-07 18:08:28472 finally:
473 del sys.path[0]
474 os.chdir(old_path)
Travis Oliphant14db4192005-09-14 22:08:46475 return
Pearu Petersonc415fd12002-11-18 22:39:31476
Ralf Gommers17716d72013-12-06 19:45:40477
Travis Oliphant14db4192005-09-14 22:08:46478if __name__ == '__main__':
Pearu Petersone8fa0132003-03-07 18:08:28479 setup_package()
Ralf Gommersbbee7472016-08-21 05:23:35480 # This may avoid problems where numpy is installed via ``*_requires`` by
481 # setuptools, the global namespace isn't reset properly, and then numpy is
482 # imported later (which will then fail to load numpy extension modules).
483 # See gh-7956 for details
484 del builtins.__NUMPY_SETUP__