diff --git a/setup.py b/setup.py index 3aa6960..dd0e372 100755 --- a/setup.py +++ b/setup.py @@ -63,9 +63,7 @@ from setupbase import ( find_entry_points, build_scripts_entrypt, find_data_files, - check_for_readline, git_prebuild, - get_bdist_wheel, install_symlinked, install_lib_symlink, install_scripts_for_symlink, @@ -181,8 +179,6 @@ setuptools_extra_args = {} # setuptools requirements -pyzmq = 'pyzmq>=13' - extras_require = dict( parallel = ['ipyparallel'], qtconsole = ['qtconsole'], @@ -194,10 +190,6 @@ extras_require = dict( notebook = ['notebook'], nbconvert = ['nbconvert'], ) - -if sys.version_info < (3, 3): - extras_require['test'].append('mock') - install_requires = [ 'decorator', 'pickleshare', @@ -205,16 +197,28 @@ install_requires = [ 'traitlets', ] -# add platform-specific dependencies -if sys.platform == 'darwin': - install_requires.append('appnope') - if 'bdist_wheel' in sys.argv[1:] or not check_for_readline(): - install_requires.append('gnureadline') - -if sys.platform.startswith('win'): - extras_require['terminal'].append('pyreadline>=2.0') -else: - install_requires.append('pexpect') +# Platform-specific dependencies: +# This is the correct way to specify these, +# but requires pip >= 6. pip < 6 ignores these. +extras_require.update({ + ':sys_platform != "win32"': ['pexpect'], + ':sys_platform == "darwin"': ['appnope', 'gnureadline'], + 'terminal:sys_platform == "win32"': ['pyreadline>=2'], + 'test:python_version == "2.7"': ['mock'], +}) +# 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.version_info < (3, 3): + extras_require['test'].append('mock') + + if sys.platform == 'darwin': + install_requires.extend(['appnope', 'gnureadline']) + + if sys.platform.startswith('win'): + extras_require['terminal'].append('pyreadline>=2.0') + else: + install_requires.append('pexpect') everything = set() for deps in extras_require.values(): @@ -222,8 +226,6 @@ for deps in extras_require.values(): extras_require['all'] = everything if 'setuptools' in sys.modules: - setup_args['cmdclass']['bdist_wheel'] = get_bdist_wheel() - setuptools_extra_args['zip_safe'] = False setuptools_extra_args['entry_points'] = { 'console_scripts': find_entry_points(), diff --git a/setupbase.py b/setupbase.py index d5b7144..6ee34cf 100644 --- a/setupbase.py +++ b/setupbase.py @@ -409,27 +409,6 @@ class install_scripts_for_symlink(install_scripts): ('skip_build', 'skip_build'), ) -#--------------------------------------------------------------------------- -# Verify all dependencies -#--------------------------------------------------------------------------- - -def check_for_readline(): - """Check for GNU readline""" - try: - import gnureadline as readline - except ImportError: - pass - else: - return True - try: - import readline - except ImportError: - return False - else: - if sys.platform == 'darwin' and 'libedit' in readline.__doc__: - print("Ignoring readline linked to libedit", file=sys.stderr) - return False - return True #--------------------------------------------------------------------------- # VCS related @@ -485,70 +464,3 @@ def git_prebuild(pkg_dir, build_cmd=build_py): ]) return MyBuildPy - - -#--------------------------------------------------------------------------- -# bdist related -#--------------------------------------------------------------------------- - -def get_bdist_wheel(): - """Construct bdist_wheel command for building wheels - - Constructs py2-none-any tag, instead of py2.7-none-any - """ - class RequiresWheel(Command): - description = "Dummy command for missing bdist_wheel" - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - print("bdist_wheel requires the wheel package") - sys.exit(1) - - if 'setuptools' not in sys.modules: - return RequiresWheel - else: - try: - from wheel.bdist_wheel import bdist_wheel, read_pkg_info, write_pkg_info - except ImportError: - return RequiresWheel - - class bdist_wheel_tag(bdist_wheel): - - def add_requirements(self, metadata_path): - """transform platform-dependent requirements""" - pkg_info = read_pkg_info(metadata_path) - # pkg_info is an email.Message object (?!) - # we have to remove the unconditional 'readline' and/or 'pyreadline' entries - # and transform them to conditionals - requires = pkg_info.get_all('Requires-Dist') - del pkg_info['Requires-Dist'] - def _remove_startswith(lis, prefix): - """like list.remove, but with startswith instead of ==""" - found = False - for idx, item in enumerate(lis): - if item.startswith(prefix): - found = True - break - if found: - lis.pop(idx) - - for pkg in ("gnureadline", "pyreadline", "mock", "terminado", "appnope", "pexpect"): - _remove_startswith(requires, pkg) - requires.append("gnureadline; sys.platform == 'darwin' and platform.python_implementation == 'CPython'") - requires.append("pyreadline (>=2.0); extra == 'terminal' and sys.platform == 'win32' and platform.python_implementation == 'CPython'") - requires.append("pyreadline (>=2.0); extra == 'all' and sys.platform == 'win32' and platform.python_implementation == 'CPython'") - requires.append("mock; extra == 'test' and python_version < '3.3'") - requires.append("appnope; sys.platform == 'darwin'") - requires.append("pexpect; sys.platform != 'win32'") - for r in requires: - pkg_info['Requires-Dist'] = r - write_pkg_info(metadata_path, pkg_info) - - return bdist_wheel_tag -