setup.py
141 lines
| 4.6 KiB
| text/x-python
|
PythonLexer
Thomas Kluyver
|
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. | ||||
# | ||||
Jonathan Frederic
|
r15990 | # The full license is in the file COPYING.rst, distributed with this software. | ||
Thomas Kluyver
|
r5829 | #----------------------------------------------------------------------------- | ||
Thomas Kluyver
|
r23546 | import os | ||
Fernando Perez
|
r2493 | import sys | ||
Thomas Kluyver
|
r23544 | # **Python version check** | ||
# | ||||
Thomas Kluyver
|
r5829 | # This check is also made in IPython/__init__, don't forget to update both when | ||
# changing Python version requirements. | ||||
Matthias Bussonnier
|
r28529 | if sys.version_info < (3, 10): | ||
Thomas Kluyver
|
r23544 | pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1.' | ||
Matthias Bussonnier
|
r23539 | try: | ||
import pip | ||||
pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]]) | ||||
if pip_version < (9, 0, 1) : | ||||
Thomas Kluyver
|
r23544 | pip_message = 'Your pip version is out of date, please install pip >= 9.0.1. '\ | ||
Matthias Bussonnier
|
r23539 | 'pip {} detected.'.format(pip.__version__) | ||
Thomas Kluyver
|
r23548 | else: | ||
# pip is new enough - it must be something else | ||||
pip_message = '' | ||||
Matthias Bussonnier
|
r23539 | except Exception: | ||
pass | ||||
Rastislav Barlik
|
r24033 | |||
Matthias Bussonnier
|
r22823 | error = """ | ||
Matthias Bussonnier
|
r28529 | IPython 8.19+ supports Python 3.10 and above, following SPEC0 | ||
Ben Greiner
|
r28279 | IPython 8.13+ supports Python 3.9 and above, following NEP 29. | ||
Matthias Bussonnier
|
r28219 | IPython 8.0-8.12 supports Python 3.8 and above, following NEP 29. | ||
Matthias Bussonnier
|
r22823 | When using Python 2.7, please install IPython 5.x LTS Long Term Support version. | ||
Matthias Bussonnier
|
r24471 | Python 3.3 and 3.4 were supported up to IPython 6.x. | ||
Matthias Bussonnier
|
r25225 | Python 3.5 was supported with IPython 7.0 to 7.9. | ||
Matthias Bussonnier
|
r25874 | Python 3.6 was supported with IPython up to 7.16. | ||
Matthias Bussonnier
|
r27132 | Python 3.7 was still supported with the 7.x branch. | ||
Matthias Bussonnier
|
r22823 | |||
See IPython `README.rst` file for more information: | ||||
Jarrod Millman
|
r27712 | https://github.com/ipython/ipython/blob/main/README.rst | ||
Matthias Bussonnier
|
r22823 | |||
Matthias Bussonnier
|
r23539 | Python {py} detected. | ||
{pip} | ||||
Matthias Bussonnier
|
r27641 | """.format( | ||
py=sys.version_info, pip=pip_message | ||||
) | ||||
Matthias Bussonnier
|
r22823 | |||
MinRK
|
r12473 | print(error, file=sys.stderr) | ||
sys.exit(1) | ||||
Thomas Kluyver
|
r5829 | |||
# At least we're on the python version we need, move on. | ||||
James Morris
|
r27251 | from setuptools import setup | ||
Thomas Kluyver
|
r5829 | |||
# Our own imports | ||||
Michał Górny
|
r27682 | |||
Matthias Koeppe
|
r28648 | from setupbase import target_update | ||
Thomas Kluyver
|
r5829 | |||
from setupbase import ( | ||||
setup_args, | ||||
MinRK
|
r15165 | check_package_data_first, | ||
Thomas Kluyver
|
r5829 | find_data_files, | ||
MinRK
|
r10484 | git_prebuild, | ||
Thomas Kluyver
|
r5829 | ) | ||
#------------------------------------------------------------------------------- | ||||
# Handle OS specific things | ||||
#------------------------------------------------------------------------------- | ||||
MinRK
|
r10087 | if os.name in ('nt','dos'): | ||
Thomas Kluyver
|
r5829 | os_name = 'windows' | ||
Ville M. Vainio
|
r1033 | else: | ||
MinRK
|
r10087 | os_name = os.name | ||
Thomas Kluyver
|
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) | ||||
MinRK
|
r10484 | |||
#------------------------------------------------------------------------------- | ||||
Thomas Kluyver
|
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 = [ | ||||
Matthias Bussonnier
|
r27268 | ( | ||
"docs/man/ipython.1.gz", | ||||
["docs/man/ipython.1"], | ||||
"cd docs/man && python -m gzip --best ipython.1", | ||||
), | ||||
] | ||||
Thomas Kluyver
|
r5829 | |||
[ target_update(*t) for t in to_update ] | ||||
#--------------------------------------------------------------------------- | ||||
# Find all the packages, package data, and data_files | ||||
#--------------------------------------------------------------------------- | ||||
data_files = find_data_files() | ||||
setup_args['data_files'] = data_files | ||||
#--------------------------------------------------------------------------- | ||||
MinRK
|
r7794 | # custom distutils commands | ||
MinRK
|
r7792 | #--------------------------------------------------------------------------- | ||
MinRK
|
r7794 | # imports here, so they are after setuptools import if there was one | ||
James Morris
|
r27251 | from setuptools.command.sdist import sdist | ||
MinRK
|
r7792 | |||
MinRK
|
r7794 | setup_args['cmdclass'] = { | ||
Min RK
|
r21249 | 'build_py': \ | ||
check_package_data_first(git_prebuild('IPython')), | ||||
'sdist' : git_prebuild('IPython', sdist), | ||||
MinRK
|
r7794 | } | ||
Nicholas Bollweg
|
r27908 | |||
Thomas Kluyver
|
r5829 | #--------------------------------------------------------------------------- | ||
# Do the actual setup now | ||||
#--------------------------------------------------------------------------- | ||||
Matthias Bussonnier
|
r27267 | if __name__ == "__main__": | ||
setup(**setup_args) | ||||