blob: 0257fc5ba7558a5def63ab05cd6e7facf43c16b3 [file] [log] [blame]
Changqing Li583901a2020-03-04 08:22:401#!/usr/bin/env python3
Ralf Gommers759dd952018-08-23 17:11:582""" NumPy is the fundamental package for array computing with Python.
Travis Oliphantda9c6da2006-01-04 17:31:073
Ralf Gommers759dd952018-08-23 17:11:584It provides:
Travis Oliphantda9c6da2006-01-04 17:31:075
Ralf Gommers759dd952018-08-23 17:11:586- a powerful N-dimensional array object
7- sophisticated (broadcasting) functions
8- tools for integrating C/C++ and Fortran code
9- useful linear algebra, Fourier transform, and random number capabilities
10- and much more
Charles Harris6aa264c2013-02-27 20:26:5811
Ralf Gommers759dd952018-08-23 17:11:5812Besides its obvious scientific uses, NumPy can also be used as an efficient
13multi-dimensional container of generic data. Arbitrary data-types can be
14defined. This allows NumPy to seamlessly and speedily integrate with a wide
15variety of databases.
Matthew Brettbe575d52016-03-07 20:52:0816
Ralf Gommers759dd952018-08-23 17:11:5817All NumPy wheels distributed on PyPI are BSD licensed.
Matthew Brettbe575d52016-03-07 20:52:0818
Travis Oliphantda9c6da2006-01-04 17:31:0719"""
David Sanders922442f2015-10-19 20:03:3420DOCLINES = (__doc__ or '').split("\n")
Pearu Petersonc415fd12002-11-18 22:39:3121
Pearu Petersone8fa0132003-03-07 18:08:2822import os
23import sys
David Cournapeau5623a7c2009-04-02 16:21:3024import subprocess
Ralf Gommers99e99e92015-12-29 14:24:2225import textwrap
Hugo van Kemenadef3a6b332020-10-04 09:09:5226import warnings
Charles Harris40fd17e2020-12-02 20:06:5127import builtins
Charles Harris9a37cd92021-05-25 19:35:4228import re
Pearu Petersonc415fd12002-11-18 22:39:3129
Ralf Gommersf66d5db2020-12-22 20:11:5030
31# Python supported version checks. Keep right after stdlib imports to ensure we
32# get a sensible error for older Python versions
Sebastian Berg3dcbecc2021-11-07 17:42:4733if sys.version_info[:2] < (3, 8):
Charles Harris9a176d02021-08-13 15:53:4134 raise RuntimeError("Python version >= 3.8 required.")
Ralf Gommersf66d5db2020-12-22 20:11:5035
36
37import versioneer
38
39
Charles Harris40fd17e2020-12-02 20:06:5140# This is a bit hackish: we are setting a global variable so that the main
41# numpy __init__ can detect if it is being loaded by the setup routine, to
42# avoid attempting to load components that aren't built yet. While ugly, it's
43# a lot more robust than what was previously being used.
44builtins.__NUMPY_SETUP__ = True
Ralf Gommers17716d72013-12-06 19:45:4045
Charles Harris40fd17e2020-12-02 20:06:5146# Needed for backwards code compatibility below and in some CI scripts.
47# The version components are changed from ints to strings, but only VERSION
48# seems to matter outside of this module and it was already a str.
49FULLVERSION = versioneer.get_version()
Charles Harris9a37cd92021-05-25 19:35:4250
51# Capture the version string:
52# 1.22.0.dev0+ ... -> ISRELEASED == False, VERSION == 1.22.0
53# 1.22.0rc1+ ... -> ISRELEASED == False, VERSION == 1.22.0
54# 1.22.0 ... -> ISRELEASED == True, VERSION == 1.22.0
55# 1.22.0rc1 ... -> ISRELEASED == True, VERSION == 1.22.0
56ISRELEASED = re.search(r'(dev|\+)', FULLVERSION) is None
Matthew Brett9db73b52021-10-23 11:05:3157_V_MATCH = re.match(r'(\d+)\.(\d+)\.(\d+)', FULLVERSION)
58if _V_MATCH is None:
59 raise RuntimeError(f'Cannot parse version {FULLVERSION}')
60MAJOR, MINOR, MICRO = _V_MATCH.groups()
Charles Harris40fd17e2020-12-02 20:06:5161VERSION = '{}.{}.{}'.format(MAJOR, MINOR, MICRO)
62
Charles Harris40fd17e2020-12-02 20:06:5163# The first version not in the `Programming Language :: Python :: ...` classifiers above
Bas van Beek856d6d62021-10-05 15:49:0364if sys.version_info >= (3, 11):
Charles Harrisca11e4e2020-12-12 15:17:0165 fmt = "NumPy {} may not yet support Python {}.{}."
Charles Harris40fd17e2020-12-02 20:06:5166 warnings.warn(
Charles Harrisca11e4e2020-12-12 15:17:0167 fmt.format(VERSION, *sys.version_info[:2]),
68 RuntimeWarning)
69 del fmt
David Cournapeau2b517692009-12-03 15:53:2970
Charles Harris40fd17e2020-12-02 20:06:5171# BEFORE importing setuptools, remove MANIFEST. Otherwise it may not be
72# properly updated when the contents of directories change (true for distutils,
73# not sure about setuptools).
74if os.path.exists('MANIFEST'):
75 os.remove('MANIFEST')
76
77# We need to import setuptools here in order for it to persist in sys.modules.
Charles Harrisfed25092020-12-10 18:58:4778# Its presence/absence is used in subclassing setup in numpy/distutils/core.py.
79# However, we need to run the distutils version of sdist, so import that first
80# so that it is in sys.modules
81import numpy.distutils.command.sdist
Charles Harris40fd17e2020-12-02 20:06:5182import setuptools
Charles Harriseb6be7c2022-01-06 23:51:2083if int(setuptools.__version__.split('.')[0]) >= 60:
Andrew J. Hesfordf30858a2022-02-01 15:34:2684 # setuptools >= 60 switches to vendored distutils by default; this
85 # may break the numpy build, so make sure the stdlib version is used
86 try:
87 setuptools_use_distutils = os.environ['SETUPTOOLS_USE_DISTUTILS']
88 except KeyError:
89 os.environ['SETUPTOOLS_USE_DISTUTILS'] = "stdlib"
90 else:
91 if setuptools_use_distutils != "stdlib":
92 raise RuntimeError("setuptools versions >= '60.0.0' require "
93 "SETUPTOOLS_USE_DISTUTILS=stdlib in the environment")
Charles Harris40fd17e2020-12-02 20:06:5194
95# Initialize cmdclass from versioneer
96from numpy.distutils.core import numpy_cmdclass
97cmdclass = versioneer.get_cmdclass(numpy_cmdclass)
Ralf Gommers17716d72013-12-06 19:45:4098
Travis Oliphantda9c6da2006-01-04 17:31:0799CLASSIFIERS = """\
Robert Kern19da9712008-06-18 22:53:44100Development Status :: 5 - Production/Stable
Travis Oliphantda9c6da2006-01-04 17:31:07101Intended Audience :: Science/Research
102Intended Audience :: Developers
johnthagen5cb80d62020-10-22 12:43:03103License :: OSI Approved :: BSD License
Travis Oliphantda9c6da2006-01-04 17:31:07104Programming Language :: C
105Programming Language :: Python
rgommerscdac1202011-01-25 14:02:40106Programming Language :: Python :: 3
Grzegorz Bokotac861a362019-10-24 18:29:09107Programming Language :: Python :: 3.8
Hugo van Kemenade79a8e162020-10-04 11:59:53108Programming Language :: Python :: 3.9
Charles Harris9a176d02021-08-13 15:53:41109Programming Language :: Python :: 3.10
Jon Dufresne334201d2019-08-27 04:18:35110Programming Language :: Python :: 3 :: Only
Alex Willmer193668a2015-08-05 09:29:39111Programming Language :: Python :: Implementation :: CPython
Travis Oliphantda9c6da2006-01-04 17:31:07112Topic :: Software Development
113Topic :: Scientific/Engineering
Bas van Beeke592c272020-10-04 13:10:42114Typing :: Typed
Travis Oliphantda9c6da2006-01-04 17:31:07115Operating System :: Microsoft :: Windows
116Operating System :: POSIX
117Operating System :: Unix
118Operating System :: MacOS
119"""
120
Ralf Gommers17716d72013-12-06 19:45:40121
Hugo van Kemenade2ebb4532020-10-04 09:41:47122def configuration(parent_package='', top_path=None):
Pearu Peterson471196b2006-03-31 08:59:36123 from numpy.distutils.misc_util import Configuration
124
Pearu Peterson17d7cfe2006-04-04 12:26:14125 config = Configuration(None, parent_package, top_path)
Pearu Peterson471196b2006-03-31 08:59:36126 config.set_options(ignore_setup_xxx_py=True,
127 assume_default_configuration=True,
128 delegate_options_to_subpackages=True,
129 quiet=True)
Jarrod Millman0b77f0e2007-10-29 14:58:18130
Pearu Peterson471196b2006-03-31 08:59:36131 config.add_subpackage('numpy')
Charles Harris054d93a2017-11-29 18:53:21132 config.add_data_files(('numpy', 'LICENSE.txt'))
scodere1211b82020-08-05 04:28:30133 config.add_data_files(('numpy', 'numpy/*.pxd'))
Jarrod Millman0b77f0e2007-10-29 14:58:18134
Hugo van Kemenade2ebb4532020-10-04 09:41:47135 config.get_version('numpy/version.py') # sets config.version
Travis Oliphant00a35872007-05-31 04:57:01136
Pearu Peterson471196b2006-03-31 08:59:36137 return config
138
Ralf Gommers4b0ed792015-12-29 10:29:38139
Julian Taylor4cd72742014-01-29 21:59:19140def check_submodules():
141 """ verify that the submodules are checked out and clean
142 use `git submodule update --init`; on failure
143 """
144 if not os.path.exists('.git'):
145 return
146 with open('.gitmodules') as f:
Hugo van Kemenade2ebb4532020-10-04 09:41:47147 for line in f:
148 if 'path' in line:
149 p = line.split('=')[-1].strip()
Julian Taylor4cd72742014-01-29 21:59:19150 if not os.path.exists(p):
Wojciech Rzadkowskidabf31c2020-05-22 15:43:08151 raise ValueError('Submodule {} missing'.format(p))
Julian Taylor4cd72742014-01-29 21:59:19152
Julian Taylor4cd72742014-01-29 21:59:19153 proc = subprocess.Popen(['git', 'submodule', 'status'],
154 stdout=subprocess.PIPE)
155 status, _ = proc.communicate()
156 status = status.decode("ascii", "replace")
157 for line in status.splitlines():
158 if line.startswith('-') or line.startswith('+'):
Wojciech Rzadkowskidabf31c2020-05-22 15:43:08159 raise ValueError('Submodule not clean: {}'.format(line))
Julian Taylor4cd72742014-01-29 21:59:19160
Ralf Gommers4b0ed792015-12-29 10:29:38161
Ralf Gommersa08fb602019-05-03 14:44:23162class concat_license_files():
Ralf Gommers33415902019-05-07 09:00:50163 """Merge LICENSE.txt and LICENSES_bundled.txt for sdist creation
Ralf Gommersa08fb602019-05-03 14:44:23164
165 Done this way to keep LICENSE.txt in repo as exact BSD 3-clause (see
166 gh-13447). This makes GitHub state correctly how NumPy is licensed.
167 """
168 def __init__(self):
169 self.f1 = 'LICENSE.txt'
Ralf Gommers33415902019-05-07 09:00:50170 self.f2 = 'LICENSES_bundled.txt'
Ralf Gommersa08fb602019-05-03 14:44:23171
172 def __enter__(self):
Ralf Gommers33415902019-05-07 09:00:50173 """Concatenate files and remove LICENSES_bundled.txt"""
Ralf Gommersa08fb602019-05-03 14:44:23174 with open(self.f1, 'r') as f1:
175 self.bsd_text = f1.read()
176
177 with open(self.f1, 'a') as f1:
178 with open(self.f2, 'r') as f2:
179 self.bundled_text = f2.read()
180 f1.write('\n\n')
181 f1.write(self.bundled_text)
182
Ralf Gommersa08fb602019-05-03 14:44:23183 def __exit__(self, exception_type, exception_value, traceback):
184 """Restore content of both files"""
185 with open(self.f1, 'w') as f:
186 f.write(self.bsd_text)
187
Ralf Gommersa08fb602019-05-03 14:44:23188
Charles Harrisfed25092020-12-10 18:58:47189# Need to inherit from versioneer version of sdist to get the encoded
190# version information.
191class sdist_checked(cmdclass['sdist']):
Julian Taylor4cd72742014-01-29 21:59:19192 """ check submodules on sdist to prevent incomplete tarballs """
193 def run(self):
194 check_submodules()
Ralf Gommersa08fb602019-05-03 14:44:23195 with concat_license_files():
Charles Harrisfed25092020-12-10 18:58:47196 super().run()
Travis Oliphant14db4192005-09-14 22:08:46197
Ralf Gommers4b0ed792015-12-29 10:29:38198
mattip18af8e02020-01-04 20:47:47199def get_build_overrides():
200 """
mattipc2f93002020-01-05 15:00:30201 Custom build commands to add `-std=c99` to compilation
mattip18af8e02020-01-04 20:47:47202 """
203 from numpy.distutils.command.build_clib import build_clib
204 from numpy.distutils.command.build_ext import build_ext
mattip57fb47c2020-07-28 03:39:16205 from distutils.version import LooseVersion
mattip18af8e02020-01-04 20:47:47206
mattip10dcfb02020-07-28 08:56:35207 def _needs_gcc_c99_flag(obj):
208 if obj.compiler.compiler_type != 'unix':
209 return False
210
211 cc = obj.compiler.compiler[0]
212 if "gcc" not in cc:
213 return False
214
215 # will print something like '4.2.1\n'
216 out = subprocess.run([cc, '-dumpversion'], stdout=subprocess.PIPE,
217 stderr=subprocess.PIPE, universal_newlines=True)
218 # -std=c99 is default from this version on
219 if LooseVersion(out.stdout) >= LooseVersion('5.0'):
220 return False
221 return True
mattip18af8e02020-01-04 20:47:47222
223 class new_build_clib(build_clib):
224 def build_a_library(self, build_info, lib_name, libraries):
mattip10dcfb02020-07-28 08:56:35225 if _needs_gcc_c99_flag(self):
serge-sans-paille2ae7aeb2021-08-19 07:28:09226 build_info['extra_cflags'] = ['-std=c99']
227 build_info['extra_cxxflags'] = ['-std=c++11']
mattip18af8e02020-01-04 20:47:47228 build_clib.build_a_library(self, build_info, lib_name, libraries)
229
230 class new_build_ext(build_ext):
231 def build_extension(self, ext):
mattip10dcfb02020-07-28 08:56:35232 if _needs_gcc_c99_flag(self):
mattipc2f93002020-01-05 15:00:30233 if '-std=c99' not in ext.extra_compile_args:
234 ext.extra_compile_args.append('-std=c99')
mattip18af8e02020-01-04 20:47:47235 build_ext.build_extension(self, ext)
236 return new_build_clib, new_build_ext
237
238
Julian Taylorc9fd6342014-04-05 11:13:13239def generate_cython():
240 cwd = os.path.abspath(os.path.dirname(__file__))
241 print("Cythonizing sources")
mattip4e6a8122019-05-23 04:54:47242 for d in ('random',):
mattipfa8af412019-03-20 10:39:53243 p = subprocess.call([sys.executable,
Hugo van Kemenade2ebb4532020-10-04 09:41:47244 os.path.join(cwd, 'tools', 'cythonize.py'),
245 'numpy/{0}'.format(d)],
246 cwd=cwd)
mattipfa8af412019-03-20 10:39:53247 if p != 0:
248 raise RuntimeError("Running cythonize failed!")
Julian Taylorc9fd6342014-04-05 11:13:13249
Ralf Gommers4b0ed792015-12-29 10:29:38250
Ralf Gommersb9f48092015-12-29 11:05:30251def parse_setuppy_commands():
Ralf Gommers99e99e92015-12-29 14:24:22252 """Check the commands and respond appropriately. Disable broken commands.
253
254 Return a boolean value for whether or not to run the build or not (avoid
255 parsing Cython and template files if False).
256 """
Eric Wieserb8b2a0e2018-03-12 08:29:52257 args = sys.argv[1:]
258
259 if not args:
Ralf Gommersb9f48092015-12-29 11:05:30260 # User forgot to give an argument probably, let setuptools handle that.
Ralf Gommers99e99e92015-12-29 14:24:22261 return True
Ralf Gommersb9f48092015-12-29 11:05:30262
Ralf Gommers99e99e92015-12-29 14:24:22263 info_commands = ['--help-commands', '--name', '--version', '-V',
264 '--fullname', '--author', '--author-email',
265 '--maintainer', '--maintainer-email', '--contact',
266 '--contact-email', '--url', '--license', '--description',
267 '--long-description', '--platforms', '--classifiers',
Charles Harris9b3f6502020-12-20 23:35:37268 '--keywords', '--provides', '--requires', '--obsoletes',
269 'version',]
Ralf Gommers99e99e92015-12-29 14:24:22270
271 for command in info_commands:
Eric Wieserb8b2a0e2018-03-12 08:29:52272 if command in args:
Ralf Gommers99e99e92015-12-29 14:24:22273 return False
274
275 # Note that 'alias', 'saveopts' and 'setopt' commands also seem to work
276 # fine as they are, but are usually used together with one of the commands
277 # below and not standalone. Hence they're not added to good_commands.
278 good_commands = ('develop', 'sdist', 'build', 'build_ext', 'build_py',
Ralf Gommersab5c6d02016-01-16 14:21:23279 'build_clib', 'build_scripts', 'bdist_wheel', 'bdist_rpm',
Ralf Gommers491d26b2021-01-27 21:48:58280 'bdist_wininst', 'bdist_msi', 'bdist_mpkg', 'build_src',
281 'bdist_egg')
Ralf Gommers99e99e92015-12-29 14:24:22282
Ralf Gommersb9f48092015-12-29 11:05:30283 for command in good_commands:
Eric Wieserb8b2a0e2018-03-12 08:29:52284 if command in args:
Ralf Gommers99e99e92015-12-29 14:24:22285 return True
Ralf Gommersb9f48092015-12-29 11:05:30286
Ralf Gommersab5c6d02016-01-16 14:21:23287 # The following commands are supported, but we need to show more
Ralf Gommers99e99e92015-12-29 14:24:22288 # useful messages to the user
Eric Wieserb8b2a0e2018-03-12 08:29:52289 if 'install' in args:
Ralf Gommers99e99e92015-12-29 14:24:22290 print(textwrap.dedent("""
291 Note: if you need reliable uninstall behavior, then install
292 with pip instead of using `setup.py install`:
293
294 - `pip install .` (from a git repo or downloaded source
295 release)
Pierre de Buyl3f6672a2016-09-06 12:54:08296 - `pip install numpy` (last NumPy release on PyPi)
Ralf Gommers99e99e92015-12-29 14:24:22297
298 """))
299 return True
300
Eric Wieserb8b2a0e2018-03-12 08:29:52301 if '--help' in args or '-h' in sys.argv[1]:
Ralf Gommers99e99e92015-12-29 14:24:22302 print(textwrap.dedent("""
Pierre de Buyl3f6672a2016-09-06 12:54:08303 NumPy-specific help
Ralf Gommers99e99e92015-12-29 14:24:22304 -------------------
305
Pierre de Buyl3f6672a2016-09-06 12:54:08306 To install NumPy from here with reliable uninstall, we recommend
307 that you use `pip install .`. To install the latest NumPy release
Ralf Gommers99e99e92015-12-29 14:24:22308 from PyPi, use `pip install numpy`.
309
310 For help with build/installation issues, please ask on the
311 numpy-discussion mailing list. If you are sure that you have run
312 into a bug, please report it at https://github.com/numpy/numpy/issues.
313
314 Setuptools commands help
315 ------------------------
316 """))
317 return False
318
319 # The following commands aren't supported. They can only be executed when
320 # the user explicitly adds a --force command-line argument.
Ralf Gommersb9f48092015-12-29 11:05:30321 bad_commands = dict(
322 test="""
323 `setup.py test` is not supported. Use one of the following
324 instead:
325
326 - `python runtests.py` (to build and test)
327 - `python runtests.py --no-build` (to test installed numpy)
328 - `>>> numpy.test()` (run tests for installed numpy
329 from within an interpreter)
330 """,
331 upload="""
332 `setup.py upload` is not supported, because it's insecure.
333 Instead, build what you want to upload and upload those files
334 with `twine upload -s <filenames>` instead.
335 """,
Ralf Gommersb9f48092015-12-29 11:05:30336 clean="""
337 `setup.py clean` is not supported, use one of the following instead:
338
339 - `git clean -xdf` (cleans all files)
340 - `git clean -Xdf` (cleans all versioned files, doesn't touch
341 files that aren't checked into the git repo)
342 """,
Ralf Gommers99e99e92015-12-29 14:24:22343 build_sphinx="""
344 `setup.py build_sphinx` is not supported, use the
345 Makefile under doc/""",
346 flake8="`setup.py flake8` is not supported, use flake8 standalone",
Ralf Gommersb9f48092015-12-29 11:05:30347 )
Ralf Gommers99e99e92015-12-29 14:24:22348 bad_commands['nosetests'] = bad_commands['test']
Luca Mussi69d2cc82016-04-07 11:24:49349 for command in ('upload_docs', 'easy_install', 'bdist', 'bdist_dumb',
Hugo van Kemenade2ebb4532020-10-04 09:41:47350 'register', 'check', 'install_data', 'install_headers',
351 'install_lib', 'install_scripts', ):
Ralf Gommers99e99e92015-12-29 14:24:22352 bad_commands[command] = "`setup.py %s` is not supported" % command
353
Ralf Gommersb9f48092015-12-29 11:05:30354 for command in bad_commands.keys():
Eric Wieserb8b2a0e2018-03-12 08:29:52355 if command in args:
Ralf Gommersb9f48092015-12-29 11:05:30356 print(textwrap.dedent(bad_commands[command]) +
357 "\nAdd `--force` to your command to use it anyway if you "
358 "must (unsupported).\n")
359 sys.exit(1)
360
Eric Wieserb8b2a0e2018-03-12 08:29:52361 # Commands that do more than print info, but also don't need Cython and
362 # template parsing.
Charles Harris9b3f6502020-12-20 23:35:37363 other_commands = ['egg_info', 'install_egg_info', 'rotate', 'dist_info']
Eric Wieserb8b2a0e2018-03-12 08:29:52364 for command in other_commands:
365 if command in args:
366 return False
367
Ralf Gommers99e99e92015-12-29 14:24:22368 # If we got here, we didn't detect what setup.py command was given
Charles Harris9b3f6502020-12-20 23:35:37369 raise RuntimeError("Unrecognized setuptools command: {}".format(args))
Ralf Gommersb9f48092015-12-29 11:05:30370
371
Eric Wieserfb47ba62020-06-20 16:28:51372def get_docs_url():
Charles Harris40fd17e2020-12-02 20:06:51373 if 'dev' in VERSION:
Eric Wieserfb47ba62020-06-20 16:28:51374 return "https://numpy.org/devdocs"
375 else:
Qiyu8779d3062020-11-03 12:30:49376 # For releases, this URL ends up on pypi.
Eric Wieserfb47ba62020-06-20 16:28:51377 # By pinning the version, users looking at old PyPI releases can get
378 # to the associated docs easily.
379 return "https://numpy.org/doc/{}.{}".format(MAJOR, MINOR)
380
381
Ralf Gommers17716d72013-12-06 19:45:40382def setup_package():
mattip8b266552019-07-03 22:24:42383 src_path = os.path.dirname(os.path.abspath(__file__))
Pauli Virtanen68159432009-12-06 11:56:18384 old_path = os.getcwd()
385 os.chdir(src_path)
386 sys.path.insert(0, src_path)
387
Charles Harrisf22a33b2018-08-22 17:57:48388 # The f2py scripts that will be installed
389 if sys.platform == 'win32':
390 f2py_cmds = [
391 'f2py = numpy.f2py.f2py2e:main',
392 ]
393 else:
394 f2py_cmds = [
395 'f2py = numpy.f2py.f2py2e:main',
396 'f2py%s = numpy.f2py.f2py2e:main' % sys.version_info[:1],
397 'f2py%s.%s = numpy.f2py.f2py2e:main' % sys.version_info[:2],
398 ]
399
Charles Harris40fd17e2020-12-02 20:06:51400 cmdclass["sdist"] = sdist_checked
Ralf Gommers17716d72013-12-06 19:45:40401 metadata = dict(
Hugo van Kemenade2ebb4532020-10-04 09:41:47402 name='numpy',
403 maintainer="NumPy Developers",
404 maintainer_email="numpy-discussion@python.org",
405 description=DOCLINES[0],
406 long_description="\n".join(DOCLINES[2:]),
407 url="https://www.numpy.org",
408 author="Travis E. Oliphant et al.",
409 download_url="https://pypi.python.org/pypi/numpy",
Jarrod Millman0486b6d2019-04-12 01:11:21410 project_urls={
411 "Bug Tracker": "https://github.com/numpy/numpy/issues",
Eric Wieserfb47ba62020-06-20 16:28:51412 "Documentation": get_docs_url(),
Jarrod Millman0486b6d2019-04-12 01:11:21413 "Source Code": "https://github.com/numpy/numpy",
414 },
Hugo van Kemenade2ebb4532020-10-04 09:41:47415 license='BSD',
Ralf Gommers17716d72013-12-06 19:45:40416 classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
Hugo van Kemenade2ebb4532020-10-04 09:41:47417 platforms=["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
Charles Harrisb3b6cc02020-05-18 22:26:10418 test_suite='pytest',
Charles Harris40fd17e2020-12-02 20:06:51419 version=versioneer.get_version(),
mattip18af8e02020-01-04 20:47:47420 cmdclass=cmdclass,
Charles Harris9a176d02021-08-13 15:53:41421 python_requires='>=3.8',
Nathaniel J. Smithf46e7162018-01-23 08:02:04422 zip_safe=False,
Charles Harrisf22a33b2018-08-22 17:57:48423 entry_points={
Matthew Barberdf6d2852021-08-31 09:23:14424 'console_scripts': f2py_cmds,
425 'array_api': ['numpy = numpy.array_api'],
Charles Harrisf22a33b2018-08-22 17:57:48426 },
Ralf Gommers17716d72013-12-06 19:45:40427 )
428
Ralf Gommers99e99e92015-12-29 14:24:22429 if "--force" in sys.argv:
430 run_build = True
Ralf Gommers20c3c2a2017-06-20 10:09:40431 sys.argv.remove('--force')
Ralf Gommers99e99e92015-12-29 14:24:22432 else:
433 # Raise errors for unsupported commands, improve help output, etc.
434 run_build = parse_setuppy_commands()
Ralf Gommersb9f48092015-12-29 11:05:30435
Charles Harris9b3f6502020-12-20 23:35:37436 if run_build:
Mike Taves07bf33f2020-02-04 19:21:51437 # patches distutils, even though we don't use it
Charles Harris40fd17e2020-12-02 20:06:51438 #from setuptools import setup
Ralf Gommers17716d72013-12-06 19:45:40439 from numpy.distutils.core import setup
Charles Harris40fd17e2020-12-02 20:06:51440
Hugo van Kemenade2ebb4532020-10-04 09:41:47441 if 'sdist' not in sys.argv:
Ralf Gommersd630d962019-09-08 05:01:41442 # Generate Cython sources, unless we're generating an sdist
Julian Taylorc9fd6342014-04-05 11:13:13443 generate_cython()
Ralf Gommers4b0ed792015-12-29 10:29:38444
Ralf Gommers17716d72013-12-06 19:45:40445 metadata['configuration'] = configuration
mattip18af8e02020-01-04 20:47:47446 # Customize extension building
447 cmdclass['build_clib'], cmdclass['build_ext'] = get_build_overrides()
Ralf Gommers99e99e92015-12-29 14:24:22448 else:
Charles Harris40fd17e2020-12-02 20:06:51449 #from numpy.distutils.core import setup
Mike Taves07bf33f2020-02-04 19:21:51450 from setuptools import setup
Pauli Virtanen68159432009-12-06 11:56:18451
Pearu Petersone8fa0132003-03-07 18:08:28452 try:
Ralf Gommers17716d72013-12-06 19:45:40453 setup(**metadata)
Pearu Petersone8fa0132003-03-07 18:08:28454 finally:
455 del sys.path[0]
456 os.chdir(old_path)
Travis Oliphant14db4192005-09-14 22:08:46457 return
Pearu Petersonc415fd12002-11-18 22:39:31458
Ralf Gommers17716d72013-12-06 19:45:40459
Travis Oliphant14db4192005-09-14 22:08:46460if __name__ == '__main__':
Pearu Petersone8fa0132003-03-07 18:08:28461 setup_package()
Ralf Gommersbbee7472016-08-21 05:23:35462 # This may avoid problems where numpy is installed via ``*_requires`` by
463 # setuptools, the global namespace isn't reset properly, and then numpy is
464 # imported later (which will then fail to load numpy extension modules).
465 # See gh-7956 for details
466 del builtins.__NUMPY_SETUP__