blob: ceb9900713cec61e8d7e9af20e050b6eda3fb9e8 [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 Harris9b297422021-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
33if sys.version_info[:2] < (3, 7):
34 raise RuntimeError("Python version >= 3.7 required.")
35
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 Harris9b297422021-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
57MAJOR, MINOR, MICRO = re.match(r'(\d+)\.(\d+)\.(\d+)', FULLVERSION).groups()
Charles Harris40fd17e2020-12-02 20:06:5158VERSION = '{}.{}.{}'.format(MAJOR, MINOR, MICRO)
59
Charles Harris40fd17e2020-12-02 20:06:5160# The first version not in the `Programming Language :: Python :: ...` classifiers above
61if sys.version_info >= (3, 10):
Charles Harrisca11e4e2020-12-12 15:17:0162 fmt = "NumPy {} may not yet support Python {}.{}."
Charles Harris40fd17e2020-12-02 20:06:5163 warnings.warn(
Charles Harrisca11e4e2020-12-12 15:17:0164 fmt.format(VERSION, *sys.version_info[:2]),
65 RuntimeWarning)
66 del fmt
David Cournapeau2b517692009-12-03 15:53:2967
Charles Harris40fd17e2020-12-02 20:06:5168# BEFORE importing setuptools, remove MANIFEST. Otherwise it may not be
69# properly updated when the contents of directories change (true for distutils,
70# not sure about setuptools).
71if os.path.exists('MANIFEST'):
72 os.remove('MANIFEST')
73
74# We need to import setuptools here in order for it to persist in sys.modules.
Charles Harrisfed25092020-12-10 18:58:4775# Its presence/absence is used in subclassing setup in numpy/distutils/core.py.
76# However, we need to run the distutils version of sdist, so import that first
77# so that it is in sys.modules
78import numpy.distutils.command.sdist
Charles Harris40fd17e2020-12-02 20:06:5179import setuptools
80
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
Ralf Gommers943695b2018-06-28 02:26:1993Programming Language :: Python :: 3.7
Grzegorz Bokotac861a362019-10-24 18:29:0994Programming Language :: Python :: 3.8
Hugo van Kemenade79a8e162020-10-04 11:59:5395Programming Language :: Python :: 3.9
Charles Harrise3b5f1d2021-08-13 16:42:2696Programming Language :: Python :: 3.10
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
mattip57fb47c2020-07-28 03:39:16192 from distutils.version import LooseVersion
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'
203 out = subprocess.run([cc, '-dumpversion'], stdout=subprocess.PIPE,
204 stderr=subprocess.PIPE, universal_newlines=True)
205 # -std=c99 is default from this version on
206 if LooseVersion(out.stdout) >= LooseVersion('5.0'):
207 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):
mattip10dcfb02020-07-28 08:56:35212 if _needs_gcc_c99_flag(self):
mattip18af8e02020-01-04 20:47:47213 args = build_info.get('extra_compiler_args') or []
mattipc2f93002020-01-05 15:00:30214 args.append('-std=c99')
mattip18af8e02020-01-04 20:47:47215 build_info['extra_compiler_args'] = args
216 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():
228 cwd = os.path.abspath(os.path.dirname(__file__))
229 print("Cythonizing sources")
mattip4e6a8122019-05-23 04:54:47230 for d in ('random',):
mattipfa8af412019-03-20 10:39:53231 p = subprocess.call([sys.executable,
Hugo van Kemenade2ebb4532020-10-04 09:41:47232 os.path.join(cwd, 'tools', 'cythonize.py'),
233 'numpy/{0}'.format(d)],
234 cwd=cwd)
mattipfa8af412019-03-20 10:39:53235 if p != 0:
236 raise RuntimeError("Running cythonize failed!")
Julian Taylorc9fd6342014-04-05 11:13:13237
Ralf Gommers4b0ed792015-12-29 10:29:38238
Ralf Gommersb9f48092015-12-29 11:05:30239def parse_setuppy_commands():
Ralf Gommers99e99e92015-12-29 14:24:22240 """Check the commands and respond appropriately. Disable broken commands.
241
242 Return a boolean value for whether or not to run the build or not (avoid
243 parsing Cython and template files if False).
244 """
Eric Wieserb8b2a0e2018-03-12 08:29:52245 args = sys.argv[1:]
246
247 if not args:
Ralf Gommersb9f48092015-12-29 11:05:30248 # User forgot to give an argument probably, let setuptools handle that.
Ralf Gommers99e99e92015-12-29 14:24:22249 return True
Ralf Gommersb9f48092015-12-29 11:05:30250
Ralf Gommers99e99e92015-12-29 14:24:22251 info_commands = ['--help-commands', '--name', '--version', '-V',
252 '--fullname', '--author', '--author-email',
253 '--maintainer', '--maintainer-email', '--contact',
254 '--contact-email', '--url', '--license', '--description',
255 '--long-description', '--platforms', '--classifiers',
Charles Harris9b3f6502020-12-20 23:35:37256 '--keywords', '--provides', '--requires', '--obsoletes',
257 'version',]
Ralf Gommers99e99e92015-12-29 14:24:22258
259 for command in info_commands:
Eric Wieserb8b2a0e2018-03-12 08:29:52260 if command in args:
Ralf Gommers99e99e92015-12-29 14:24:22261 return False
262
263 # Note that 'alias', 'saveopts' and 'setopt' commands also seem to work
264 # fine as they are, but are usually used together with one of the commands
265 # below and not standalone. Hence they're not added to good_commands.
266 good_commands = ('develop', 'sdist', 'build', 'build_ext', 'build_py',
Ralf Gommersab5c6d02016-01-16 14:21:23267 'build_clib', 'build_scripts', 'bdist_wheel', 'bdist_rpm',
Ralf Gommers491d26b2021-01-27 21:48:58268 'bdist_wininst', 'bdist_msi', 'bdist_mpkg', 'build_src',
269 'bdist_egg')
Ralf Gommers99e99e92015-12-29 14:24:22270
Ralf Gommersb9f48092015-12-29 11:05:30271 for command in good_commands:
Eric Wieserb8b2a0e2018-03-12 08:29:52272 if command in args:
Ralf Gommers99e99e92015-12-29 14:24:22273 return True
Ralf Gommersb9f48092015-12-29 11:05:30274
Ralf Gommersab5c6d02016-01-16 14:21:23275 # The following commands are supported, but we need to show more
Ralf Gommers99e99e92015-12-29 14:24:22276 # useful messages to the user
Eric Wieserb8b2a0e2018-03-12 08:29:52277 if 'install' in args:
Ralf Gommers99e99e92015-12-29 14:24:22278 print(textwrap.dedent("""
279 Note: if you need reliable uninstall behavior, then install
280 with pip instead of using `setup.py install`:
281
282 - `pip install .` (from a git repo or downloaded source
283 release)
Pierre de Buyl3f6672a2016-09-06 12:54:08284 - `pip install numpy` (last NumPy release on PyPi)
Ralf Gommers99e99e92015-12-29 14:24:22285
286 """))
287 return True
288
Eric Wieserb8b2a0e2018-03-12 08:29:52289 if '--help' in args or '-h' in sys.argv[1]:
Ralf Gommers99e99e92015-12-29 14:24:22290 print(textwrap.dedent("""
Pierre de Buyl3f6672a2016-09-06 12:54:08291 NumPy-specific help
Ralf Gommers99e99e92015-12-29 14:24:22292 -------------------
293
Pierre de Buyl3f6672a2016-09-06 12:54:08294 To install NumPy from here with reliable uninstall, we recommend
295 that you use `pip install .`. To install the latest NumPy release
Ralf Gommers99e99e92015-12-29 14:24:22296 from PyPi, use `pip install numpy`.
297
298 For help with build/installation issues, please ask on the
299 numpy-discussion mailing list. If you are sure that you have run
300 into a bug, please report it at https://github.com/numpy/numpy/issues.
301
302 Setuptools commands help
303 ------------------------
304 """))
305 return False
306
Ralf Gommers99e99e92015-12-29 14:24:22307 # The following commands aren't supported. They can only be executed when
308 # the user explicitly adds a --force command-line argument.
Ralf Gommersb9f48092015-12-29 11:05:30309 bad_commands = dict(
310 test="""
311 `setup.py test` is not supported. Use one of the following
312 instead:
313
314 - `python runtests.py` (to build and test)
315 - `python runtests.py --no-build` (to test installed numpy)
316 - `>>> numpy.test()` (run tests for installed numpy
317 from within an interpreter)
318 """,
319 upload="""
320 `setup.py upload` is not supported, because it's insecure.
321 Instead, build what you want to upload and upload those files
322 with `twine upload -s <filenames>` instead.
323 """,
Ralf Gommersb9f48092015-12-29 11:05:30324 clean="""
325 `setup.py clean` is not supported, use one of the following instead:
326
327 - `git clean -xdf` (cleans all files)
328 - `git clean -Xdf` (cleans all versioned files, doesn't touch
329 files that aren't checked into the git repo)
330 """,
Ralf Gommers99e99e92015-12-29 14:24:22331 build_sphinx="""
332 `setup.py build_sphinx` is not supported, use the
333 Makefile under doc/""",
334 flake8="`setup.py flake8` is not supported, use flake8 standalone",
Ralf Gommersb9f48092015-12-29 11:05:30335 )
Ralf Gommers99e99e92015-12-29 14:24:22336 bad_commands['nosetests'] = bad_commands['test']
Luca Mussi69d2cc82016-04-07 11:24:49337 for command in ('upload_docs', 'easy_install', 'bdist', 'bdist_dumb',
Hugo van Kemenade2ebb4532020-10-04 09:41:47338 'register', 'check', 'install_data', 'install_headers',
339 'install_lib', 'install_scripts', ):
Ralf Gommers99e99e92015-12-29 14:24:22340 bad_commands[command] = "`setup.py %s` is not supported" % command
341
Ralf Gommersb9f48092015-12-29 11:05:30342 for command in bad_commands.keys():
Eric Wieserb8b2a0e2018-03-12 08:29:52343 if command in args:
Ralf Gommersb9f48092015-12-29 11:05:30344 print(textwrap.dedent(bad_commands[command]) +
345 "\nAdd `--force` to your command to use it anyway if you "
346 "must (unsupported).\n")
347 sys.exit(1)
348
Eric Wieserb8b2a0e2018-03-12 08:29:52349 # Commands that do more than print info, but also don't need Cython and
350 # template parsing.
Charles Harris9b3f6502020-12-20 23:35:37351 other_commands = ['egg_info', 'install_egg_info', 'rotate', 'dist_info']
Eric Wieserb8b2a0e2018-03-12 08:29:52352 for command in other_commands:
353 if command in args:
354 return False
355
Ralf Gommers99e99e92015-12-29 14:24:22356 # If we got here, we didn't detect what setup.py command was given
Charles Harris9b3f6502020-12-20 23:35:37357 raise RuntimeError("Unrecognized setuptools command: {}".format(args))
Ralf Gommersb9f48092015-12-29 11:05:30358
359
Eric Wieserfb47ba62020-06-20 16:28:51360def get_docs_url():
Charles Harris40fd17e2020-12-02 20:06:51361 if 'dev' in VERSION:
Eric Wieserfb47ba62020-06-20 16:28:51362 return "https://numpy.org/devdocs"
363 else:
Qiyu8779d3062020-11-03 12:30:49364 # For releases, this URL ends up on pypi.
Eric Wieserfb47ba62020-06-20 16:28:51365 # By pinning the version, users looking at old PyPI releases can get
366 # to the associated docs easily.
367 return "https://numpy.org/doc/{}.{}".format(MAJOR, MINOR)
368
369
Ralf Gommers17716d72013-12-06 19:45:40370def setup_package():
mattip8b266552019-07-03 22:24:42371 src_path = os.path.dirname(os.path.abspath(__file__))
Pauli Virtanen68159432009-12-06 11:56:18372 old_path = os.getcwd()
373 os.chdir(src_path)
374 sys.path.insert(0, src_path)
375
Charles Harrisf22a33b2018-08-22 17:57:48376 # The f2py scripts that will be installed
377 if sys.platform == 'win32':
378 f2py_cmds = [
379 'f2py = numpy.f2py.f2py2e:main',
380 ]
381 else:
382 f2py_cmds = [
383 'f2py = numpy.f2py.f2py2e:main',
384 'f2py%s = numpy.f2py.f2py2e:main' % sys.version_info[:1],
385 'f2py%s.%s = numpy.f2py.f2py2e:main' % sys.version_info[:2],
386 ]
387
Charles Harris40fd17e2020-12-02 20:06:51388 cmdclass["sdist"] = sdist_checked
Ralf Gommers17716d72013-12-06 19:45:40389 metadata = dict(
Hugo van Kemenade2ebb4532020-10-04 09:41:47390 name='numpy',
391 maintainer="NumPy Developers",
392 maintainer_email="numpy-discussion@python.org",
393 description=DOCLINES[0],
394 long_description="\n".join(DOCLINES[2:]),
395 url="https://www.numpy.org",
396 author="Travis E. Oliphant et al.",
397 download_url="https://pypi.python.org/pypi/numpy",
Jarrod Millman0486b6d2019-04-12 01:11:21398 project_urls={
399 "Bug Tracker": "https://github.com/numpy/numpy/issues",
Eric Wieserfb47ba62020-06-20 16:28:51400 "Documentation": get_docs_url(),
Jarrod Millman0486b6d2019-04-12 01:11:21401 "Source Code": "https://github.com/numpy/numpy",
402 },
Hugo van Kemenade2ebb4532020-10-04 09:41:47403 license='BSD',
Ralf Gommers17716d72013-12-06 19:45:40404 classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
Hugo van Kemenade2ebb4532020-10-04 09:41:47405 platforms=["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
Charles Harrisb3b6cc02020-05-18 22:26:10406 test_suite='pytest',
Charles Harris40fd17e2020-12-02 20:06:51407 version=versioneer.get_version(),
mattip18af8e02020-01-04 20:47:47408 cmdclass=cmdclass,
Ralf Gommers1e8d6a82021-07-18 20:32:38409 python_requires='>=3.7,<3.11',
Nathaniel J. Smithf46e7162018-01-23 08:02:04410 zip_safe=False,
Charles Harrisf22a33b2018-08-22 17:57:48411 entry_points={
412 'console_scripts': f2py_cmds
413 },
Ralf Gommers17716d72013-12-06 19:45:40414 )
415
Ralf Gommers99e99e92015-12-29 14:24:22416 if "--force" in sys.argv:
417 run_build = True
Ralf Gommers20c3c2a2017-06-20 10:09:40418 sys.argv.remove('--force')
Ralf Gommers99e99e92015-12-29 14:24:22419 else:
420 # Raise errors for unsupported commands, improve help output, etc.
421 run_build = parse_setuppy_commands()
Ralf Gommersb9f48092015-12-29 11:05:30422
Charles Harris9b3f6502020-12-20 23:35:37423 if run_build:
Mike Taves07bf33f2020-02-04 19:21:51424 # patches distutils, even though we don't use it
Charles Harris40fd17e2020-12-02 20:06:51425 #from setuptools import setup
Ralf Gommers17716d72013-12-06 19:45:40426 from numpy.distutils.core import setup
Charles Harris40fd17e2020-12-02 20:06:51427
Hugo van Kemenade2ebb4532020-10-04 09:41:47428 if 'sdist' not in sys.argv:
Ralf Gommersd630d962019-09-08 05:01:41429 # Generate Cython sources, unless we're generating an sdist
Julian Taylorc9fd6342014-04-05 11:13:13430 generate_cython()
Ralf Gommers4b0ed792015-12-29 10:29:38431
Ralf Gommers17716d72013-12-06 19:45:40432 metadata['configuration'] = configuration
mattip18af8e02020-01-04 20:47:47433 # Customize extension building
434 cmdclass['build_clib'], cmdclass['build_ext'] = get_build_overrides()
Ralf Gommers99e99e92015-12-29 14:24:22435 else:
Charles Harris40fd17e2020-12-02 20:06:51436 #from numpy.distutils.core import setup
Mike Taves07bf33f2020-02-04 19:21:51437 from setuptools import setup
Pauli Virtanen68159432009-12-06 11:56:18438
Pearu Petersone8fa0132003-03-07 18:08:28439 try:
Ralf Gommers17716d72013-12-06 19:45:40440 setup(**metadata)
Pearu Petersone8fa0132003-03-07 18:08:28441 finally:
442 del sys.path[0]
443 os.chdir(old_path)
Travis Oliphant14db4192005-09-14 22:08:46444 return
Pearu Petersonc415fd12002-11-18 22:39:31445
Ralf Gommers17716d72013-12-06 19:45:40446
Travis Oliphant14db4192005-09-14 22:08:46447if __name__ == '__main__':
Pearu Petersone8fa0132003-03-07 18:08:28448 setup_package()
Ralf Gommersbbee7472016-08-21 05:23:35449 # This may avoid problems where numpy is installed via ``*_requires`` by
450 # setuptools, the global namespace isn't reset properly, and then numpy is
451 # imported later (which will then fail to load numpy extension modules).
452 # See gh-7956 for details
453 del builtins.__NUMPY_SETUP__