Skip to content

Commit

Permalink
Merge pull request #113 from zooba/issue112
Browse files Browse the repository at this point in the history
Fixes #112 install command doesn't use platform in nt_user scheme
  • Loading branch information
jaraco authored Jan 30, 2022
2 parents 4471eee + 917046d commit b53a824
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 9 additions & 3 deletions distutils/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
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}',
}

Expand Down Expand Up @@ -412,12 +412,18 @@ def finalize_options(self):
'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()

Expand Down
15 changes: 14 additions & 1 deletion distutils/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def test_user_site(self):
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

Expand Down Expand Up @@ -122,6 +124,17 @@ def cleanup():
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)
Expand Down

0 comments on commit b53a824

Please sign in to comment.