|
14 | 14 | from distutils.command.build_ext import build_ext |
15 | 15 | from distutils.command.install import install |
16 | 16 | from distutils.command.install_lib import install_lib |
| 17 | +from distutils.command.build_scripts import build_scripts |
17 | 18 | from distutils.spawn import find_executable |
18 | 19 |
|
19 | 20 | # Were we compiled --with-pydebug or with #define Py_DEBUG? |
@@ -1792,6 +1793,25 @@ def set_dir_modes(self, dirname, mode): |
1792 | 1793 | def is_chmod_supported(self): |
1793 | 1794 | return hasattr(os, 'chmod') |
1794 | 1795 |
|
| 1796 | +class PyBuildScripts(build_scripts): |
| 1797 | + def copy_scripts(self): |
| 1798 | + outfiles, updated_files = build_scripts.copy_scripts(self) |
| 1799 | + fullversion = '-{0[0]}.{0[1]}'.format(sys.version_info) |
| 1800 | + minoronly = '.{0[1]}'.format(sys.version_info) |
| 1801 | + newoutfiles = [] |
| 1802 | + newupdated_files = [] |
| 1803 | + for filename in outfiles: |
| 1804 | + if filename.endswith('2to3'): |
| 1805 | + newfilename = filename + fullversion |
| 1806 | + else: |
| 1807 | + newfilename = filename + minoronly |
| 1808 | + log.info('renaming {} to {}'.format(filename, newfilename)) |
| 1809 | + os.rename(filename, newfilename) |
| 1810 | + newoutfiles.append(newfilename) |
| 1811 | + if filename in updated_files: |
| 1812 | + newupdated_files.append(newfilename) |
| 1813 | + return newoutfiles, newupdated_files |
| 1814 | + |
1795 | 1815 | SUMMARY = """ |
1796 | 1816 | Python is an interpreted, interactive, object-oriented programming |
1797 | 1817 | language. It is often compared to Tcl, Perl, Scheme or Java. |
@@ -1837,12 +1857,17 @@ def main(): |
1837 | 1857 | platforms = ["Many"], |
1838 | 1858 |
|
1839 | 1859 | # Build info |
1840 | | - cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall, |
1841 | | - 'install_lib':PyBuildInstallLib}, |
| 1860 | + cmdclass = {'build_ext': PyBuildExt, |
| 1861 | + 'build_scripts': PyBuildScripts, |
| 1862 | + 'install': PyBuildInstall, |
| 1863 | + 'install_lib': PyBuildInstallLib}, |
1842 | 1864 | # The struct module is defined here, because build_ext won't be |
1843 | 1865 | # called unless there's at least one extension module defined. |
1844 | 1866 | ext_modules=[Extension('_struct', ['_struct.c'])], |
1845 | 1867 |
|
| 1868 | + # If you change the scripts installed here, you also need to |
| 1869 | + # check the PyBuildScripts command above, and change the links |
| 1870 | + # created by the bininstall target in Makefile.pre.in |
1846 | 1871 | scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3", |
1847 | 1872 | "Tools/scripts/2to3"] |
1848 | 1873 | ) |
|
0 commit comments