diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2020-07-07 18:03:06 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2020-07-07 18:03:55 -0400 |
| commit | 06d2c56b85c97d0e3cfa278048a8fab43d38684e (patch) | |
| tree | 5ab7f5a4811ceeffd96aa7fa7e4715551db58c7a | |
| parent | e34d6d8b739a8e0edbdfa324bf3607430aa3ff70 (diff) | |
| download | external_python_setuptools-06d2c56b85c97d0e3cfa278048a8fab43d38684e.tar.gz external_python_setuptools-06d2c56b85c97d0e3cfa278048a8fab43d38684e.tar.bz2 external_python_setuptools-06d2c56b85c97d0e3cfa278048a8fab43d38684e.zip | |
http https://sources.debian.org/data/main/p/python3.8/3.8.4~rc1-1/debian/patches/distutils-install-layout.diff | git apply --include 'Lib/distutils/*'
| -rw-r--r-- | command/install.py | 43 | ||||
| -rw-r--r-- | command/install_egg_info.py | 30 | ||||
| -rw-r--r-- | sysconfig.py | 7 | ||||
| -rw-r--r-- | tests/test_bdist_dumb.py | 2 | ||||
| -rw-r--r-- | tests/test_install.py | 4 |
5 files changed, 77 insertions, 9 deletions
diff --git a/command/install.py b/command/install.py index aaa300ef..1067e673 100644 --- a/command/install.py +++ b/command/install.py @@ -35,6 +35,20 @@ INSTALL_SCHEMES = { 'scripts': '$base/bin', 'data' : '$base', }, + 'unix_local': { + 'purelib': '$base/local/lib/python$py_version_short/dist-packages', + 'platlib': '$platbase/local/lib/python$py_version_short/dist-packages', + 'headers': '$base/local/include/python$py_version_short/$dist_name', + 'scripts': '$base/local/bin', + 'data' : '$base/local', + }, + 'deb_system': { + 'purelib': '$base/lib/python3/dist-packages', + 'platlib': '$platbase/lib/python3/dist-packages', + 'headers': '$base/include/python$py_version_short/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', + }, 'unix_home': { 'purelib': '$base/lib/python', 'platlib': '$base/$platlibdir/python', @@ -131,6 +145,9 @@ class install(Command): ('record=', None, "filename in which to record list of installed files"), + + ('install-layout=', None, + "installation layout to choose (known values: deb, unix)"), ] boolean_options = ['compile', 'force', 'skip-build'] @@ -151,6 +168,7 @@ class install(Command): self.exec_prefix = None self.home = None self.user = 0 + self.prefix_option = None # These select only the installation base; it's up to the user to # specify the installation scheme (currently, that means supplying @@ -172,6 +190,9 @@ class install(Command): self.install_userbase = USER_BASE self.install_usersite = USER_SITE + # enable custom installation, known values: deb + self.install_layout = None + self.compile = None self.optimize = None @@ -414,6 +435,7 @@ class install(Command): self.install_base = self.install_platbase = self.home self.select_scheme("unix_home") else: + self.prefix_option = self.prefix if self.prefix is None: if self.exec_prefix is not None: raise DistutilsOptionError( @@ -428,7 +450,26 @@ class install(Command): self.install_base = self.prefix self.install_platbase = self.exec_prefix - self.select_scheme("unix_prefix") + if self.install_layout: + if self.install_layout.lower() in ['deb']: + self.select_scheme("deb_system") + elif self.install_layout.lower() in ['unix']: + self.select_scheme("unix_prefix") + else: + raise DistutilsOptionError( + "unknown value for --install-layout") + elif ((self.prefix_option and + os.path.normpath(self.prefix) != '/usr/local') + or sys.base_prefix != sys.prefix + or 'PYTHONUSERBASE' in os.environ + or 'VIRTUAL_ENV' in os.environ + or 'real_prefix' in sys.__dict__): + self.select_scheme("unix_prefix") + else: + if os.path.normpath(self.prefix) == '/usr/local': + self.prefix = self.exec_prefix = '/usr' + self.install_base = self.install_platbase = '/usr' + self.select_scheme("unix_local") def finalize_other(self): """Finalizes options for non-posix platforms""" diff --git a/command/install_egg_info.py b/command/install_egg_info.py index 0ddc7367..0a71b610 100644 --- a/command/install_egg_info.py +++ b/command/install_egg_info.py @@ -14,18 +14,38 @@ class install_egg_info(Command): description = "Install package's PKG-INFO metadata as an .egg-info file" user_options = [ ('install-dir=', 'd', "directory to install to"), + ('install-layout', None, "custom installation layout"), ] def initialize_options(self): self.install_dir = None + self.install_layout = None + self.prefix_option = None def finalize_options(self): self.set_undefined_options('install_lib',('install_dir','install_dir')) - basename = "%s-%s-py%d.%d.egg-info" % ( - to_filename(safe_name(self.distribution.get_name())), - to_filename(safe_version(self.distribution.get_version())), - *sys.version_info[:2] - ) + self.set_undefined_options('install',('install_layout','install_layout')) + self.set_undefined_options('install',('prefix_option','prefix_option')) + if self.install_layout: + if not self.install_layout.lower() in ['deb', 'unix']: + raise DistutilsOptionError( + "unknown value for --install-layout") + no_pyver = (self.install_layout.lower() == 'deb') + elif self.prefix_option: + no_pyver = False + else: + no_pyver = True + if no_pyver: + basename = "%s-%s.egg-info" % ( + to_filename(safe_name(self.distribution.get_name())), + to_filename(safe_version(self.distribution.get_version())) + ) + else: + basename = "%s-%s-py%d.%d.egg-info" % ( + to_filename(safe_name(self.distribution.get_name())), + to_filename(safe_version(self.distribution.get_version())), + *sys.version_info[:2] + ) self.target = os.path.join(self.install_dir, basename) self.outputs = [self.target] diff --git a/sysconfig.py b/sysconfig.py index 37feae5d..6edad79a 100644 --- a/sysconfig.py +++ b/sysconfig.py @@ -138,6 +138,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): If 'prefix' is supplied, use it instead of sys.base_prefix or sys.base_exec_prefix -- i.e., ignore 'plat_specific'. """ + is_default_prefix = not prefix or os.path.normpath(prefix) in ('/usr', '/usr/local') if prefix is None: if standard_lib: prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX @@ -156,6 +157,12 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): "python" + get_python_version()) if standard_lib: return libpython + elif (is_default_prefix and + 'PYTHONUSERBASE' not in os.environ and + 'VIRTUAL_ENV' not in os.environ and + 'real_prefix' not in sys.__dict__ and + sys.prefix == sys.base_prefix): + return os.path.join(prefix, "lib", "python3", "dist-packages") else: return os.path.join(libpython, "site-packages") elif os.name == "nt": diff --git a/tests/test_bdist_dumb.py b/tests/test_bdist_dumb.py index 01a233bc..f99dec53 100644 --- a/tests/test_bdist_dumb.py +++ b/tests/test_bdist_dumb.py @@ -85,7 +85,7 @@ class BuildDumbTestCase(support.TempdirManager, fp.close() contents = sorted(filter(None, map(os.path.basename, contents))) - wanted = ['foo-0.1-py%s.%s.egg-info' % sys.version_info[:2], 'foo.py'] + wanted = ['foo-0.1.egg-info', 'foo.py'] if not sys.dont_write_bytecode: wanted.append('foo.%s.pyc' % sys.implementation.cache_tag) self.assertEqual(contents, sorted(wanted)) diff --git a/tests/test_install.py b/tests/test_install.py index 51c80e04..2ada481f 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -194,7 +194,7 @@ class InstallTestCase(support.TempdirManager, found = [os.path.basename(line) for line in content.splitlines()] expected = ['hello.py', 'hello.%s.pyc' % sys.implementation.cache_tag, 'sayhi', - 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] + 'UNKNOWN-0.0.0.egg-info'] self.assertEqual(found, expected) def test_record_extensions(self): @@ -227,7 +227,7 @@ class InstallTestCase(support.TempdirManager, found = [os.path.basename(line) for line in content.splitlines()] expected = [_make_ext_name('xx'), - 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] + 'UNKNOWN-0.0.0.egg-info'] self.assertEqual(found, expected) def test_debug_mode(self): |
