Skip to content

Commit b53a824

Browse files
authored
Merge pull request #113 from zooba/issue112
Fixes #112 install command doesn't use platform in nt_user scheme
2 parents 4471eee + 917046d commit b53a824

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

distutils/command/install.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
INSTALL_SCHEMES['nt_user'] = {
6969
'purelib': '{usersite}',
7070
'platlib': '{usersite}',
71-
'headers': '{userbase}/{implementation}{py_version_nodot}/Include/{dist_name}',
72-
'scripts': '{userbase}/{implementation}{py_version_nodot}/Scripts',
71+
'headers': '{userbase}/{implementation}{py_version_nodot_plat}/Include/{dist_name}',
72+
'scripts': '{userbase}/{implementation}{py_version_nodot_plat}/Scripts',
7373
'data' : '{userbase}',
7474
}
7575

@@ -412,12 +412,18 @@ def finalize_options(self):
412412
'implementation': _get_implementation(),
413413
}
414414

415+
# vars for compatibility on older Pythons
416+
compat_vars = dict(
417+
# Python 3.9 and earlier
418+
py_version_nodot_plat=getattr(sys, 'winver', '').replace('.', ''),
419+
)
420+
415421
if HAS_USER_SITE:
416422
local_vars['userbase'] = self.install_userbase
417423
local_vars['usersite'] = self.install_usersite
418424

419425
self.config_vars = _collections.DictStack(
420-
[sysconfig.get_config_vars(), local_vars])
426+
[compat_vars, sysconfig.get_config_vars(), local_vars])
421427

422428
self.expand_basedirs()
423429

distutils/tests/test_install.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def test_user_site(self):
8181
install_module.USER_SITE = self.user_site
8282

8383
def _expanduser(path):
84-
return self.tmpdir
84+
if path.startswith('~'):
85+
return os.path.normpath(self.tmpdir + path[1:])
86+
return path
8587
self.old_expand = os.path.expanduser
8688
os.path.expanduser = _expanduser
8789

@@ -122,6 +124,17 @@ def cleanup():
122124
self.assertIn('userbase', cmd.config_vars)
123125
self.assertIn('usersite', cmd.config_vars)
124126

127+
actual_headers = os.path.relpath(cmd.install_headers, self.user_base)
128+
if os.name == 'nt':
129+
site_path = os.path.relpath(
130+
os.path.dirname(self.old_user_site), self.old_user_base)
131+
include = os.path.join(site_path, 'Include')
132+
else:
133+
include = sysconfig.get_python_inc(0, '')
134+
expect_headers = os.path.join(include, 'xx')
135+
136+
self.assertEqual(os.path.normcase(actual_headers), os.path.normcase(expect_headers))
137+
125138
def test_handle_extra_path(self):
126139
dist = Distribution({'name': 'xx', 'extra_path': 'path,dirs'})
127140
cmd = install(dist)

0 commit comments

Comments
 (0)