diff --git a/setup2.py b/setup2.py index 0e54f87..d91bdf7 100755 --- a/setup2.py +++ b/setup2.py @@ -61,6 +61,7 @@ from setupbase import ( find_data_files, check_for_dependencies, record_commit_info, + bdist_wininst_options, ) from setupext import setupext @@ -197,27 +198,16 @@ if 'setuptools' in sys.modules: if not setupext.check_for_readline(): if sys.platform == 'darwin': requires.append('readline') - elif sys.platform.startswith('win') and sys.maxsize < 2**32: - # only require pyreadline on 32b Windows, due to 64b bug in pyreadline: - # https://bugs.launchpad.net/pyreadline/+bug/787574 - requires.append('pyreadline') + elif sys.platform.startswith('win') and \ + not 'bdist_wininst' in sys.argv: + # We must avoid listing pyreadline when *building* the binary windows + # installers, because if we do so, then at runtime ipython will fail + # to find a pyreadline that could have been installed without + # setuptools (such as the one from the binary pyreadline installer). + requires.append('pyreadline') else: pass - # do we want to install readline here? - - # Script to be run by the windows binary installer after the default setup - # routine, to add shortcuts and similar windows-only things. Windows - # post-install scripts MUST reside in the scripts/ dir, otherwise distutils - # doesn't find them. - if 'bdist_wininst' in sys.argv: - if len(sys.argv) > 2 and \ - ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): - print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." - sys.exit(1) - setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] - setup_args['options'] = {"bdist_wininst": - {"install_script": - "ipython_win_post_install.py"}} + setup_args.update(bdist_wininst_options()) else: # If we are running without setuptools, call this function which will # check for dependencies an inform the user what is needed. This is @@ -235,9 +225,11 @@ setup_args['package_data'] = package_data setup_args['data_files'] = data_files setup_args.update(setuptools_extra_args) + def main(): setup(**setup_args) cleanup() + if __name__ == '__main__': main() diff --git a/setup3.py b/setup3.py index a7bc9ab..b6f4bf0 100644 --- a/setup3.py +++ b/setup3.py @@ -8,26 +8,16 @@ from setupbase import (setup_args, find_packages, find_package_data, record_commit_info, + bdist_wininst_options, ) setup_args['entry_points'] = find_scripts(True, suffix='3') setup_args['packages'] = find_packages() setup_args['package_data'] = find_package_data() -setup_args['cmdclass'] = {'build_py': record_commit_info('IPython', build_cmd=build_py)} +setup_args['cmdclass'] = {'build_py': + record_commit_info('IPython', build_cmd=build_py)} -# Script to be run by the windows binary installer after the default setup -# routine, to add shortcuts and similar windows-only things. Windows -# post-install scripts MUST reside in the scripts/ dir, otherwise distutils -# doesn't find them. -if 'bdist_wininst' in sys.argv: - if len(sys.argv) > 2 and \ - ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): - print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." - sys.exit(1) - setup_args['scripts'] = [os.path.join('scripts','ipython_win_post_install.py')] - setup_args['options'] = {"bdist_wininst": - {"install_script": - "ipython_win_post_install.py"}} +setup_args.update(bdist_wininst_options()) def main(): setup(use_2to3 = True, **setup_args) diff --git a/setupbase.py b/setupbase.py index b6e700c..4846d82 100644 --- a/setupbase.py +++ b/setupbase.py @@ -358,3 +358,32 @@ def record_commit_info(pkg_dir, build_cmd=build_py): 'commit = "%s"\n' % repo_commit.decode('ascii'), ]) return MyBuildPy + +#----------------------------------------------------------------------------- +# Misc. utilities common to setup2/3 +#----------------------------------------------------------------------------- + +def bdist_wininst_options(): + """Options to setup specific to the creation of Windows binary installer. + """ + + setup_args = {} + + if 'bdist_wininst' not in sys.argv: + return setup_args + + # If we're building a binary Windows installer, a few extra flags are + # needed. Script to be run by the installer after the default setup + # routine, to add shortcuts and similar windows-only things. Windows + # post-install scripts MUST reside in the scripts/ dir, otherwise distutils + # doesn't find them. + if len(sys.argv) > 2 and \ + ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): + print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." + sys.exit(1) + setup_args['scripts'] = [os.path.join('scripts', + 'ipython_win_post_install.py')] + setup_args['options'] = {"bdist_wininst": + {"install_script": + "ipython_win_post_install.py"}} + return setup_args