##// END OF EJS Templates
only use backports.shutil_get_terminal_size on Python 2...
Min RK -
Show More
@@ -1,125 +1,121 b''
1 # encoding: utf-8
1 # encoding: utf-8
2 """
2 """
3 Utilities for working with terminals.
3 Utilities for working with terminals.
4
4
5 Authors:
5 Authors:
6
6
7 * Brian E. Granger
7 * Brian E. Granger
8 * Fernando Perez
8 * Fernando Perez
9 * Alexander Belchenko (e-mail: bialix AT ukr.net)
9 * Alexander Belchenko (e-mail: bialix AT ukr.net)
10 """
10 """
11
11
12 #-----------------------------------------------------------------------------
12 # Copyright (c) IPython Development Team.
13 # Copyright (C) 2008-2011 The IPython Development Team
13 # Distributed under the terms of the Modified BSD License.
14 #
15 # Distributed under the terms of the BSD License. The full license is in
16 # the file COPYING, distributed as part of this software.
17 #-----------------------------------------------------------------------------
18
19 #-----------------------------------------------------------------------------
20 # Imports
21 #-----------------------------------------------------------------------------
22
14
23 import os
15 import os
24 import struct
16 import struct
25 import sys
17 import sys
26 import warnings
18 import warnings
27 import backports.shutil_get_terminal_size
19 try:
20 from shutil import get_terminal_size as _get_terminal_size
21 except ImportError:
22 # use backport on Python 2
23 from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size
28
24
29 from . import py3compat
25 from . import py3compat
30
26
31 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
32 # Code
28 # Code
33 #-----------------------------------------------------------------------------
29 #-----------------------------------------------------------------------------
34
30
35 # This variable is part of the expected API of the module:
31 # This variable is part of the expected API of the module:
36 ignore_termtitle = True
32 ignore_termtitle = True
37
33
38
34
39
35
40 if os.name == 'posix':
36 if os.name == 'posix':
41 def _term_clear():
37 def _term_clear():
42 os.system('clear')
38 os.system('clear')
43 elif sys.platform == 'win32':
39 elif sys.platform == 'win32':
44 def _term_clear():
40 def _term_clear():
45 os.system('cls')
41 os.system('cls')
46 else:
42 else:
47 def _term_clear():
43 def _term_clear():
48 pass
44 pass
49
45
50
46
51
47
52 def toggle_set_term_title(val):
48 def toggle_set_term_title(val):
53 """Control whether set_term_title is active or not.
49 """Control whether set_term_title is active or not.
54
50
55 set_term_title() allows writing to the console titlebar. In embedded
51 set_term_title() allows writing to the console titlebar. In embedded
56 widgets this can cause problems, so this call can be used to toggle it on
52 widgets this can cause problems, so this call can be used to toggle it on
57 or off as needed.
53 or off as needed.
58
54
59 The default state of the module is for the function to be disabled.
55 The default state of the module is for the function to be disabled.
60
56
61 Parameters
57 Parameters
62 ----------
58 ----------
63 val : bool
59 val : bool
64 If True, set_term_title() actually writes to the terminal (using the
60 If True, set_term_title() actually writes to the terminal (using the
65 appropriate platform-specific module). If False, it is a no-op.
61 appropriate platform-specific module). If False, it is a no-op.
66 """
62 """
67 global ignore_termtitle
63 global ignore_termtitle
68 ignore_termtitle = not(val)
64 ignore_termtitle = not(val)
69
65
70
66
71 def _set_term_title(*args,**kw):
67 def _set_term_title(*args,**kw):
72 """Dummy no-op."""
68 """Dummy no-op."""
73 pass
69 pass
74
70
75
71
76 def _set_term_title_xterm(title):
72 def _set_term_title_xterm(title):
77 """ Change virtual terminal title in xterm-workalikes """
73 """ Change virtual terminal title in xterm-workalikes """
78 sys.stdout.write('\033]0;%s\007' % title)
74 sys.stdout.write('\033]0;%s\007' % title)
79
75
80 if os.name == 'posix':
76 if os.name == 'posix':
81 TERM = os.environ.get('TERM','')
77 TERM = os.environ.get('TERM','')
82 if TERM.startswith('xterm'):
78 if TERM.startswith('xterm'):
83 _set_term_title = _set_term_title_xterm
79 _set_term_title = _set_term_title_xterm
84 elif sys.platform == 'win32':
80 elif sys.platform == 'win32':
85 try:
81 try:
86 import ctypes
82 import ctypes
87
83
88 SetConsoleTitleW = ctypes.windll.kernel32.SetConsoleTitleW
84 SetConsoleTitleW = ctypes.windll.kernel32.SetConsoleTitleW
89 SetConsoleTitleW.argtypes = [ctypes.c_wchar_p]
85 SetConsoleTitleW.argtypes = [ctypes.c_wchar_p]
90
86
91 def _set_term_title(title):
87 def _set_term_title(title):
92 """Set terminal title using ctypes to access the Win32 APIs."""
88 """Set terminal title using ctypes to access the Win32 APIs."""
93 SetConsoleTitleW(title)
89 SetConsoleTitleW(title)
94 except ImportError:
90 except ImportError:
95 def _set_term_title(title):
91 def _set_term_title(title):
96 """Set terminal title using the 'title' command."""
92 """Set terminal title using the 'title' command."""
97 global ignore_termtitle
93 global ignore_termtitle
98
94
99 try:
95 try:
100 # Cannot be on network share when issuing system commands
96 # Cannot be on network share when issuing system commands
101 curr = py3compat.getcwd()
97 curr = py3compat.getcwd()
102 os.chdir("C:")
98 os.chdir("C:")
103 ret = os.system("title " + title)
99 ret = os.system("title " + title)
104 finally:
100 finally:
105 os.chdir(curr)
101 os.chdir(curr)
106 if ret:
102 if ret:
107 # non-zero return code signals error, don't try again
103 # non-zero return code signals error, don't try again
108 ignore_termtitle = True
104 ignore_termtitle = True
109
105
110
106
111 def set_term_title(title):
107 def set_term_title(title):
112 """Set terminal title using the necessary platform-dependent calls."""
108 """Set terminal title using the necessary platform-dependent calls."""
113 if ignore_termtitle:
109 if ignore_termtitle:
114 return
110 return
115 _set_term_title(title)
111 _set_term_title(title)
116
112
117
113
118 def freeze_term_title():
114 def freeze_term_title():
119 warnings.warn("This function is deprecated, use toggle_set_term_title()")
115 warnings.warn("This function is deprecated, use toggle_set_term_title()")
120 global ignore_termtitle
116 global ignore_termtitle
121 ignore_termtitle = True
117 ignore_termtitle = True
122
118
123
119
124 def get_terminal_size(defaultx=80, defaulty=25):
120 def get_terminal_size(defaultx=80, defaulty=25):
125 return backports.shutil_get_terminal_size.get_terminal_size((defaultx, defaulty))
121 return _get_terminal_size((defaultx, defaulty))
@@ -1,299 +1,299 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
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 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 # Minimal Python version sanity check
21 # Minimal Python version sanity check
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23 from __future__ import print_function
23 from __future__ import print_function
24
24
25 import sys
25 import sys
26
26
27 # This check is also made in IPython/__init__, don't forget to update both when
27 # This check is also made in IPython/__init__, don't forget to update both when
28 # changing Python version requirements.
28 # changing Python version requirements.
29 v = sys.version_info
29 v = sys.version_info
30 if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
30 if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
31 error = "ERROR: IPython requires Python version 2.7 or 3.3 or above."
31 error = "ERROR: IPython requires Python version 2.7 or 3.3 or above."
32 print(error, file=sys.stderr)
32 print(error, file=sys.stderr)
33 sys.exit(1)
33 sys.exit(1)
34
34
35 PY3 = (sys.version_info[0] >= 3)
35 PY3 = (sys.version_info[0] >= 3)
36
36
37 # At least we're on the python version we need, move on.
37 # At least we're on the python version we need, move on.
38
38
39 #-------------------------------------------------------------------------------
39 #-------------------------------------------------------------------------------
40 # Imports
40 # Imports
41 #-------------------------------------------------------------------------------
41 #-------------------------------------------------------------------------------
42
42
43 # Stdlib imports
43 # Stdlib imports
44 import os
44 import os
45
45
46 from glob import glob
46 from glob import glob
47
47
48 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
48 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
49 # update it when the contents of directories change.
49 # update it when the contents of directories change.
50 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
50 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
51
51
52 from distutils.core import setup
52 from distutils.core import setup
53
53
54 # Our own imports
54 # Our own imports
55 from setupbase import target_update
55 from setupbase import target_update
56
56
57 from setupbase import (
57 from setupbase import (
58 setup_args,
58 setup_args,
59 find_packages,
59 find_packages,
60 find_package_data,
60 find_package_data,
61 check_package_data_first,
61 check_package_data_first,
62 find_entry_points,
62 find_entry_points,
63 build_scripts_entrypt,
63 build_scripts_entrypt,
64 find_data_files,
64 find_data_files,
65 git_prebuild,
65 git_prebuild,
66 install_symlinked,
66 install_symlinked,
67 install_lib_symlink,
67 install_lib_symlink,
68 install_scripts_for_symlink,
68 install_scripts_for_symlink,
69 unsymlink,
69 unsymlink,
70 )
70 )
71
71
72 isfile = os.path.isfile
72 isfile = os.path.isfile
73 pjoin = os.path.join
73 pjoin = os.path.join
74
74
75 #-------------------------------------------------------------------------------
75 #-------------------------------------------------------------------------------
76 # Handle OS specific things
76 # Handle OS specific things
77 #-------------------------------------------------------------------------------
77 #-------------------------------------------------------------------------------
78
78
79 if os.name in ('nt','dos'):
79 if os.name in ('nt','dos'):
80 os_name = 'windows'
80 os_name = 'windows'
81 else:
81 else:
82 os_name = os.name
82 os_name = os.name
83
83
84 # Under Windows, 'sdist' has not been supported. Now that the docs build with
84 # Under Windows, 'sdist' has not been supported. Now that the docs build with
85 # Sphinx it might work, but let's not turn it on until someone confirms that it
85 # Sphinx it might work, but let's not turn it on until someone confirms that it
86 # actually works.
86 # actually works.
87 if os_name == 'windows' and 'sdist' in sys.argv:
87 if os_name == 'windows' and 'sdist' in sys.argv:
88 print('The sdist command is not available under Windows. Exiting.')
88 print('The sdist command is not available under Windows. Exiting.')
89 sys.exit(1)
89 sys.exit(1)
90
90
91
91
92 #-------------------------------------------------------------------------------
92 #-------------------------------------------------------------------------------
93 # Things related to the IPython documentation
93 # Things related to the IPython documentation
94 #-------------------------------------------------------------------------------
94 #-------------------------------------------------------------------------------
95
95
96 # update the manuals when building a source dist
96 # update the manuals when building a source dist
97 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
97 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
98
98
99 # List of things to be updated. Each entry is a triplet of args for
99 # List of things to be updated. Each entry is a triplet of args for
100 # target_update()
100 # target_update()
101 to_update = [
101 to_update = [
102 ('docs/man/ipython.1.gz',
102 ('docs/man/ipython.1.gz',
103 ['docs/man/ipython.1'],
103 ['docs/man/ipython.1'],
104 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
104 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
105 ]
105 ]
106
106
107
107
108 [ target_update(*t) for t in to_update ]
108 [ target_update(*t) for t in to_update ]
109
109
110 #---------------------------------------------------------------------------
110 #---------------------------------------------------------------------------
111 # Find all the packages, package data, and data_files
111 # Find all the packages, package data, and data_files
112 #---------------------------------------------------------------------------
112 #---------------------------------------------------------------------------
113
113
114 packages = find_packages()
114 packages = find_packages()
115 package_data = find_package_data()
115 package_data = find_package_data()
116
116
117 data_files = find_data_files()
117 data_files = find_data_files()
118
118
119 setup_args['packages'] = packages
119 setup_args['packages'] = packages
120 setup_args['package_data'] = package_data
120 setup_args['package_data'] = package_data
121 setup_args['data_files'] = data_files
121 setup_args['data_files'] = data_files
122
122
123 #---------------------------------------------------------------------------
123 #---------------------------------------------------------------------------
124 # custom distutils commands
124 # custom distutils commands
125 #---------------------------------------------------------------------------
125 #---------------------------------------------------------------------------
126 # imports here, so they are after setuptools import if there was one
126 # imports here, so they are after setuptools import if there was one
127 from distutils.command.sdist import sdist
127 from distutils.command.sdist import sdist
128 from distutils.command.upload import upload
128 from distutils.command.upload import upload
129
129
130 class UploadWindowsInstallers(upload):
130 class UploadWindowsInstallers(upload):
131
131
132 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
132 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
133 user_options = upload.user_options + [
133 user_options = upload.user_options + [
134 ('files=', 'f', 'exe file (or glob) to upload')
134 ('files=', 'f', 'exe file (or glob) to upload')
135 ]
135 ]
136 def initialize_options(self):
136 def initialize_options(self):
137 upload.initialize_options(self)
137 upload.initialize_options(self)
138 meta = self.distribution.metadata
138 meta = self.distribution.metadata
139 base = '{name}-{version}'.format(
139 base = '{name}-{version}'.format(
140 name=meta.get_name(),
140 name=meta.get_name(),
141 version=meta.get_version()
141 version=meta.get_version()
142 )
142 )
143 self.files = os.path.join('dist', '%s.*.exe' % base)
143 self.files = os.path.join('dist', '%s.*.exe' % base)
144
144
145 def run(self):
145 def run(self):
146 for dist_file in glob(self.files):
146 for dist_file in glob(self.files):
147 self.upload_file('bdist_wininst', 'any', dist_file)
147 self.upload_file('bdist_wininst', 'any', dist_file)
148
148
149 setup_args['cmdclass'] = {
149 setup_args['cmdclass'] = {
150 'build_py': \
150 'build_py': \
151 check_package_data_first(git_prebuild('IPython')),
151 check_package_data_first(git_prebuild('IPython')),
152 'sdist' : git_prebuild('IPython', sdist),
152 'sdist' : git_prebuild('IPython', sdist),
153 'upload_wininst' : UploadWindowsInstallers,
153 'upload_wininst' : UploadWindowsInstallers,
154 'symlink': install_symlinked,
154 'symlink': install_symlinked,
155 'install_lib_symlink': install_lib_symlink,
155 'install_lib_symlink': install_lib_symlink,
156 'install_scripts_sym': install_scripts_for_symlink,
156 'install_scripts_sym': install_scripts_for_symlink,
157 'unsymlink': unsymlink,
157 'unsymlink': unsymlink,
158 }
158 }
159
159
160
160
161 #---------------------------------------------------------------------------
161 #---------------------------------------------------------------------------
162 # Handle scripts, dependencies, and setuptools specific things
162 # Handle scripts, dependencies, and setuptools specific things
163 #---------------------------------------------------------------------------
163 #---------------------------------------------------------------------------
164
164
165 # For some commands, use setuptools. Note that we do NOT list install here!
165 # For some commands, use setuptools. Note that we do NOT list install here!
166 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
166 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
167 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
167 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
168 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
168 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
169 'egg_info', 'easy_install', 'upload', 'install_egg_info',
169 'egg_info', 'easy_install', 'upload', 'install_egg_info',
170 ))
170 ))
171
171
172 if len(needs_setuptools.intersection(sys.argv)) > 0:
172 if len(needs_setuptools.intersection(sys.argv)) > 0:
173 import setuptools
173 import setuptools
174
174
175 # This dict is used for passing extra arguments that are setuptools
175 # This dict is used for passing extra arguments that are setuptools
176 # specific to setup
176 # specific to setup
177 setuptools_extra_args = {}
177 setuptools_extra_args = {}
178
178
179 # setuptools requirements
179 # setuptools requirements
180
180
181 extras_require = dict(
181 extras_require = dict(
182 parallel = ['ipyparallel'],
182 parallel = ['ipyparallel'],
183 qtconsole = ['qtconsole'],
183 qtconsole = ['qtconsole'],
184 doc = ['Sphinx>=1.3'],
184 doc = ['Sphinx>=1.3'],
185 test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments'],
185 test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments'],
186 terminal = [],
186 terminal = [],
187 kernel = ['ipykernel'],
187 kernel = ['ipykernel'],
188 nbformat = ['nbformat'],
188 nbformat = ['nbformat'],
189 notebook = ['notebook', 'ipywidgets'],
189 notebook = ['notebook', 'ipywidgets'],
190 nbconvert = ['nbconvert'],
190 nbconvert = ['nbconvert'],
191 )
191 )
192 install_requires = [
192 install_requires = [
193 'setuptools>=18.5',
193 'setuptools>=18.5',
194 'decorator',
194 'decorator',
195 'pickleshare',
195 'pickleshare',
196 'simplegeneric>0.8',
196 'simplegeneric>0.8',
197 'traitlets',
197 'traitlets',
198 'prompt_toolkit>=0.60',
198 'prompt_toolkit>=0.60',
199 'pygments',
199 'pygments',
200 'backports.shutil_get_terminal_size',
201 ]
200 ]
202
201
203 # Platform-specific dependencies:
202 # Platform-specific dependencies:
204 # This is the correct way to specify these,
203 # This is the correct way to specify these,
205 # but requires pip >= 6. pip < 6 ignores these.
204 # but requires pip >= 6. pip < 6 ignores these.
206
205
207 extras_require.update({
206 extras_require.update({
207 ':python_version == "2.7"': ['backports.shutil_get_terminal_size'],
208 ':python_version == "2.7" or python_version == "3.3"': ['pathlib2'],
208 ':python_version == "2.7" or python_version == "3.3"': ['pathlib2'],
209 ':sys_platform != "win32"': ['pexpect'],
209 ':sys_platform != "win32"': ['pexpect'],
210 ':sys_platform == "darwin"': ['appnope'],
210 ':sys_platform == "darwin"': ['appnope'],
211 ':sys_platform == "win32"': ['colorama'],
211 ':sys_platform == "win32"': ['colorama'],
212 'test:python_version == "2.7"': ['mock'],
212 'test:python_version == "2.7"': ['mock'],
213 })
213 })
214 # FIXME: re-specify above platform dependencies for pip < 6
214 # FIXME: re-specify above platform dependencies for pip < 6
215 # These would result in non-portable bdists.
215 # These would result in non-portable bdists.
216 if not any(arg.startswith('bdist') for arg in sys.argv):
216 if not any(arg.startswith('bdist') for arg in sys.argv):
217 if sys.version_info < (3, 3):
217 if sys.version_info < (3, 3):
218 extras_require['test'].append('mock')
218 extras_require['test'].append('mock')
219
219
220 if sys.platform == 'darwin':
220 if sys.platform == 'darwin':
221 install_requires.extend(['appnope'])
221 install_requires.extend(['appnope'])
222 have_readline = False
222 have_readline = False
223 try:
223 try:
224 import readline
224 import readline
225 except ImportError:
225 except ImportError:
226 pass
226 pass
227 else:
227 else:
228 if 'libedit' not in readline.__doc__:
228 if 'libedit' not in readline.__doc__:
229 have_readline = True
229 have_readline = True
230 if not have_readline:
230 if not have_readline:
231 install_requires.extend(['gnureadline'])
231 install_requires.extend(['gnureadline'])
232
232
233 if sys.platform.startswith('win'):
233 if sys.platform.startswith('win'):
234 extras_require['terminal'].append('pyreadline>=2.0')
234 extras_require['terminal'].append('pyreadline>=2.0')
235 else:
235 else:
236 install_requires.append('pexpect')
236 install_requires.append('pexpect')
237
237
238 # workaround pypa/setuptools#147, where setuptools misspells
238 # workaround pypa/setuptools#147, where setuptools misspells
239 # platform_python_implementation as python_implementation
239 # platform_python_implementation as python_implementation
240 if 'setuptools' in sys.modules:
240 if 'setuptools' in sys.modules:
241 for key in list(extras_require):
241 for key in list(extras_require):
242 if 'platform_python_implementation' in key:
242 if 'platform_python_implementation' in key:
243 new_key = key.replace('platform_python_implementation', 'python_implementation')
243 new_key = key.replace('platform_python_implementation', 'python_implementation')
244 extras_require[new_key] = extras_require.pop(key)
244 extras_require[new_key] = extras_require.pop(key)
245
245
246 everything = set()
246 everything = set()
247 for key, deps in extras_require.items():
247 for key, deps in extras_require.items():
248 if ':' not in key:
248 if ':' not in key:
249 everything.update(deps)
249 everything.update(deps)
250 extras_require['all'] = everything
250 extras_require['all'] = everything
251
251
252 if 'setuptools' in sys.modules:
252 if 'setuptools' in sys.modules:
253 setuptools_extra_args['zip_safe'] = False
253 setuptools_extra_args['zip_safe'] = False
254 setuptools_extra_args['entry_points'] = {
254 setuptools_extra_args['entry_points'] = {
255 'console_scripts': find_entry_points(),
255 'console_scripts': find_entry_points(),
256 'pygments.lexers': [
256 'pygments.lexers': [
257 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
257 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
258 'ipython = IPython.lib.lexers:IPythonLexer',
258 'ipython = IPython.lib.lexers:IPythonLexer',
259 'ipython3 = IPython.lib.lexers:IPython3Lexer',
259 'ipython3 = IPython.lib.lexers:IPython3Lexer',
260 ],
260 ],
261 }
261 }
262 setup_args['extras_require'] = extras_require
262 setup_args['extras_require'] = extras_require
263 requires = setup_args['install_requires'] = install_requires
263 requires = setup_args['install_requires'] = install_requires
264
264
265 # Script to be run by the windows binary installer after the default setup
265 # Script to be run by the windows binary installer after the default setup
266 # routine, to add shortcuts and similar windows-only things. Windows
266 # routine, to add shortcuts and similar windows-only things. Windows
267 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
267 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
268 # doesn't find them.
268 # doesn't find them.
269 if 'bdist_wininst' in sys.argv:
269 if 'bdist_wininst' in sys.argv:
270 if len(sys.argv) > 2 and \
270 if len(sys.argv) > 2 and \
271 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
271 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
272 print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr)
272 print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr)
273 sys.exit(1)
273 sys.exit(1)
274 setup_args['data_files'].append(
274 setup_args['data_files'].append(
275 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
275 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
276 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
276 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
277 setup_args['options'] = {"bdist_wininst":
277 setup_args['options'] = {"bdist_wininst":
278 {"install_script":
278 {"install_script":
279 "ipython_win_post_install.py"}}
279 "ipython_win_post_install.py"}}
280
280
281 else:
281 else:
282 # scripts has to be a non-empty list, or install_scripts isn't called
282 # scripts has to be a non-empty list, or install_scripts isn't called
283 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
283 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
284
284
285 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
285 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
286
286
287 #---------------------------------------------------------------------------
287 #---------------------------------------------------------------------------
288 # Do the actual setup now
288 # Do the actual setup now
289 #---------------------------------------------------------------------------
289 #---------------------------------------------------------------------------
290
290
291 setup_args.update(setuptools_extra_args)
291 setup_args.update(setuptools_extra_args)
292
292
293
293
294
294
295 def main():
295 def main():
296 setup(**setup_args)
296 setup(**setup_args)
297
297
298 if __name__ == '__main__':
298 if __name__ == '__main__':
299 main()
299 main()
General Comments 0
You need to be logged in to leave comments. Login now