Skip to content

[3.11] gh-103224: Resolve paths properly in test_sysconfig (GH-103292) #115101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,21 @@ def test_posix_venv_scheme(self):
'python%d.%d' % sys.version_info[:2],
'site-packages')

# Resolve the paths in prefix
binpath = os.path.join(sys.prefix, binpath)
incpath = os.path.join(sys.prefix, incpath)
libpath = os.path.join(sys.prefix, libpath)
# Resolve the paths in an imaginary venv/ directory
binpath = os.path.join('venv', binpath)
incpath = os.path.join('venv', incpath)
libpath = os.path.join('venv', libpath)

self.assertEqual(binpath, sysconfig.get_path('scripts', scheme='posix_venv'))
self.assertEqual(libpath, sysconfig.get_path('purelib', scheme='posix_venv'))
# Mimic the venv module, set all bases to the venv directory
bases = ('base', 'platbase', 'installed_base', 'installed_platbase')
vars = {base: 'venv' for base in bases}

self.assertEqual(binpath, sysconfig.get_path('scripts', scheme='posix_venv', vars=vars))
self.assertEqual(libpath, sysconfig.get_path('purelib', scheme='posix_venv', vars=vars))

# The include directory on POSIX isn't exactly the same as before,
# but it is "within"
sysconfig_includedir = sysconfig.get_path('include', scheme='posix_venv')
sysconfig_includedir = sysconfig.get_path('include', scheme='posix_venv', vars=vars)
self.assertTrue(sysconfig_includedir.startswith(incpath + os.sep))

def test_nt_venv_scheme(self):
Expand All @@ -170,14 +174,19 @@ def test_nt_venv_scheme(self):
incpath = 'Include'
libpath = os.path.join('Lib', 'site-packages')

# Resolve the paths in prefix
binpath = os.path.join(sys.prefix, binpath)
incpath = os.path.join(sys.prefix, incpath)
libpath = os.path.join(sys.prefix, libpath)
# Resolve the paths in an imaginary venv\ directory
venv = 'venv'
binpath = os.path.join(venv, binpath)
incpath = os.path.join(venv, incpath)
libpath = os.path.join(venv, libpath)

# Mimic the venv module, set all bases to the venv directory
bases = ('base', 'platbase', 'installed_base', 'installed_platbase')
vars = {base: 'venv' for base in bases}

self.assertEqual(binpath, sysconfig.get_path('scripts', scheme='nt_venv'))
self.assertEqual(incpath, sysconfig.get_path('include', scheme='nt_venv'))
self.assertEqual(libpath, sysconfig.get_path('purelib', scheme='nt_venv'))
self.assertEqual(binpath, sysconfig.get_path('scripts', scheme='nt_venv', vars=vars))
self.assertEqual(incpath, sysconfig.get_path('include', scheme='nt_venv', vars=vars))
self.assertEqual(libpath, sysconfig.get_path('purelib', scheme='nt_venv', vars=vars))

def test_venv_scheme(self):
if sys.platform == 'win32':
Expand Down