##// END OF EJS Templates
Merge pull request #8461 from minrk/optional-deps...
Kyle Kelley -
r21382:5a106ac3 merge
parent child Browse files
Show More
@@ -63,9 +63,7 b' from setupbase import ('
63 find_entry_points,
63 find_entry_points,
64 build_scripts_entrypt,
64 build_scripts_entrypt,
65 find_data_files,
65 find_data_files,
66 check_for_readline,
67 git_prebuild,
66 git_prebuild,
68 get_bdist_wheel,
69 install_symlinked,
67 install_symlinked,
70 install_lib_symlink,
68 install_lib_symlink,
71 install_scripts_for_symlink,
69 install_scripts_for_symlink,
@@ -181,8 +179,6 b' setuptools_extra_args = {}'
181
179
182 # setuptools requirements
180 # setuptools requirements
183
181
184 pyzmq = 'pyzmq>=13'
185
186 extras_require = dict(
182 extras_require = dict(
187 parallel = ['ipyparallel'],
183 parallel = ['ipyparallel'],
188 qtconsole = ['qtconsole'],
184 qtconsole = ['qtconsole'],
@@ -194,10 +190,6 b' extras_require = dict('
194 notebook = ['notebook'],
190 notebook = ['notebook'],
195 nbconvert = ['nbconvert'],
191 nbconvert = ['nbconvert'],
196 )
192 )
197
198 if sys.version_info < (3, 3):
199 extras_require['test'].append('mock')
200
201 install_requires = [
193 install_requires = [
202 'decorator',
194 'decorator',
203 'pickleshare',
195 'pickleshare',
@@ -205,16 +197,28 b' install_requires = ['
205 'traitlets',
197 'traitlets',
206 ]
198 ]
207
199
208 # add platform-specific dependencies
200 # Platform-specific dependencies:
209 if sys.platform == 'darwin':
201 # This is the correct way to specify these,
210 install_requires.append('appnope')
202 # but requires pip >= 6. pip < 6 ignores these.
211 if 'bdist_wheel' in sys.argv[1:] or not check_for_readline():
203 extras_require.update({
212 install_requires.append('gnureadline')
204 ':sys_platform != "win32"': ['pexpect'],
213
205 ':sys_platform == "darwin"': ['appnope', 'gnureadline'],
214 if sys.platform.startswith('win'):
206 'terminal:sys_platform == "win32"': ['pyreadline>=2'],
215 extras_require['terminal'].append('pyreadline>=2.0')
207 'test:python_version == "2.7"': ['mock'],
216 else:
208 })
217 install_requires.append('pexpect')
209 # FIXME: re-specify above platform dependencies for pip < 6
210 # These would result in non-portable bdists.
211 if not any(arg.startswith('bdist') for arg in sys.argv):
212 if sys.version_info < (3, 3):
213 extras_require['test'].append('mock')
214
215 if sys.platform == 'darwin':
216 install_requires.extend(['appnope', 'gnureadline'])
217
218 if sys.platform.startswith('win'):
219 extras_require['terminal'].append('pyreadline>=2.0')
220 else:
221 install_requires.append('pexpect')
218
222
219 everything = set()
223 everything = set()
220 for deps in extras_require.values():
224 for deps in extras_require.values():
@@ -222,8 +226,6 b' for deps in extras_require.values():'
222 extras_require['all'] = everything
226 extras_require['all'] = everything
223
227
224 if 'setuptools' in sys.modules:
228 if 'setuptools' in sys.modules:
225 setup_args['cmdclass']['bdist_wheel'] = get_bdist_wheel()
226
227 setuptools_extra_args['zip_safe'] = False
229 setuptools_extra_args['zip_safe'] = False
228 setuptools_extra_args['entry_points'] = {
230 setuptools_extra_args['entry_points'] = {
229 'console_scripts': find_entry_points(),
231 'console_scripts': find_entry_points(),
@@ -409,27 +409,6 b' class install_scripts_for_symlink(install_scripts):'
409 ('skip_build', 'skip_build'),
409 ('skip_build', 'skip_build'),
410 )
410 )
411
411
412 #---------------------------------------------------------------------------
413 # Verify all dependencies
414 #---------------------------------------------------------------------------
415
416 def check_for_readline():
417 """Check for GNU readline"""
418 try:
419 import gnureadline as readline
420 except ImportError:
421 pass
422 else:
423 return True
424 try:
425 import readline
426 except ImportError:
427 return False
428 else:
429 if sys.platform == 'darwin' and 'libedit' in readline.__doc__:
430 print("Ignoring readline linked to libedit", file=sys.stderr)
431 return False
432 return True
433
412
434 #---------------------------------------------------------------------------
413 #---------------------------------------------------------------------------
435 # VCS related
414 # VCS related
@@ -485,70 +464,3 b' def git_prebuild(pkg_dir, build_cmd=build_py):'
485 ])
464 ])
486 return MyBuildPy
465 return MyBuildPy
487
466
488
489
490 #---------------------------------------------------------------------------
491 # bdist related
492 #---------------------------------------------------------------------------
493
494 def get_bdist_wheel():
495 """Construct bdist_wheel command for building wheels
496
497 Constructs py2-none-any tag, instead of py2.7-none-any
498 """
499 class RequiresWheel(Command):
500 description = "Dummy command for missing bdist_wheel"
501 user_options = []
502
503 def initialize_options(self):
504 pass
505
506 def finalize_options(self):
507 pass
508
509 def run(self):
510 print("bdist_wheel requires the wheel package")
511 sys.exit(1)
512
513 if 'setuptools' not in sys.modules:
514 return RequiresWheel
515 else:
516 try:
517 from wheel.bdist_wheel import bdist_wheel, read_pkg_info, write_pkg_info
518 except ImportError:
519 return RequiresWheel
520
521 class bdist_wheel_tag(bdist_wheel):
522
523 def add_requirements(self, metadata_path):
524 """transform platform-dependent requirements"""
525 pkg_info = read_pkg_info(metadata_path)
526 # pkg_info is an email.Message object (?!)
527 # we have to remove the unconditional 'readline' and/or 'pyreadline' entries
528 # and transform them to conditionals
529 requires = pkg_info.get_all('Requires-Dist')
530 del pkg_info['Requires-Dist']
531 def _remove_startswith(lis, prefix):
532 """like list.remove, but with startswith instead of =="""
533 found = False
534 for idx, item in enumerate(lis):
535 if item.startswith(prefix):
536 found = True
537 break
538 if found:
539 lis.pop(idx)
540
541 for pkg in ("gnureadline", "pyreadline", "mock", "terminado", "appnope", "pexpect"):
542 _remove_startswith(requires, pkg)
543 requires.append("gnureadline; sys.platform == 'darwin' and platform.python_implementation == 'CPython'")
544 requires.append("pyreadline (>=2.0); extra == 'terminal' and sys.platform == 'win32' and platform.python_implementation == 'CPython'")
545 requires.append("pyreadline (>=2.0); extra == 'all' and sys.platform == 'win32' and platform.python_implementation == 'CPython'")
546 requires.append("mock; extra == 'test' and python_version < '3.3'")
547 requires.append("appnope; sys.platform == 'darwin'")
548 requires.append("pexpect; sys.platform != 'win32'")
549 for r in requires:
550 pkg_info['Requires-Dist'] = r
551 write_pkg_info(metadata_path, pkg_info)
552
553 return bdist_wheel_tag
554
General Comments 0
You need to be logged in to leave comments. Login now