##// END OF EJS Templates
[setup] Add pytest to test dependencies
Samuel Gaist -
Show More
@@ -1,272 +1,273 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 from pathlib import Path
23
23
24 # **Python version check**
24 # **Python version check**
25 #
25 #
26 # 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
27 # changing Python version requirements.
27 # changing Python version requirements.
28 if sys.version_info < (3, 7):
28 if sys.version_info < (3, 7):
29 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.'
30 try:
30 try:
31 import pip
31 import pip
32 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]])
33 if pip_version < (9, 0, 1) :
33 if pip_version < (9, 0, 1) :
34 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. '\
35 'pip {} detected.'.format(pip.__version__)
35 'pip {} detected.'.format(pip.__version__)
36 else:
36 else:
37 # pip is new enough - it must be something else
37 # pip is new enough - it must be something else
38 pip_message = ''
38 pip_message = ''
39 except Exception:
39 except Exception:
40 pass
40 pass
41
41
42
42
43 error = """
43 error = """
44 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.
45 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.
46 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.
47 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.
48 Python 3.6 was supported with IPython up to 7.16.
48 Python 3.6 was supported with IPython up to 7.16.
49
49
50 See IPython `README.rst` file for more information:
50 See IPython `README.rst` file for more information:
51
51
52 https://github.com/ipython/ipython/blob/master/README.rst
52 https://github.com/ipython/ipython/blob/master/README.rst
53
53
54 Python {py} detected.
54 Python {py} detected.
55 {pip}
55 {pip}
56 """.format(py=sys.version_info, pip=pip_message )
56 """.format(py=sys.version_info, pip=pip_message )
57
57
58 print(error, file=sys.stderr)
58 print(error, file=sys.stderr)
59 sys.exit(1)
59 sys.exit(1)
60
60
61 # 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.
62
62
63 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
63 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
64 # update it when the contents of directories change.
64 # update it when the contents of directories change.
65 if Path("MANIFEST").exists():
65 if Path("MANIFEST").exists():
66 Path("MANIFEST").unlink()
66 Path("MANIFEST").unlink()
67
67
68 from distutils.core import setup
68 from distutils.core import setup
69
69
70 # Our own imports
70 # Our own imports
71 from setupbase import target_update
71 from setupbase import target_update
72
72
73 from setupbase import (
73 from setupbase import (
74 setup_args,
74 setup_args,
75 find_packages,
75 find_packages,
76 find_package_data,
76 find_package_data,
77 check_package_data_first,
77 check_package_data_first,
78 find_entry_points,
78 find_entry_points,
79 build_scripts_entrypt,
79 build_scripts_entrypt,
80 find_data_files,
80 find_data_files,
81 git_prebuild,
81 git_prebuild,
82 install_symlinked,
82 install_symlinked,
83 install_lib_symlink,
83 install_lib_symlink,
84 install_scripts_for_symlink,
84 install_scripts_for_symlink,
85 unsymlink,
85 unsymlink,
86 )
86 )
87
87
88 #-------------------------------------------------------------------------------
88 #-------------------------------------------------------------------------------
89 # Handle OS specific things
89 # Handle OS specific things
90 #-------------------------------------------------------------------------------
90 #-------------------------------------------------------------------------------
91
91
92 if os.name in ('nt','dos'):
92 if os.name in ('nt','dos'):
93 os_name = 'windows'
93 os_name = 'windows'
94 else:
94 else:
95 os_name = os.name
95 os_name = os.name
96
96
97 # 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
98 # 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
99 # actually works.
99 # actually works.
100 if os_name == 'windows' and 'sdist' in sys.argv:
100 if os_name == 'windows' and 'sdist' in sys.argv:
101 print('The sdist command is not available under Windows. Exiting.')
101 print('The sdist command is not available under Windows. Exiting.')
102 sys.exit(1)
102 sys.exit(1)
103
103
104
104
105 #-------------------------------------------------------------------------------
105 #-------------------------------------------------------------------------------
106 # Things related to the IPython documentation
106 # Things related to the IPython documentation
107 #-------------------------------------------------------------------------------
107 #-------------------------------------------------------------------------------
108
108
109 # update the manuals when building a source dist
109 # update the manuals when building a source dist
110 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'):
111
111
112 # 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
113 # target_update()
113 # target_update()
114 to_update = [
114 to_update = [
115 ('docs/man/ipython.1.gz',
115 ('docs/man/ipython.1.gz',
116 ['docs/man/ipython.1'],
116 ['docs/man/ipython.1'],
117 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
117 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
118 ]
118 ]
119
119
120
120
121 [ target_update(*t) for t in to_update ]
121 [ target_update(*t) for t in to_update ]
122
122
123 #---------------------------------------------------------------------------
123 #---------------------------------------------------------------------------
124 # Find all the packages, package data, and data_files
124 # Find all the packages, package data, and data_files
125 #---------------------------------------------------------------------------
125 #---------------------------------------------------------------------------
126
126
127 packages = find_packages()
127 packages = find_packages()
128 package_data = find_package_data()
128 package_data = find_package_data()
129
129
130 data_files = find_data_files()
130 data_files = find_data_files()
131
131
132 setup_args['packages'] = packages
132 setup_args['packages'] = packages
133 setup_args['package_data'] = package_data
133 setup_args['package_data'] = package_data
134 setup_args['data_files'] = data_files
134 setup_args['data_files'] = data_files
135
135
136 #---------------------------------------------------------------------------
136 #---------------------------------------------------------------------------
137 # custom distutils commands
137 # custom distutils commands
138 #---------------------------------------------------------------------------
138 #---------------------------------------------------------------------------
139 # 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
140 from distutils.command.sdist import sdist
140 from distutils.command.sdist import sdist
141
141
142 setup_args['cmdclass'] = {
142 setup_args['cmdclass'] = {
143 'build_py': \
143 'build_py': \
144 check_package_data_first(git_prebuild('IPython')),
144 check_package_data_first(git_prebuild('IPython')),
145 'sdist' : git_prebuild('IPython', sdist),
145 'sdist' : git_prebuild('IPython', sdist),
146 'symlink': install_symlinked,
146 'symlink': install_symlinked,
147 'install_lib_symlink': install_lib_symlink,
147 'install_lib_symlink': install_lib_symlink,
148 'install_scripts_sym': install_scripts_for_symlink,
148 'install_scripts_sym': install_scripts_for_symlink,
149 'unsymlink': unsymlink,
149 'unsymlink': unsymlink,
150 }
150 }
151
151
152
152
153 #---------------------------------------------------------------------------
153 #---------------------------------------------------------------------------
154 # Handle scripts, dependencies, and setuptools specific things
154 # Handle scripts, dependencies, and setuptools specific things
155 #---------------------------------------------------------------------------
155 #---------------------------------------------------------------------------
156
156
157 # 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!
158 # 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'
159 needs_setuptools = {'develop', 'release', 'bdist_egg', 'bdist_rpm',
159 needs_setuptools = {'develop', 'release', 'bdist_egg', 'bdist_rpm',
160 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
160 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
161 'egg_info', 'easy_install', 'upload', 'install_egg_info',
161 'egg_info', 'easy_install', 'upload', 'install_egg_info',
162 }
162 }
163
163
164 if len(needs_setuptools.intersection(sys.argv)) > 0:
164 if len(needs_setuptools.intersection(sys.argv)) > 0:
165 import setuptools
165 import setuptools
166
166
167 # This dict is used for passing extra arguments that are setuptools
167 # This dict is used for passing extra arguments that are setuptools
168 # specific to setup
168 # specific to setup
169 setuptools_extra_args = {}
169 setuptools_extra_args = {}
170
170
171 # setuptools requirements
171 # setuptools requirements
172
172
173 extras_require = dict(
173 extras_require = dict(
174 parallel=["ipyparallel"],
174 parallel=["ipyparallel"],
175 qtconsole=["qtconsole"],
175 qtconsole=["qtconsole"],
176 doc=["Sphinx>=1.3"],
176 doc=["Sphinx>=1.3"],
177 test=[
177 test=[
178 "nose>=0.10.1",
178 "nose>=0.10.1",
179 "pytest",
179 "requests",
180 "requests",
180 "testpath",
181 "testpath",
181 "pygments",
182 "pygments",
182 "nbformat",
183 "nbformat",
183 "ipykernel",
184 "ipykernel",
184 "numpy>=1.17",
185 "numpy>=1.17",
185 ],
186 ],
186 terminal=[],
187 terminal=[],
187 kernel=["ipykernel"],
188 kernel=["ipykernel"],
188 nbformat=["nbformat"],
189 nbformat=["nbformat"],
189 notebook=["notebook", "ipywidgets"],
190 notebook=["notebook", "ipywidgets"],
190 nbconvert=["nbconvert"],
191 nbconvert=["nbconvert"],
191 )
192 )
192
193
193 install_requires = [
194 install_requires = [
194 "setuptools>=18.5",
195 "setuptools>=18.5",
195 "jedi>=0.16",
196 "jedi>=0.16",
196 "decorator",
197 "decorator",
197 "pickleshare",
198 "pickleshare",
198 "traitlets>=4.2",
199 "traitlets>=4.2",
199 "prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1",
200 "prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1",
200 "pygments",
201 "pygments",
201 "backcall",
202 "backcall",
202 "stack_data",
203 "stack_data",
203 "matplotlib-inline",
204 "matplotlib-inline",
204 ]
205 ]
205
206
206 # Platform-specific dependencies:
207 # Platform-specific dependencies:
207 # This is the correct way to specify these,
208 # This is the correct way to specify these,
208 # but requires pip >= 6. pip < 6 ignores these.
209 # but requires pip >= 6. pip < 6 ignores these.
209
210
210 extras_require.update(
211 extras_require.update(
211 {
212 {
212 ':sys_platform != "win32"': ["pexpect>4.3"],
213 ':sys_platform != "win32"': ["pexpect>4.3"],
213 ':sys_platform == "darwin"': ["appnope"],
214 ':sys_platform == "darwin"': ["appnope"],
214 ':sys_platform == "win32"': ["colorama"],
215 ':sys_platform == "win32"': ["colorama"],
215 }
216 }
216 )
217 )
217 # FIXME: re-specify above platform dependencies for pip < 6
218 # FIXME: re-specify above platform dependencies for pip < 6
218 # These would result in non-portable bdists.
219 # These would result in non-portable bdists.
219 if not any(arg.startswith('bdist') for arg in sys.argv):
220 if not any(arg.startswith('bdist') for arg in sys.argv):
220 if sys.platform == 'darwin':
221 if sys.platform == 'darwin':
221 install_requires.extend(['appnope'])
222 install_requires.extend(['appnope'])
222
223
223 if not sys.platform.startswith("win"):
224 if not sys.platform.startswith("win"):
224 install_requires.append("pexpect>4.3")
225 install_requires.append("pexpect>4.3")
225
226
226 # workaround pypa/setuptools#147, where setuptools misspells
227 # workaround pypa/setuptools#147, where setuptools misspells
227 # platform_python_implementation as python_implementation
228 # platform_python_implementation as python_implementation
228 if 'setuptools' in sys.modules:
229 if 'setuptools' in sys.modules:
229 for key in list(extras_require):
230 for key in list(extras_require):
230 if 'platform_python_implementation' in key:
231 if 'platform_python_implementation' in key:
231 new_key = key.replace('platform_python_implementation', 'python_implementation')
232 new_key = key.replace('platform_python_implementation', 'python_implementation')
232 extras_require[new_key] = extras_require.pop(key)
233 extras_require[new_key] = extras_require.pop(key)
233
234
234 everything = set()
235 everything = set()
235 for key, deps in extras_require.items():
236 for key, deps in extras_require.items():
236 if ':' not in key:
237 if ':' not in key:
237 everything.update(deps)
238 everything.update(deps)
238 extras_require['all'] = list(sorted(everything))
239 extras_require['all'] = list(sorted(everything))
239
240
240 if 'setuptools' in sys.modules:
241 if 'setuptools' in sys.modules:
241 setuptools_extra_args['python_requires'] = '>=3.7'
242 setuptools_extra_args['python_requires'] = '>=3.7'
242 setuptools_extra_args['zip_safe'] = False
243 setuptools_extra_args['zip_safe'] = False
243 setuptools_extra_args['entry_points'] = {
244 setuptools_extra_args['entry_points'] = {
244 'console_scripts': find_entry_points(),
245 'console_scripts': find_entry_points(),
245 'pygments.lexers': [
246 'pygments.lexers': [
246 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
247 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
247 'ipython = IPython.lib.lexers:IPythonLexer',
248 'ipython = IPython.lib.lexers:IPythonLexer',
248 'ipython3 = IPython.lib.lexers:IPython3Lexer',
249 'ipython3 = IPython.lib.lexers:IPython3Lexer',
249 ],
250 ],
250 }
251 }
251 setup_args['extras_require'] = extras_require
252 setup_args['extras_require'] = extras_require
252 setup_args['install_requires'] = install_requires
253 setup_args['install_requires'] = install_requires
253
254
254 else:
255 else:
255 # scripts has to be a non-empty list, or install_scripts isn't called
256 # scripts has to be a non-empty list, or install_scripts isn't called
256 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
257 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
257
258
258 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
259 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
259
260
260 #---------------------------------------------------------------------------
261 #---------------------------------------------------------------------------
261 # Do the actual setup now
262 # Do the actual setup now
262 #---------------------------------------------------------------------------
263 #---------------------------------------------------------------------------
263
264
264 setup_args.update(setuptools_extra_args)
265 setup_args.update(setuptools_extra_args)
265
266
266
267
267
268
268 def main():
269 def main():
269 setup(**setup_args)
270 setup(**setup_args)
270
271
271 if __name__ == '__main__':
272 if __name__ == '__main__':
272 main()
273 main()
General Comments 0
You need to be logged in to leave comments. Login now