summaryrefslogtreecommitdiff
path: root/distutils
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-01-30 13:15:20 -0500
committerGitHub <noreply@github.com>2022-01-30 13:15:20 -0500
commitb53a824ec34b75d8f267f9ec8bf152bfea2e3edb (patch)
treeb9fe12535d65866999986e5023f73b28de7184e3 /distutils
parent4471eeeb8510cb7de367219ad50d8221735dc701 (diff)
parent917046dc70da8c6c5ba87571b0864826085e3659 (diff)
downloadpython-setuptools-git-b53a824ec34b75d8f267f9ec8bf152bfea2e3edb.tar.gz
Merge pull request #113 from zooba/issue112
Fixes #112 install command doesn't use platform in nt_user scheme
Diffstat (limited to 'distutils')
-rw-r--r--distutils/command/install.py12
-rw-r--r--distutils/tests/test_install.py15
2 files changed, 23 insertions, 4 deletions
diff --git a/distutils/command/install.py b/distutils/command/install.py
index 511938f4..9fe65913 100644
--- a/distutils/command/install.py
+++ b/distutils/command/install.py
@@ -68,8 +68,8 @@ if HAS_USER_SITE:
INSTALL_SCHEMES['nt_user'] = {
'purelib': '{usersite}',
'platlib': '{usersite}',
- 'headers': '{userbase}/{implementation}{py_version_nodot}/Include/{dist_name}',
- 'scripts': '{userbase}/{implementation}{py_version_nodot}/Scripts',
+ 'headers': '{userbase}/{implementation}{py_version_nodot_plat}/Include/{dist_name}',
+ 'scripts': '{userbase}/{implementation}{py_version_nodot_plat}/Scripts',
'data' : '{userbase}',
}
@@ -412,12 +412,18 @@ class install(Command):
'implementation': _get_implementation(),
}
+ # vars for compatibility on older Pythons
+ compat_vars = dict(
+ # Python 3.9 and earlier
+ py_version_nodot_plat=getattr(sys, 'winver', '').replace('.', ''),
+ )
+
if HAS_USER_SITE:
local_vars['userbase'] = self.install_userbase
local_vars['usersite'] = self.install_usersite
self.config_vars = _collections.DictStack(
- [sysconfig.get_config_vars(), local_vars])
+ [compat_vars, sysconfig.get_config_vars(), local_vars])
self.expand_basedirs()
diff --git a/distutils/tests/test_install.py b/distutils/tests/test_install.py
index 75770b05..5dbc06b0 100644
--- a/distutils/tests/test_install.py
+++ b/distutils/tests/test_install.py
@@ -81,7 +81,9 @@ class InstallTestCase(support.TempdirManager,
install_module.USER_SITE = self.user_site
def _expanduser(path):
- return self.tmpdir
+ if path.startswith('~'):
+ return os.path.normpath(self.tmpdir + path[1:])
+ return path
self.old_expand = os.path.expanduser
os.path.expanduser = _expanduser
@@ -122,6 +124,17 @@ class InstallTestCase(support.TempdirManager,
self.assertIn('userbase', cmd.config_vars)
self.assertIn('usersite', cmd.config_vars)
+ actual_headers = os.path.relpath(cmd.install_headers, self.user_base)
+ if os.name == 'nt':
+ site_path = os.path.relpath(
+ os.path.dirname(self.old_user_site), self.old_user_base)
+ include = os.path.join(site_path, 'Include')
+ else:
+ include = sysconfig.get_python_inc(0, '')
+ expect_headers = os.path.join(include, 'xx')
+
+ self.assertEqual(os.path.normcase(actual_headers), os.path.normcase(expect_headers))
+
def test_handle_extra_path(self):
dist = Distribution({'name': 'xx', 'extra_path': 'path,dirs'})
cmd = install(dist)