forked from ipython/ipython
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·264 lines (210 loc) · 8.58 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/usr/bin/env python3
# -*- 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 <[email protected]>
# Copyright (c) 2001, Janko Hauser <[email protected]>
# Copyright (c) 2001, Nathaniel Gray <[email protected]>
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.rst, distributed with this software.
#-----------------------------------------------------------------------------
from __future__ import print_function
import os
import sys
# **Python version check**
#
# This check is also made in IPython/__init__, don't forget to update both when
# changing Python version requirements.
if sys.version_info < (3, 4):
pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1.'
try:
import pip
pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]])
if pip_version < (9, 0, 1) :
pip_message = 'Your pip version is out of date, please install pip >= 9.0.1. '\
'pip {} detected.'.format(pip.__version__)
else:
# pip is new enough - it must be something else
pip_message = ''
except Exception:
pass
error = """
IPython 7.0+ supports Python 3.4 and above.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
Python 3.3 was supported up to IPython 6.x.
See IPython `README.rst` file for more information:
https://github.com/ipython/ipython/blob/master/README.rst
Python {py} detected.
{pip}
""".format(py=sys.version_info, pip=pip_message )
print(error, file=sys.stderr)
sys.exit(1)
# 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.
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
from distutils.core import setup
# Our own imports
from setupbase import target_update
from setupbase import (
setup_args,
find_packages,
find_package_data,
check_package_data_first,
find_entry_points,
build_scripts_entrypt,
find_data_files,
git_prebuild,
install_symlinked,
install_lib_symlink,
install_scripts_for_symlink,
unsymlink,
)
isfile = os.path.isfile
pjoin = os.path.join
#-------------------------------------------------------------------------------
# Handle OS specific things
#-------------------------------------------------------------------------------
if os.name in ('nt','dos'):
os_name = 'windows'
else:
os_name = os.name
# 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)
#-------------------------------------------------------------------------------
# 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()
data_files = find_data_files()
setup_args['packages'] = packages
setup_args['package_data'] = package_data
setup_args['data_files'] = data_files
#---------------------------------------------------------------------------
# custom distutils commands
#---------------------------------------------------------------------------
# imports here, so they are after setuptools import if there was one
from distutils.command.sdist import sdist
setup_args['cmdclass'] = {
'build_py': \
check_package_data_first(git_prebuild('IPython')),
'sdist' : git_prebuild('IPython', sdist),
'symlink': install_symlinked,
'install_lib_symlink': install_lib_symlink,
'install_scripts_sym': install_scripts_for_symlink,
'unsymlink': unsymlink,
}
#---------------------------------------------------------------------------
# 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'
needs_setuptools = {'develop', 'release', 'bdist_egg', 'bdist_rpm',
'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
'egg_info', 'easy_install', 'upload', 'install_egg_info',
}
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 = {}
# setuptools requirements
extras_require = dict(
parallel = ['ipyparallel'],
qtconsole = ['qtconsole'],
doc = ['Sphinx>=1.3'],
test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments', 'nbformat', 'ipykernel', 'numpy'],
terminal = [],
kernel = ['ipykernel'],
nbformat = ['nbformat'],
notebook = ['notebook', 'ipywidgets'],
nbconvert = ['nbconvert'],
)
install_requires = [
'setuptools>=18.5',
'jedi>=0.10',
'decorator',
'pickleshare',
'simplegeneric>0.8',
'traitlets>=4.2',
'prompt_toolkit>=1.0.15,<2.0.0',
'pygments',
'backcall',
]
# Platform-specific dependencies:
# This is the correct way to specify these,
# but requires pip >= 6. pip < 6 ignores these.
extras_require.update({
':python_version == "3.4"': ['typing'],
':sys_platform != "win32"': ['pexpect'],
':sys_platform == "darwin"': ['appnope'],
':sys_platform == "win32"': ['colorama'],
':sys_platform == "win32" and python_version < "3.6"': ['win_unicode_console>=0.5'],
})
# 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':
install_requires.extend(['appnope'])
if not sys.platform.startswith('win'):
install_requires.append('pexpect')
# 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)
everything = set()
for key, deps in extras_require.items():
if ':' not in key:
everything.update(deps)
extras_require['all'] = everything
if 'setuptools' in sys.modules:
setuptools_extra_args['python_requires'] = '>=3.4'
setuptools_extra_args['zip_safe'] = False
setuptools_extra_args['entry_points'] = {
'console_scripts': find_entry_points(),
'pygments.lexers': [
'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
'ipython = IPython.lib.lexers:IPythonLexer',
'ipython3 = IPython.lib.lexers:IPython3Lexer',
],
}
setup_args['extras_require'] = extras_require
setup_args['install_requires'] = install_requires
else:
# 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
#---------------------------------------------------------------------------
# Do the actual setup now
#---------------------------------------------------------------------------
setup_args.update(setuptools_extra_args)
def main():
setup(**setup_args)
if __name__ == '__main__':
main()