summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py192
1 files changed, 168 insertions, 24 deletions
diff --git a/setup.py b/setup.py
index 7eed56e5c..b6e144562 100755
--- a/setup.py
+++ b/setup.py
@@ -12,18 +12,26 @@ interfacing with general-purpose data-base applications.
There are also basic facilities for discrete fourier transform,
basic linear algebra and random number generation.
+All numpy wheels distributed from pypi are BSD licensed.
+
+Windows wheels are linked against the ATLAS BLAS / LAPACK library, restricted
+to SSE2 instructions, so may not give optimal linear algebra performance for
+your machine. See http://docs.scipy.org/doc/numpy/user/install.html for
+alternatives.
+
"""
from __future__ import division, print_function
-DOCLINES = __doc__.split("\n")
+DOCLINES = (__doc__ or '').split("\n")
import os
import sys
import subprocess
+import textwrap
-if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[0:2] < (3, 2):
- raise RuntimeError("Python version 2.6, 2.7 or >= 3.2 required.")
+if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[:2] < (3, 4):
+ raise RuntimeError("Python version 2.7 or >= 3.4 required.")
if sys.version_info[0] >= 3:
import builtins
@@ -38,7 +46,13 @@ Intended Audience :: Developers
License :: OSI Approved
Programming Language :: C
Programming Language :: Python
+Programming Language :: Python :: 2
+Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
+Programming Language :: Python :: 3.4
+Programming Language :: Python :: 3.5
+Programming Language :: Python :: 3.6
+Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development
Topic :: Scientific/Engineering
Operating System :: Microsoft :: Windows
@@ -48,7 +62,7 @@ Operating System :: MacOS
"""
MAJOR = 1
-MINOR = 10
+MINOR = 13
MICRO = 0
ISRELEASED = False
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
@@ -78,9 +92,11 @@ def git_version():
return GIT_REVISION
-# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
-# update it when the contents of directories change.
-if os.path.exists('MANIFEST'): os.remove('MANIFEST')
+# BEFORE importing setuptools, remove MANIFEST. Otherwise it may not be
+# properly updated when the contents of directories change (true for distutils,
+# not sure about setuptools).
+if os.path.exists('MANIFEST'):
+ os.remove('MANIFEST')
# This is a bit hackish: we are setting a global variable so that the main
# numpy __init__ can detect if it is being loaded by the setup routine, to
@@ -115,6 +131,8 @@ def get_version_info():
def write_version_py(filename='numpy/version.py'):
cnt = """
# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
+#
+# To compare versions robustly, use `numpy.lib.NumpyVersion`
short_version = '%(version)s'
version = '%(version)s'
full_version = '%(full_version)s'
@@ -151,6 +169,7 @@ def configuration(parent_package='',top_path=None):
return config
+
def check_submodules():
""" verify that the submodules are checked out and clean
use `git submodule update --init`; on failure
@@ -173,6 +192,7 @@ def check_submodules():
if line.startswith('-') or line.startswith('+'):
raise ValueError('Submodule not clean: %s' % line)
+
from distutils.command.sdist import sdist
class sdist_checked(sdist):
""" check submodules on sdist to prevent incomplete tarballs """
@@ -180,6 +200,7 @@ class sdist_checked(sdist):
check_submodules()
sdist.run(self)
+
def generate_cython():
cwd = os.path.abspath(os.path.dirname(__file__))
print("Cythonizing sources")
@@ -190,6 +211,129 @@ def generate_cython():
if p != 0:
raise RuntimeError("Running cythonize failed!")
+
+def parse_setuppy_commands():
+ """Check the commands and respond appropriately. Disable broken commands.
+
+ Return a boolean value for whether or not to run the build or not (avoid
+ parsing Cython and template files if False).
+ """
+ if len(sys.argv) < 2:
+ # User forgot to give an argument probably, let setuptools handle that.
+ return True
+
+ info_commands = ['--help-commands', '--name', '--version', '-V',
+ '--fullname', '--author', '--author-email',
+ '--maintainer', '--maintainer-email', '--contact',
+ '--contact-email', '--url', '--license', '--description',
+ '--long-description', '--platforms', '--classifiers',
+ '--keywords', '--provides', '--requires', '--obsoletes']
+ # Add commands that do more than print info, but also don't need Cython and
+ # template parsing.
+ info_commands.extend(['egg_info', 'install_egg_info', 'rotate'])
+
+ for command in info_commands:
+ if command in sys.argv[1:]:
+ return False
+
+ # Note that 'alias', 'saveopts' and 'setopt' commands also seem to work
+ # fine as they are, but are usually used together with one of the commands
+ # below and not standalone. Hence they're not added to good_commands.
+ good_commands = ('develop', 'sdist', 'build', 'build_ext', 'build_py',
+ 'build_clib', 'build_scripts', 'bdist_wheel', 'bdist_rpm',
+ 'bdist_wininst', 'bdist_msi', 'bdist_mpkg')
+
+ for command in good_commands:
+ if command in sys.argv[1:]:
+ return True
+
+ # The following commands are supported, but we need to show more
+ # useful messages to the user
+ if 'install' in sys.argv[1:]:
+ print(textwrap.dedent("""
+ Note: if you need reliable uninstall behavior, then install
+ with pip instead of using `setup.py install`:
+
+ - `pip install .` (from a git repo or downloaded source
+ release)
+ - `pip install numpy` (last NumPy release on PyPi)
+
+ """))
+ return True
+
+ if '--help' in sys.argv[1:] or '-h' in sys.argv[1]:
+ print(textwrap.dedent("""
+ NumPy-specific help
+ -------------------
+
+ To install NumPy from here with reliable uninstall, we recommend
+ that you use `pip install .`. To install the latest NumPy release
+ from PyPi, use `pip install numpy`.
+
+ For help with build/installation issues, please ask on the
+ numpy-discussion mailing list. If you are sure that you have run
+ into a bug, please report it at https://github.com/numpy/numpy/issues.
+
+ Setuptools commands help
+ ------------------------
+ """))
+ return False
+
+ # The following commands aren't supported. They can only be executed when
+ # the user explicitly adds a --force command-line argument.
+ bad_commands = dict(
+ test="""
+ `setup.py test` is not supported. Use one of the following
+ instead:
+
+ - `python runtests.py` (to build and test)
+ - `python runtests.py --no-build` (to test installed numpy)
+ - `>>> numpy.test()` (run tests for installed numpy
+ from within an interpreter)
+ """,
+ upload="""
+ `setup.py upload` is not supported, because it's insecure.
+ Instead, build what you want to upload and upload those files
+ with `twine upload -s <filenames>` instead.
+ """,
+ upload_docs="`setup.py upload_docs` is not supported",
+ easy_install="`setup.py easy_install` is not supported",
+ clean="""
+ `setup.py clean` is not supported, use one of the following instead:
+
+ - `git clean -xdf` (cleans all files)
+ - `git clean -Xdf` (cleans all versioned files, doesn't touch
+ files that aren't checked into the git repo)
+ """,
+ check="`setup.py check` is not supported",
+ register="`setup.py register` is not supported",
+ bdist_dumb="`setup.py bdist_dumb` is not supported",
+ bdist="`setup.py bdist` is not supported",
+ build_sphinx="""
+ `setup.py build_sphinx` is not supported, use the
+ Makefile under doc/""",
+ flake8="`setup.py flake8` is not supported, use flake8 standalone",
+ )
+ bad_commands['nosetests'] = bad_commands['test']
+ for command in ('upload_docs', 'easy_install', 'bdist', 'bdist_dumb',
+ 'register', 'check', 'install_data', 'install_headers',
+ 'install_lib', 'install_scripts', ):
+ bad_commands[command] = "`setup.py %s` is not supported" % command
+
+ for command in bad_commands.keys():
+ if command in sys.argv[1:]:
+ print(textwrap.dedent(bad_commands[command]) +
+ "\nAdd `--force` to your command to use it anyway if you "
+ "must (unsupported).\n")
+ sys.exit(1)
+
+ # If we got here, we didn't detect what setup.py command was given
+ import warnings
+ warnings.warn("Unrecognized setuptools command, proceeding with "
+ "generating Cython sources and expanding templates", stacklevel=2)
+ return True
+
+
def setup_package():
src_path = os.path.dirname(os.path.abspath(sys.argv[0]))
old_path = os.getcwd()
@@ -213,32 +357,27 @@ def setup_package():
platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
test_suite='nose.collector',
cmdclass={"sdist": sdist_checked},
- package_data={'numpy.core': ['libopenblaspy.dll']},
)
- # Run build
- if len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
- sys.argv[1] in ('--help-commands', 'egg_info', '--version',
- 'clean')):
- # Use setuptools for these commands (they don't work well or at all
- # with distutils). For normal builds use distutils.
- try:
- from setuptools import setup
- except ImportError:
- from distutils.core import setup
-
- FULLVERSION, GIT_REVISION = get_version_info()
- metadata['version'] = FULLVERSION
+ if "--force" in sys.argv:
+ run_build = True
else:
- if len(sys.argv) >= 2 and sys.argv[1] == 'bdist_wheel':
- # bdist_wheel needs setuptools
- import setuptools
+ # Raise errors for unsupported commands, improve help output, etc.
+ run_build = parse_setuppy_commands()
+
+ from setuptools import setup
+ if run_build:
from numpy.distutils.core import setup
cwd = os.path.abspath(os.path.dirname(__file__))
if not os.path.exists(os.path.join(cwd, 'PKG-INFO')):
# Generate Cython sources, unless building from source release
generate_cython()
+
metadata['configuration'] = configuration
+ else:
+ # Version number is added to metadata inside configuration() if build
+ # is run.
+ metadata['version'] = get_version_info()[0]
try:
setup(**metadata)
@@ -250,3 +389,8 @@ def setup_package():
if __name__ == '__main__':
setup_package()
+ # This may avoid problems where numpy is installed via ``*_requires`` by
+ # setuptools, the global namespace isn't reset properly, and then numpy is
+ # imported later (which will then fail to load numpy extension modules).
+ # See gh-7956 for details
+ del builtins.__NUMPY_SETUP__