##// END OF EJS Templates
Merge pull request #12675 from baogianghoangvu/pathlib-in-setuppy...
Matthias Bussonnier -
r26196:21f8f14b merge
parent child Browse files
Show More
@@ -1,264 +1,263 b''
1 #!/usr/bin/env python3
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 """Setup script for IPython.
3 """Setup script for IPython.
4
4
5 Under Posix environments it works like a typical setup.py script.
5 Under Posix environments it works like a typical setup.py script.
6 Under Windows, the command sdist is not supported, since IPython
6 Under Windows, the command sdist is not supported, since IPython
7 requires utilities which are not available under Windows."""
7 requires utilities which are not available under Windows."""
8
8
9 #-----------------------------------------------------------------------------
9 #-----------------------------------------------------------------------------
10 # Copyright (c) 2008-2011, IPython Development Team.
10 # Copyright (c) 2008-2011, IPython Development Team.
11 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
11 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
12 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
12 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
13 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
13 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
14 #
14 #
15 # Distributed under the terms of the Modified BSD License.
15 # Distributed under the terms of the Modified BSD License.
16 #
16 #
17 # The full license is in the file COPYING.rst, distributed with this software.
17 # The full license is in the file COPYING.rst, distributed with this software.
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19
19
20 import os
20 import os
21 import sys
21 import sys
22 from pathlib import Path
22
23
23 # **Python version check**
24 # **Python version check**
24 #
25 #
25 # This check is also made in IPython/__init__, don't forget to update both when
26 # This check is also made in IPython/__init__, don't forget to update both when
26 # changing Python version requirements.
27 # changing Python version requirements.
27 if sys.version_info < (3, 7):
28 if sys.version_info < (3, 7):
28 pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1.'
29 pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1.'
29 try:
30 try:
30 import pip
31 import pip
31 pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]])
32 pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]])
32 if pip_version < (9, 0, 1) :
33 if pip_version < (9, 0, 1) :
33 pip_message = 'Your pip version is out of date, please install pip >= 9.0.1. '\
34 pip_message = 'Your pip version is out of date, please install pip >= 9.0.1. '\
34 'pip {} detected.'.format(pip.__version__)
35 'pip {} detected.'.format(pip.__version__)
35 else:
36 else:
36 # pip is new enough - it must be something else
37 # pip is new enough - it must be something else
37 pip_message = ''
38 pip_message = ''
38 except Exception:
39 except Exception:
39 pass
40 pass
40
41
41
42
42 error = """
43 error = """
43 IPython 7.17+ supports Python 3.7 and above, following NEP 29.
44 IPython 7.17+ supports Python 3.7 and above, following NEP 29.
44 When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
45 When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
45 Python 3.3 and 3.4 were supported up to IPython 6.x.
46 Python 3.3 and 3.4 were supported up to IPython 6.x.
46 Python 3.5 was supported with IPython 7.0 to 7.9.
47 Python 3.5 was supported with IPython 7.0 to 7.9.
47 Python 3.6 was supported with IPython up to 7.16.
48 Python 3.6 was supported with IPython up to 7.16.
48
49
49 See IPython `README.rst` file for more information:
50 See IPython `README.rst` file for more information:
50
51
51 https://github.com/ipython/ipython/blob/master/README.rst
52 https://github.com/ipython/ipython/blob/master/README.rst
52
53
53 Python {py} detected.
54 Python {py} detected.
54 {pip}
55 {pip}
55 """.format(py=sys.version_info, pip=pip_message )
56 """.format(py=sys.version_info, pip=pip_message )
56
57
57 print(error, file=sys.stderr)
58 print(error, file=sys.stderr)
58 sys.exit(1)
59 sys.exit(1)
59
60
60 # At least we're on the python version we need, move on.
61 # At least we're on the python version we need, move on.
61
62
62 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
63 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
63 # update it when the contents of directories change.
64 # update it when the contents of directories change.
64 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
65 if Path("MANIFEST").exists():
66 Path("MANIFEST").unlink()
65
67
66 from distutils.core import setup
68 from distutils.core import setup
67
69
68 # Our own imports
70 # Our own imports
69 from setupbase import target_update
71 from setupbase import target_update
70
72
71 from setupbase import (
73 from setupbase import (
72 setup_args,
74 setup_args,
73 find_packages,
75 find_packages,
74 find_package_data,
76 find_package_data,
75 check_package_data_first,
77 check_package_data_first,
76 find_entry_points,
78 find_entry_points,
77 build_scripts_entrypt,
79 build_scripts_entrypt,
78 find_data_files,
80 find_data_files,
79 git_prebuild,
81 git_prebuild,
80 install_symlinked,
82 install_symlinked,
81 install_lib_symlink,
83 install_lib_symlink,
82 install_scripts_for_symlink,
84 install_scripts_for_symlink,
83 unsymlink,
85 unsymlink,
84 )
86 )
85
87
86 isfile = os.path.isfile
87 pjoin = os.path.join
88
89 #-------------------------------------------------------------------------------
88 #-------------------------------------------------------------------------------
90 # Handle OS specific things
89 # Handle OS specific things
91 #-------------------------------------------------------------------------------
90 #-------------------------------------------------------------------------------
92
91
93 if os.name in ('nt','dos'):
92 if os.name in ('nt','dos'):
94 os_name = 'windows'
93 os_name = 'windows'
95 else:
94 else:
96 os_name = os.name
95 os_name = os.name
97
96
98 # Under Windows, 'sdist' has not been supported. Now that the docs build with
97 # Under Windows, 'sdist' has not been supported. Now that the docs build with
99 # Sphinx it might work, but let's not turn it on until someone confirms that it
98 # Sphinx it might work, but let's not turn it on until someone confirms that it
100 # actually works.
99 # actually works.
101 if os_name == 'windows' and 'sdist' in sys.argv:
100 if os_name == 'windows' and 'sdist' in sys.argv:
102 print('The sdist command is not available under Windows. Exiting.')
101 print('The sdist command is not available under Windows. Exiting.')
103 sys.exit(1)
102 sys.exit(1)
104
103
105
104
106 #-------------------------------------------------------------------------------
105 #-------------------------------------------------------------------------------
107 # Things related to the IPython documentation
106 # Things related to the IPython documentation
108 #-------------------------------------------------------------------------------
107 #-------------------------------------------------------------------------------
109
108
110 # update the manuals when building a source dist
109 # update the manuals when building a source dist
111 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
110 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
112
111
113 # List of things to be updated. Each entry is a triplet of args for
112 # List of things to be updated. Each entry is a triplet of args for
114 # target_update()
113 # target_update()
115 to_update = [
114 to_update = [
116 ('docs/man/ipython.1.gz',
115 ('docs/man/ipython.1.gz',
117 ['docs/man/ipython.1'],
116 ['docs/man/ipython.1'],
118 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
117 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
119 ]
118 ]
120
119
121
120
122 [ target_update(*t) for t in to_update ]
121 [ target_update(*t) for t in to_update ]
123
122
124 #---------------------------------------------------------------------------
123 #---------------------------------------------------------------------------
125 # Find all the packages, package data, and data_files
124 # Find all the packages, package data, and data_files
126 #---------------------------------------------------------------------------
125 #---------------------------------------------------------------------------
127
126
128 packages = find_packages()
127 packages = find_packages()
129 package_data = find_package_data()
128 package_data = find_package_data()
130
129
131 data_files = find_data_files()
130 data_files = find_data_files()
132
131
133 setup_args['packages'] = packages
132 setup_args['packages'] = packages
134 setup_args['package_data'] = package_data
133 setup_args['package_data'] = package_data
135 setup_args['data_files'] = data_files
134 setup_args['data_files'] = data_files
136
135
137 #---------------------------------------------------------------------------
136 #---------------------------------------------------------------------------
138 # custom distutils commands
137 # custom distutils commands
139 #---------------------------------------------------------------------------
138 #---------------------------------------------------------------------------
140 # imports here, so they are after setuptools import if there was one
139 # imports here, so they are after setuptools import if there was one
141 from distutils.command.sdist import sdist
140 from distutils.command.sdist import sdist
142
141
143 setup_args['cmdclass'] = {
142 setup_args['cmdclass'] = {
144 'build_py': \
143 'build_py': \
145 check_package_data_first(git_prebuild('IPython')),
144 check_package_data_first(git_prebuild('IPython')),
146 'sdist' : git_prebuild('IPython', sdist),
145 'sdist' : git_prebuild('IPython', sdist),
147 'symlink': install_symlinked,
146 'symlink': install_symlinked,
148 'install_lib_symlink': install_lib_symlink,
147 'install_lib_symlink': install_lib_symlink,
149 'install_scripts_sym': install_scripts_for_symlink,
148 'install_scripts_sym': install_scripts_for_symlink,
150 'unsymlink': unsymlink,
149 'unsymlink': unsymlink,
151 }
150 }
152
151
153
152
154 #---------------------------------------------------------------------------
153 #---------------------------------------------------------------------------
155 # Handle scripts, dependencies, and setuptools specific things
154 # Handle scripts, dependencies, and setuptools specific things
156 #---------------------------------------------------------------------------
155 #---------------------------------------------------------------------------
157
156
158 # For some commands, use setuptools. Note that we do NOT list install here!
157 # For some commands, use setuptools. Note that we do NOT list install here!
159 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
158 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
160 needs_setuptools = {'develop', 'release', 'bdist_egg', 'bdist_rpm',
159 needs_setuptools = {'develop', 'release', 'bdist_egg', 'bdist_rpm',
161 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
160 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
162 'egg_info', 'easy_install', 'upload', 'install_egg_info',
161 'egg_info', 'easy_install', 'upload', 'install_egg_info',
163 }
162 }
164
163
165 if len(needs_setuptools.intersection(sys.argv)) > 0:
164 if len(needs_setuptools.intersection(sys.argv)) > 0:
166 import setuptools
165 import setuptools
167
166
168 # This dict is used for passing extra arguments that are setuptools
167 # This dict is used for passing extra arguments that are setuptools
169 # specific to setup
168 # specific to setup
170 setuptools_extra_args = {}
169 setuptools_extra_args = {}
171
170
172 # setuptools requirements
171 # setuptools requirements
173
172
174 extras_require = dict(
173 extras_require = dict(
175 parallel = ['ipyparallel'],
174 parallel = ['ipyparallel'],
176 qtconsole = ['qtconsole'],
175 qtconsole = ['qtconsole'],
177 doc = ['Sphinx>=1.3'],
176 doc = ['Sphinx>=1.3'],
178 test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments', 'nbformat', 'ipykernel', 'numpy>=1.14'],
177 test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments', 'nbformat', 'ipykernel', 'numpy>=1.14'],
179 terminal = [],
178 terminal = [],
180 kernel = ['ipykernel'],
179 kernel = ['ipykernel'],
181 nbformat = ['nbformat'],
180 nbformat = ['nbformat'],
182 notebook = ['notebook', 'ipywidgets'],
181 notebook = ['notebook', 'ipywidgets'],
183 nbconvert = ['nbconvert'],
182 nbconvert = ['nbconvert'],
184 )
183 )
185
184
186 install_requires = [
185 install_requires = [
187 'setuptools>=18.5',
186 'setuptools>=18.5',
188 'jedi>=0.16',
187 'jedi>=0.16',
189 'decorator',
188 'decorator',
190 'pickleshare',
189 'pickleshare',
191 'traitlets>=4.2',
190 'traitlets>=4.2',
192 'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1',
191 'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1',
193 'pygments',
192 'pygments',
194 'backcall',
193 'backcall',
195 'stack_data',
194 'stack_data',
196 ]
195 ]
197
196
198 # Platform-specific dependencies:
197 # Platform-specific dependencies:
199 # This is the correct way to specify these,
198 # This is the correct way to specify these,
200 # but requires pip >= 6. pip < 6 ignores these.
199 # but requires pip >= 6. pip < 6 ignores these.
201
200
202 extras_require.update(
201 extras_require.update(
203 {
202 {
204 ':sys_platform != "win32"': ["pexpect>4.3"],
203 ':sys_platform != "win32"': ["pexpect>4.3"],
205 ':sys_platform == "darwin"': ["appnope"],
204 ':sys_platform == "darwin"': ["appnope"],
206 ':sys_platform == "win32"': ["colorama"],
205 ':sys_platform == "win32"': ["colorama"],
207 }
206 }
208 )
207 )
209 # FIXME: re-specify above platform dependencies for pip < 6
208 # FIXME: re-specify above platform dependencies for pip < 6
210 # These would result in non-portable bdists.
209 # These would result in non-portable bdists.
211 if not any(arg.startswith('bdist') for arg in sys.argv):
210 if not any(arg.startswith('bdist') for arg in sys.argv):
212 if sys.platform == 'darwin':
211 if sys.platform == 'darwin':
213 install_requires.extend(['appnope'])
212 install_requires.extend(['appnope'])
214
213
215 if not sys.platform.startswith("win"):
214 if not sys.platform.startswith("win"):
216 install_requires.append("pexpect>4.3")
215 install_requires.append("pexpect>4.3")
217
216
218 # workaround pypa/setuptools#147, where setuptools misspells
217 # workaround pypa/setuptools#147, where setuptools misspells
219 # platform_python_implementation as python_implementation
218 # platform_python_implementation as python_implementation
220 if 'setuptools' in sys.modules:
219 if 'setuptools' in sys.modules:
221 for key in list(extras_require):
220 for key in list(extras_require):
222 if 'platform_python_implementation' in key:
221 if 'platform_python_implementation' in key:
223 new_key = key.replace('platform_python_implementation', 'python_implementation')
222 new_key = key.replace('platform_python_implementation', 'python_implementation')
224 extras_require[new_key] = extras_require.pop(key)
223 extras_require[new_key] = extras_require.pop(key)
225
224
226 everything = set()
225 everything = set()
227 for key, deps in extras_require.items():
226 for key, deps in extras_require.items():
228 if ':' not in key:
227 if ':' not in key:
229 everything.update(deps)
228 everything.update(deps)
230 extras_require['all'] = list(sorted(everything))
229 extras_require['all'] = list(sorted(everything))
231
230
232 if 'setuptools' in sys.modules:
231 if 'setuptools' in sys.modules:
233 setuptools_extra_args['python_requires'] = '>=3.7'
232 setuptools_extra_args['python_requires'] = '>=3.7'
234 setuptools_extra_args['zip_safe'] = False
233 setuptools_extra_args['zip_safe'] = False
235 setuptools_extra_args['entry_points'] = {
234 setuptools_extra_args['entry_points'] = {
236 'console_scripts': find_entry_points(),
235 'console_scripts': find_entry_points(),
237 'pygments.lexers': [
236 'pygments.lexers': [
238 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
237 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
239 'ipython = IPython.lib.lexers:IPythonLexer',
238 'ipython = IPython.lib.lexers:IPythonLexer',
240 'ipython3 = IPython.lib.lexers:IPython3Lexer',
239 'ipython3 = IPython.lib.lexers:IPython3Lexer',
241 ],
240 ],
242 }
241 }
243 setup_args['extras_require'] = extras_require
242 setup_args['extras_require'] = extras_require
244 setup_args['install_requires'] = install_requires
243 setup_args['install_requires'] = install_requires
245
244
246 else:
245 else:
247 # scripts has to be a non-empty list, or install_scripts isn't called
246 # scripts has to be a non-empty list, or install_scripts isn't called
248 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
247 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
249
248
250 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
249 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
251
250
252 #---------------------------------------------------------------------------
251 #---------------------------------------------------------------------------
253 # Do the actual setup now
252 # Do the actual setup now
254 #---------------------------------------------------------------------------
253 #---------------------------------------------------------------------------
255
254
256 setup_args.update(setuptools_extra_args)
255 setup_args.update(setuptools_extra_args)
257
256
258
257
259
258
260 def main():
259 def main():
261 setup(**setup_args)
260 setup(**setup_args)
262
261
263 if __name__ == '__main__':
262 if __name__ == '__main__':
264 main()
263 main()
General Comments 0
You need to be logged in to leave comments. Login now