Show More
setup.py
279 lines
| 8.8 KiB
| text/x-python
|
PythonLexer
|
r24250 | #!/usr/bin/env python3 | ||
|
r5829 | # -*- coding: utf-8 -*- | ||
"""Setup script for IPython. | ||||
Under Posix environments it works like a typical setup.py script. | ||||
Under Windows, the command sdist is not supported, since IPython | ||||
requires utilities which are not available under Windows.""" | ||||
#----------------------------------------------------------------------------- | ||||
# Copyright (c) 2008-2011, IPython Development Team. | ||||
# Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> | ||||
# Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> | ||||
# Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> | ||||
# | ||||
# Distributed under the terms of the Modified BSD License. | ||||
# | ||||
|
r15990 | # The full license is in the file COPYING.rst, distributed with this software. | ||
|
r5829 | #----------------------------------------------------------------------------- | ||
|
r23546 | import os | ||
|
r2493 | import sys | ||
|
r26168 | from pathlib import Path | ||
|
r2493 | |||
|
r23544 | # **Python version check** | ||
# | ||||
|
r5829 | # This check is also made in IPython/__init__, don't forget to update both when | ||
# changing Python version requirements. | ||||
|
r25874 | if sys.version_info < (3, 7): | ||
|
r23544 | pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1.' | ||
|
r23539 | try: | ||
import pip | ||||
pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]]) | ||||
if pip_version < (9, 0, 1) : | ||||
|
r23544 | pip_message = 'Your pip version is out of date, please install pip >= 9.0.1. '\ | ||
|
r23539 | 'pip {} detected.'.format(pip.__version__) | ||
|
r23548 | else: | ||
# pip is new enough - it must be something else | ||||
pip_message = '' | ||||
|
r23539 | except Exception: | ||
pass | ||||
|
r24033 | |||
|
r22823 | error = """ | ||
|
r25874 | IPython 7.17+ supports Python 3.7 and above, following NEP 29. | ||
|
r22823 | When using Python 2.7, please install IPython 5.x LTS Long Term Support version. | ||
|
r24471 | Python 3.3 and 3.4 were supported up to IPython 6.x. | ||
|
r25225 | Python 3.5 was supported with IPython 7.0 to 7.9. | ||
|
r25874 | Python 3.6 was supported with IPython up to 7.16. | ||
|
r22823 | |||
See IPython `README.rst` file for more information: | ||||
https://github.com/ipython/ipython/blob/master/README.rst | ||||
|
r23539 | Python {py} detected. | ||
{pip} | ||||
""".format(py=sys.version_info, pip=pip_message ) | ||||
|
r22823 | |||
|
r12473 | print(error, file=sys.stderr) | ||
sys.exit(1) | ||||
|
r5829 | |||
# At least we're on the python version we need, move on. | ||||
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly | ||||
# update it when the contents of directories change. | ||||
|
r26168 | if Path("MANIFEST").exists(): | ||
Path("MANIFEST").unlink() | ||||
|
r5829 | |||
from distutils.core import setup | ||||
# Our own imports | ||||
from setupbase import target_update | ||||
from setupbase import ( | ||||
setup_args, | ||||
find_packages, | ||||
find_package_data, | ||||
|
r15165 | check_package_data_first, | ||
|
r13452 | find_entry_points, | ||
build_scripts_entrypt, | ||||
|
r5829 | find_data_files, | ||
|
r10484 | git_prebuild, | ||
|
r13452 | install_symlinked, | ||
install_lib_symlink, | ||||
install_scripts_for_symlink, | ||||
|
r13862 | unsymlink, | ||
|
r5829 | ) | ||
#------------------------------------------------------------------------------- | ||||
# Handle OS specific things | ||||
#------------------------------------------------------------------------------- | ||||
|
r10087 | if os.name in ('nt','dos'): | ||
|
r5829 | os_name = 'windows' | ||
|
r1033 | else: | ||
|
r10087 | os_name = os.name | ||
|
r5829 | |||
# Under Windows, 'sdist' has not been supported. Now that the docs build with | ||||
# Sphinx it might work, but let's not turn it on until someone confirms that it | ||||
# actually works. | ||||
if os_name == 'windows' and 'sdist' in sys.argv: | ||||
print('The sdist command is not available under Windows. Exiting.') | ||||
sys.exit(1) | ||||
|
r10484 | |||
#------------------------------------------------------------------------------- | ||||
|
r5829 | # Things related to the IPython documentation | ||
#------------------------------------------------------------------------------- | ||||
# update the manuals when building a source dist | ||||
if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): | ||||
# List of things to be updated. Each entry is a triplet of args for | ||||
# target_update() | ||||
to_update = [ | ||||
('docs/man/ipython.1.gz', | ||||
['docs/man/ipython.1'], | ||||
'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), | ||||
] | ||||
[ target_update(*t) for t in to_update ] | ||||
#--------------------------------------------------------------------------- | ||||
# Find all the packages, package data, and data_files | ||||
#--------------------------------------------------------------------------- | ||||
packages = find_packages() | ||||
package_data = find_package_data() | ||||
|
r15114 | |||
|
r5829 | data_files = find_data_files() | ||
setup_args['packages'] = packages | ||||
setup_args['package_data'] = package_data | ||||
setup_args['data_files'] = data_files | ||||
#--------------------------------------------------------------------------- | ||||
|
r7794 | # custom distutils commands | ||
|
r7792 | #--------------------------------------------------------------------------- | ||
|
r7794 | # imports here, so they are after setuptools import if there was one | ||
from distutils.command.sdist import sdist | ||||
|
r7792 | |||
|
r7794 | setup_args['cmdclass'] = { | ||
|
r21249 | 'build_py': \ | ||
check_package_data_first(git_prebuild('IPython')), | ||||
'sdist' : git_prebuild('IPython', sdist), | ||||
|
r13452 | 'symlink': install_symlinked, | ||
'install_lib_symlink': install_lib_symlink, | ||||
'install_scripts_sym': install_scripts_for_symlink, | ||||
|
r13862 | 'unsymlink': unsymlink, | ||
|
r7794 | } | ||
|
r7792 | |||
|
r21036 | |||
|
r7792 | #--------------------------------------------------------------------------- | ||
|
r5829 | # Handle scripts, dependencies, and setuptools specific things | ||
#--------------------------------------------------------------------------- | ||||
# For some commands, use setuptools. Note that we do NOT list install here! | ||||
# If you want a setuptools-enhanced install, just run 'setupegg.py install' | ||||
|
r23546 | needs_setuptools = {'develop', 'release', 'bdist_egg', 'bdist_rpm', | ||
|
r15030 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel', | ||
'egg_info', 'easy_install', 'upload', 'install_egg_info', | ||||
|
r23546 | } | ||
|
r5829 | |||
if len(needs_setuptools.intersection(sys.argv)) > 0: | ||||
import setuptools | ||||
# This dict is used for passing extra arguments that are setuptools | ||||
# specific to setup | ||||
setuptools_extra_args = {} | ||||
|
r15030 | # setuptools requirements | ||
extras_require = dict( | ||||
|
r26354 | parallel=["ipyparallel"], | ||
qtconsole=["qtconsole"], | ||||
doc=["Sphinx>=1.3"], | ||||
test=[ | ||||
|
r26882 | "pytest", | ||
|
r26354 | "testpath", | ||
"pygments", | ||||
|
r27104 | ], | ||
test_extra=[ | ||||
"pytest", | ||||
"testpath", | ||||
"curio", | ||||
"matplotlib!=3.2.0", | ||||
|
r26354 | "nbformat", | ||
|
r26511 | "numpy>=1.17", | ||
|
r27104 | "pandas", | ||
"pygments", | ||||
"trio", | ||||
|
r26354 | ], | ||
terminal=[], | ||||
kernel=["ipykernel"], | ||||
nbformat=["nbformat"], | ||||
notebook=["notebook", "ipywidgets"], | ||||
nbconvert=["nbconvert"], | ||||
|
r15030 | ) | ||
|
r22379 | |||
|
r20811 | install_requires = [ | ||
|
r26464 | "setuptools>=18.5", | ||
"jedi>=0.16", | ||||
"decorator", | ||||
"pickleshare", | ||||
"traitlets>=4.2", | ||||
"prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1", | ||||
"pygments", | ||||
"backcall", | ||||
"stack_data", | ||||
"matplotlib-inline", | ||||
|
r20811 | ] | ||
|
r16386 | |||
|
r21372 | # Platform-specific dependencies: | ||
# This is the correct way to specify these, | ||||
# but requires pip >= 6. pip < 6 ignores these. | ||||
|
r21659 | |||
|
r25967 | extras_require.update( | ||
{ | ||||
':sys_platform != "win32"': ["pexpect>4.3"], | ||||
':sys_platform == "darwin"': ["appnope"], | ||||
':sys_platform == "win32"': ["colorama"], | ||||
} | ||||
) | ||||
|
r21372 | # FIXME: re-specify above platform dependencies for pip < 6 | ||
# These would result in non-portable bdists. | ||||
if not any(arg.startswith('bdist') for arg in sys.argv): | ||||
if sys.platform == 'darwin': | ||||
|
r21652 | install_requires.extend(['appnope']) | ||
|
r22628 | |||
|
r25967 | if not sys.platform.startswith("win"): | ||
install_requires.append("pexpect>4.3") | ||||
|
r22591 | |||
|
r21659 | # workaround pypa/setuptools#147, where setuptools misspells | ||
# platform_python_implementation as python_implementation | ||||
if 'setuptools' in sys.modules: | ||||
for key in list(extras_require): | ||||
if 'platform_python_implementation' in key: | ||||
new_key = key.replace('platform_python_implementation', 'python_implementation') | ||||
extras_require[new_key] = extras_require.pop(key) | ||||
|
r16244 | |||
|
r20256 | everything = set() | ||
|
r21644 | for key, deps in extras_require.items(): | ||
if ':' not in key: | ||||
everything.update(deps) | ||||
|
r25769 | extras_require['all'] = list(sorted(everything)) | ||
|
r15030 | |||
|
r5829 | if 'setuptools' in sys.modules: | ||
|
r25874 | setuptools_extra_args['python_requires'] = '>=3.7' | ||
|
r5829 | setuptools_extra_args['zip_safe'] = False | ||
|
r20117 | setuptools_extra_args['entry_points'] = { | ||
'console_scripts': find_entry_points(), | ||||
'pygments.lexers': [ | ||||
|
r20625 | 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer', | ||
'ipython = IPython.lib.lexers:IPythonLexer', | ||||
'ipython3 = IPython.lib.lexers:IPython3Lexer', | ||||
|
r20117 | ], | ||
} | ||||
|
r15030 | setup_args['extras_require'] = extras_require | ||
|
r23547 | setup_args['install_requires'] = install_requires | ||
|
r8814 | |||
|
r5829 | else: | ||
|
r13452 | # scripts has to be a non-empty list, or install_scripts isn't called | ||
setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()] | ||||
setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt | ||||
|
r5829 | |||
#--------------------------------------------------------------------------- | ||||
# Do the actual setup now | ||||
#--------------------------------------------------------------------------- | ||||
setup_args.update(setuptools_extra_args) | ||||
|
r21986 | |||
|
r5829 | def main(): | ||
setup(**setup_args) | ||||
|
r2460 | |||
|
r5829 | if __name__ == '__main__': | ||
main() | ||||