diff --git a/setup.py b/setup.py index c26ff6f..fd4b36d 100755 --- a/setup.py +++ b/setup.py @@ -59,6 +59,7 @@ from setupbase import ( find_packages, find_package_data, find_scripts, + build_scripts_rename, find_data_files, check_for_dependencies, git_prebuild, @@ -315,7 +316,10 @@ else: # check for dependencies an inform the user what is needed. This is # just to make life easy for users. check_for_dependencies() - setup_args['scripts'] = find_scripts(False, suffix = '3' if PY3 else '') + setup_args['scripts'] = find_scripts(False) + if PY3: + # Rename scripts with '3' suffix + setup_args['cmdclass']['build_scripts'] = build_scripts_rename #--------------------------------------------------------------------------- # Do the actual setup now diff --git a/setupbase.py b/setupbase.py index 7bfdf08..8319f00 100644 --- a/setupbase.py +++ b/setupbase.py @@ -28,6 +28,7 @@ try: except: from ConfigParser import ConfigParser from distutils.command.build_py import build_py +from distutils.command.build_scripts import build_scripts from distutils.cmd import Command from glob import glob from subprocess import call @@ -347,6 +348,19 @@ def find_scripts(entry_points=False, suffix=''): ] return scripts +class build_scripts_rename(build_scripts): + """Use this on Python 3 to rename scripts to ipython3 etc.""" + _suffix = '3' + + def copy_scripts(self): + outfiles, updated_files = super(build_scripts_rename, self).copy_scripts() + new_outfiles = [p + self._suffix for p in outfiles] + updated_files = [p + self._suffix for p in updated_files] + for old, new in zip(outfiles, new_outfiles): + self.move_file(old, new) + return new_outfiles, updated_files + + #--------------------------------------------------------------------------- # Verify all dependencies #---------------------------------------------------------------------------