blob: 82661046637f36436a37ae19b7e91969fff0e464 [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
Jon Dufresne334201d2019-08-27 04:18:3596Programming Language :: Python :: 3 :: Only
Alex Willmer193668a2015-08-05 09:29:3997Programming Language :: Python :: Implementation :: CPython
Travis Oliphantda9c6da2006-01-04 17:31:0798Topic :: Software Development
99Topic :: Scientific/Engineering
Bas van Beeke592c272020-10-04 13:10:42100Typing :: Typed
Travis Oliphantda9c6da2006-01-04 17:31:07101Operating System :: Microsoft :: Windows
102Operating System :: POSIX
103Operating System :: Unix
104Operating System :: MacOS
105"""
106
Ralf Gommers17716d72013-12-06 19:45:40107
Hugo van Kemenade2ebb4532020-10-04 09:41:47108def configuration(parent_package='', top_path=None):
Pearu Peterson471196b2006-03-31 08:59:36109 from numpy.distutils.misc_util import Configuration
110
Pearu Peterson17d7cfe2006-04-04 12:26:14111 config = Configuration(None, parent_package, top_path)
Pearu Peterson471196b2006-03-31 08:59:36112 config.set_options(ignore_setup_xxx_py=True,
113 assume_default_configuration=True,
114 delegate_options_to_subpackages=True,
115 quiet=True)
Jarrod Millman0b77f0e2007-10-29 14:58:18116
Pearu Peterson471196b2006-03-31 08:59:36117 config.add_subpackage('numpy')
Charles Harris054d93a2017-11-29 18:53:21118 config.add_data_files(('numpy', 'LICENSE.txt'))
scodere1211b82020-08-05 04:28:30119 config.add_data_files(('numpy', 'numpy/*.pxd'))
Jarrod Millman0b77f0e2007-10-29 14:58:18120
Hugo van Kemenade2ebb4532020-10-04 09:41:47121 config.get_version('numpy/version.py') # sets config.version
Travis Oliphant00a35872007-05-31 04:57:01122
Pearu Peterson471196b2006-03-31 08:59:36123 return config
124
Ralf Gommers4b0ed792015-12-29 10:29:38125
Julian Taylor4cd72742014-01-29 21:59:19126def check_submodules():
127 """ verify that the submodules are checked out and clean
128 use `git submodule update --init`; on failure
129 """
130 if not os.path.exists('.git'):
131 return
132 with open('.gitmodules') as f:
Hugo van Kemenade2ebb4532020-10-04 09:41:47133 for line in f:
134 if 'path' in line:
135 p = line.split('=')[-1].strip()
Julian Taylor4cd72742014-01-29 21:59:19136 if not os.path.exists(p):
Wojciech Rzadkowskidabf31c2020-05-22 15:43:08137 raise ValueError('Submodule {} missing'.format(p))
Julian Taylor4cd72742014-01-29 21:59:19138
Julian Taylor4cd72742014-01-29 21:59:19139 proc = subprocess.Popen(['git', 'submodule', 'status'],
140 stdout=subprocess.PIPE)
141 status, _ = proc.communicate()
142 status = status.decode("ascii", "replace")
143 for line in status.splitlines():
144 if line.startswith('-') or line.startswith('+'):
Wojciech Rzadkowskidabf31c2020-05-22 15:43:08145 raise ValueError('Submodule not clean: {}'.format(line))
Julian Taylor4cd72742014-01-29 21:59:19146
Ralf Gommers4b0ed792015-12-29 10:29:38147
Ralf Gommersa08fb602019-05-03 14:44:23148class concat_license_files():
Ralf Gommers33415902019-05-07 09:00:50149 """Merge LICENSE.txt and LICENSES_bundled.txt for sdist creation
Ralf Gommersa08fb602019-05-03 14:44:23150
151 Done this way to keep LICENSE.txt in repo as exact BSD 3-clause (see
152 gh-13447). This makes GitHub state correctly how NumPy is licensed.
153 """
154 def __init__(self):
155 self.f1 = 'LICENSE.txt'
Ralf Gommers33415902019-05-07 09:00:50156 self.f2 = 'LICENSES_bundled.txt'
Ralf Gommersa08fb602019-05-03 14:44:23157
158 def __enter__(self):
Ralf Gommers33415902019-05-07 09:00:50159 """Concatenate files and remove LICENSES_bundled.txt"""
Ralf Gommersa08fb602019-05-03 14:44:23160 with open(self.f1, 'r') as f1:
161 self.bsd_text = f1.read()
162
163 with open(self.f1, 'a') as f1:
164 with open(self.f2, 'r') as f2:
165 self.bundled_text = f2.read()
166 f1.write('\n\n')
167 f1.write(self.bundled_text)
168
Ralf Gommersa08fb602019-05-03 14:44:23169 def __exit__(self, exception_type, exception_value, traceback):
170 """Restore content of both files"""
171 with open(self.f1, 'w') as f:
172 f.write(self.bsd_text)
173
Ralf Gommersa08fb602019-05-03 14:44:23174
Charles Harrisfed25092020-12-10 18:58:47175# Need to inherit from versioneer version of sdist to get the encoded
176# version information.
177class sdist_checked(cmdclass['sdist']):
Julian Taylor4cd72742014-01-29 21:59:19178 """ check submodules on sdist to prevent incomplete tarballs """
179 def run(self):
180 check_submodules()
Ralf Gommersa08fb602019-05-03 14:44:23181 with concat_license_files():
Charles Harrisfed25092020-12-10 18:58:47182 super().run()
Travis Oliphant14db4192005-09-14 22:08:46183
Ralf Gommers4b0ed792015-12-29 10:29:38184
mattip18af8e02020-01-04 20:47:47185def get_build_overrides():
186 """
mattipc2f93002020-01-05 15:00:30187 Custom build commands to add `-std=c99` to compilation
mattip18af8e02020-01-04 20:47:47188 """
189 from numpy.distutils.command.build_clib import build_clib
190 from numpy.distutils.command.build_ext import build_ext
mattip57fb47c2020-07-28 03:39:16191 from distutils.version import LooseVersion
mattip18af8e02020-01-04 20:47:47192
mattip10dcfb02020-07-28 08:56:35193 def _needs_gcc_c99_flag(obj):
194 if obj.compiler.compiler_type != 'unix':
195 return False
196
197 cc = obj.compiler.compiler[0]
198 if "gcc" not in cc:
199 return False
200
201 # will print something like '4.2.1\n'
202 out = subprocess.run([cc, '-dumpversion'], stdout=subprocess.PIPE,
203 stderr=subprocess.PIPE, universal_newlines=True)
204 # -std=c99 is default from this version on
205 if LooseVersion(out.stdout) >= LooseVersion('5.0'):
206 return False
207 return True
mattip18af8e02020-01-04 20:47:47208
209 class new_build_clib(build_clib):
210 def build_a_library(self, build_info, lib_name, libraries):
mattip10dcfb02020-07-28 08:56:35211 if _needs_gcc_c99_flag(self):
mattip18af8e02020-01-04 20:47:47212 args = build_info.get('extra_compiler_args') or []
mattipc2f93002020-01-05 15:00:30213 args.append('-std=c99')
mattip18af8e02020-01-04 20:47:47214 build_info['extra_compiler_args'] = args
215 build_clib.build_a_library(self, build_info, lib_name, libraries)
216
217 class new_build_ext(build_ext):
218 def build_extension(self, ext):
mattip10dcfb02020-07-28 08:56:35219 if _needs_gcc_c99_flag(self):
mattipc2f93002020-01-05 15:00:30220 if '-std=c99' not in ext.extra_compile_args:
221 ext.extra_compile_args.append('-std=c99')
mattip18af8e02020-01-04 20:47:47222 build_ext.build_extension(self, ext)
223 return new_build_clib, new_build_ext
224
225
Julian Taylorc9fd6342014-04-05 11:13:13226def generate_cython():
227 cwd = os.path.abspath(os.path.dirname(__file__))
228 print("Cythonizing sources")
mattip4e6a8122019-05-23 04:54:47229 for d in ('random',):
mattipfa8af412019-03-20 10:39:53230 p = subprocess.call([sys.executable,
Hugo van Kemenade2ebb4532020-10-04 09:41:47231 os.path.join(cwd, 'tools', 'cythonize.py'),
232 'numpy/{0}'.format(d)],
233 cwd=cwd)
mattipfa8af412019-03-20 10:39:53234 if p != 0:
235 raise RuntimeError("Running cythonize failed!")
Julian Taylorc9fd6342014-04-05 11:13:13236
Ralf Gommers4b0ed792015-12-29 10:29:38237
Ralf Gommersb9f48092015-12-29 11:05:30238def parse_setuppy_commands():
Ralf Gommers99e99e92015-12-29 14:24:22239 """Check the commands and respond appropriately. Disable broken commands.
240
241 Return a boolean value for whether or not to run the build or not (avoid
242 parsing Cython and template files if False).
243 """
Eric Wieserb8b2a0e2018-03-12 08:29:52244 args = sys.argv[1:]
245
246 if not args:
Ralf Gommersb9f48092015-12-29 11:05:30247 # User forgot to give an argument probably, let setuptools handle that.
Ralf Gommers99e99e92015-12-29 14:24:22248 return True
Ralf Gommersb9f48092015-12-29 11:05:30249
Ralf Gommers99e99e92015-12-29 14:24:22250 info_commands = ['--help-commands', '--name', '--version', '-V',
251 '--fullname', '--author', '--author-email',
252 '--maintainer', '--maintainer-email', '--contact',
253 '--contact-email', '--url', '--license', '--description',
254 '--long-description', '--platforms', '--classifiers',
Charles Harris9b3f6502020-12-20 23:35:37255 '--keywords', '--provides', '--requires', '--obsoletes',
256 'version',]
Ralf Gommers99e99e92015-12-29 14:24:22257
258 for command in info_commands:
Eric Wieserb8b2a0e2018-03-12 08:29:52259 if command in args:
Ralf Gommers99e99e92015-12-29 14:24:22260 return False
261
262 # Note that 'alias', 'saveopts' and 'setopt' commands also seem to work
263 # fine as they are, but are usually used together with one of the commands
264 # below and not standalone. Hence they're not added to good_commands.
265 good_commands = ('develop', 'sdist', 'build', 'build_ext', 'build_py',
Ralf Gommersab5c6d02016-01-16 14:21:23266 'build_clib', 'build_scripts', 'bdist_wheel', 'bdist_rpm',
Ralf Gommers491d26b2021-01-27 21:48:58267 'bdist_wininst', 'bdist_msi', 'bdist_mpkg', 'build_src',
268 'bdist_egg')
Ralf Gommers99e99e92015-12-29 14:24:22269
Ralf Gommersb9f48092015-12-29 11:05:30270 for command in good_commands:
Eric Wieserb8b2a0e2018-03-12 08:29:52271 if command in args:
Ralf Gommers99e99e92015-12-29 14:24:22272 return True
Ralf Gommersb9f48092015-12-29 11:05:30273
Ralf Gommersab5c6d02016-01-16 14:21:23274 # The following commands are supported, but we need to show more
Ralf Gommers99e99e92015-12-29 14:24:22275 # useful messages to the user
Eric Wieserb8b2a0e2018-03-12 08:29:52276 if 'install' in args:
Ralf Gommers99e99e92015-12-29 14:24:22277 print(textwrap.dedent("""
278 Note: if you need reliable uninstall behavior, then install
279 with pip instead of using `setup.py install`:
280
281 - `pip install .` (from a git repo or downloaded source
282 release)
Pierre de Buyl3f6672a2016-09-06 12:54:08283 - `pip install numpy` (last NumPy release on PyPi)
Ralf Gommers99e99e92015-12-29 14:24:22284
285 """))
286 return True
287
Eric Wieserb8b2a0e2018-03-12 08:29:52288 if '--help' in args or '-h' in sys.argv[1]:
Ralf Gommers99e99e92015-12-29 14:24:22289 print(textwrap.dedent("""
Pierre de Buyl3f6672a2016-09-06 12:54:08290 NumPy-specific help
Ralf Gommers99e99e92015-12-29 14:24:22291 -------------------
292
Pierre de Buyl3f6672a2016-09-06 12:54:08293 To install NumPy from here with reliable uninstall, we recommend
294 that you use `pip install .`. To install the latest NumPy release
Ralf Gommers99e99e92015-12-29 14:24:22295 from PyPi, use `pip install numpy`.
296
297 For help with build/installation issues, please ask on the
298 numpy-discussion mailing list. If you are sure that you have run
299 into a bug, please report it at https://github.com/numpy/numpy/issues.
300
301 Setuptools commands help
302 ------------------------
303 """))
304 return False
305
Ralf Gommers99e99e92015-12-29 14:24:22306 # The following commands aren't supported. They can only be executed when
307 # the user explicitly adds a --force command-line argument.
Ralf Gommersb9f48092015-12-29 11:05:30308 bad_commands = dict(
309 test="""
310 `setup.py test` is not supported. Use one of the following
311 instead:
312
313 - `python runtests.py` (to build and test)
314 - `python runtests.py --no-build` (to test installed numpy)
315 - `>>> numpy.test()` (run tests for installed numpy
316 from within an interpreter)
317 """,
318 upload="""
319 `setup.py upload` is not supported, because it's insecure.
320 Instead, build what you want to upload and upload those files
321 with `twine upload -s <filenames>` instead.
322 """,
Ralf Gommersb9f48092015-12-29 11:05:30323 clean="""
324 `setup.py clean` is not supported, use one of the following instead:
325
326 - `git clean -xdf` (cleans all files)
327 - `git clean -Xdf` (cleans all versioned files, doesn't touch
328 files that aren't checked into the git repo)
329 """,
Ralf Gommers99e99e92015-12-29 14:24:22330 build_sphinx="""
331 `setup.py build_sphinx` is not supported, use the
332 Makefile under doc/""",
333 flake8="`setup.py flake8` is not supported, use flake8 standalone",
Ralf Gommersb9f48092015-12-29 11:05:30334 )
Ralf Gommers99e99e92015-12-29 14:24:22335 bad_commands['nosetests'] = bad_commands['test']
Luca Mussi69d2cc82016-04-07 11:24:49336 for command in ('upload_docs', 'easy_install', 'bdist', 'bdist_dumb',
Hugo van Kemenade2ebb4532020-10-04 09:41:47337 'register', 'check', 'install_data', 'install_headers',
338 'install_lib', 'install_scripts', ):
Ralf Gommers99e99e92015-12-29 14:24:22339 bad_commands[command] = "`setup.py %s` is not supported" % command
340
Ralf Gommersb9f48092015-12-29 11:05:30341 for command in bad_commands.keys():
Eric Wieserb8b2a0e2018-03-12 08:29:52342 if command in args:
Ralf Gommersb9f48092015-12-29 11:05:30343 print(textwrap.dedent(bad_commands[command]) +
344 "\nAdd `--force` to your command to use it anyway if you "
345 "must (unsupported).\n")
346 sys.exit(1)
347
Eric Wieserb8b2a0e2018-03-12 08:29:52348 # Commands that do more than print info, but also don't need Cython and
349 # template parsing.
Charles Harris9b3f6502020-12-20 23:35:37350 other_commands = ['egg_info', 'install_egg_info', 'rotate', 'dist_info']
Eric Wieserb8b2a0e2018-03-12 08:29:52351 for command in other_commands:
352 if command in args:
353 return False
354
Ralf Gommers99e99e92015-12-29 14:24:22355 # If we got here, we didn't detect what setup.py command was given
Charles Harris9b3f6502020-12-20 23:35:37356 raise RuntimeError("Unrecognized setuptools command: {}".format(args))
Ralf Gommersb9f48092015-12-29 11:05:30357
358
Eric Wieserfb47ba62020-06-20 16:28:51359def get_docs_url():
Charles Harris40fd17e2020-12-02 20:06:51360 if 'dev' in VERSION:
Eric Wieserfb47ba62020-06-20 16:28:51361 return "https://numpy.org/devdocs"
362 else:
Qiyu8779d3062020-11-03 12:30:49363 # For releases, this URL ends up on pypi.
Eric Wieserfb47ba62020-06-20 16:28:51364 # By pinning the version, users looking at old PyPI releases can get
365 # to the associated docs easily.
366 return "https://numpy.org/doc/{}.{}".format(MAJOR, MINOR)
367
368
Ralf Gommers17716d72013-12-06 19:45:40369def setup_package():
mattip8b266552019-07-03 22:24:42370 src_path = os.path.dirname(os.path.abspath(__file__))
Pauli Virtanen68159432009-12-06 11:56:18371 old_path = os.getcwd()
372 os.chdir(src_path)
373 sys.path.insert(0, src_path)
374
Charles Harrisf22a33b2018-08-22 17:57:48375 # The f2py scripts that will be installed
376 if sys.platform == 'win32':
377 f2py_cmds = [
378 'f2py = numpy.f2py.f2py2e:main',
379 ]
380 else:
381 f2py_cmds = [
382 'f2py = numpy.f2py.f2py2e:main',
383 'f2py%s = numpy.f2py.f2py2e:main' % sys.version_info[:1],
384 'f2py%s.%s = numpy.f2py.f2py2e:main' % sys.version_info[:2],
385 ]
386
Charles Harris40fd17e2020-12-02 20:06:51387 cmdclass["sdist"] = sdist_checked
Ralf Gommers17716d72013-12-06 19:45:40388 metadata = dict(
Hugo van Kemenade2ebb4532020-10-04 09:41:47389 name='numpy',
390 maintainer="NumPy Developers",
391 maintainer_email="numpy-discussion@python.org",
392 description=DOCLINES[0],
393 long_description="\n".join(DOCLINES[2:]),
394 url="https://www.numpy.org",
395 author="Travis E. Oliphant et al.",
396 download_url="https://pypi.python.org/pypi/numpy",
Jarrod Millman0486b6d2019-04-12 01:11:21397 project_urls={
398 "Bug Tracker": "https://github.com/numpy/numpy/issues",
Eric Wieserfb47ba62020-06-20 16:28:51399 "Documentation": get_docs_url(),
Jarrod Millman0486b6d2019-04-12 01:11:21400 "Source Code": "https://github.com/numpy/numpy",
401 },
Hugo van Kemenade2ebb4532020-10-04 09:41:47402 license='BSD',
Ralf Gommers17716d72013-12-06 19:45:40403 classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
Hugo van Kemenade2ebb4532020-10-04 09:41:47404 platforms=["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
Charles Harrisb3b6cc02020-05-18 22:26:10405 test_suite='pytest',
Charles Harris40fd17e2020-12-02 20:06:51406 version=versioneer.get_version(),
mattip18af8e02020-01-04 20:47:47407 cmdclass=cmdclass,
Charles Harris88be44b2020-12-02 20:35:57408 python_requires='>=3.7',
Nathaniel J. Smithf46e7162018-01-23 08:02:04409 zip_safe=False,
Charles Harrisf22a33b2018-08-22 17:57:48410 entry_points={
411 'console_scripts': f2py_cmds
412 },
Ralf Gommers17716d72013-12-06 19:45:40413 )
414
Ralf Gommers99e99e92015-12-29 14:24:22415 if "--force" in sys.argv:
416 run_build = True
Ralf Gommers20c3c2a2017-06-20 10:09:40417 sys.argv.remove('--force')
Ralf Gommers99e99e92015-12-29 14:24:22418 else:
419 # Raise errors for unsupported commands, improve help output, etc.
420 run_build = parse_setuppy_commands()
Ralf Gommersb9f48092015-12-29 11:05:30421
Charles Harris9b3f6502020-12-20 23:35:37422 if run_build:
Mike Taves07bf33f2020-02-04 19:21:51423 # patches distutils, even though we don't use it
Charles Harris40fd17e2020-12-02 20:06:51424 #from setuptools import setup
Ralf Gommers17716d72013-12-06 19:45:40425 from numpy.distutils.core import setup
Charles Harris40fd17e2020-12-02 20:06:51426
Hugo van Kemenade2ebb4532020-10-04 09:41:47427 if 'sdist' not in sys.argv:
Ralf Gommersd630d962019-09-08 05:01:41428 # Generate Cython sources, unless we're generating an sdist
Julian Taylorc9fd6342014-04-05 11:13:13429 generate_cython()
Ralf Gommers4b0ed792015-12-29 10:29:38430
Ralf Gommers17716d72013-12-06 19:45:40431 metadata['configuration'] = configuration
mattip18af8e02020-01-04 20:47:47432 # Customize extension building
433 cmdclass['build_clib'], cmdclass['build_ext'] = get_build_overrides()
Ralf Gommers99e99e92015-12-29 14:24:22434 else:
Charles Harris40fd17e2020-12-02 20:06:51435 #from numpy.distutils.core import setup
Mike Taves07bf33f2020-02-04 19:21:51436 from setuptools import setup
Pauli Virtanen68159432009-12-06 11:56:18437
Pearu Petersone8fa0132003-03-07 18:08:28438 try:
Ralf Gommers17716d72013-12-06 19:45:40439 setup(**metadata)
Pearu Petersone8fa0132003-03-07 18:08:28440 finally:
441 del sys.path[0]
442 os.chdir(old_path)
Travis Oliphant14db4192005-09-14 22:08:46443 return
Pearu Petersonc415fd12002-11-18 22:39:31444
Ralf Gommers17716d72013-12-06 19:45:40445
Travis Oliphant14db4192005-09-14 22:08:46446if __name__ == '__main__':
Pearu Petersone8fa0132003-03-07 18:08:28447 setup_package()
Ralf Gommersbbee7472016-08-21 05:23:35448 # This may avoid problems where numpy is installed via ``*_requires`` by
449 # setuptools, the global namespace isn't reset properly, and then numpy is
450 # imported later (which will then fail to load numpy extension modules).
451 # See gh-7956 for details
452 del builtins.__NUMPY_SETUP__