Skip to content

Commit cf465bd

Browse files
authored
Merge pull request RustPython#4924 from itsankitkp/fix-sys-path-for-venv
Ensure correct site packages are visible to rustpython
2 parents 05442bc + aad1d84 commit cf465bd

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ jobs:
308308
run: |
309309
target/release/rustpython -m ensurepip
310310
target/release/rustpython -c "import pip"
311+
- if: runner.os != 'Windows'
312+
name: Check if pip inside venv is functional
313+
run: |
314+
target/release/rustpython -m venv testvenv
315+
testvenv/bin/rustpython -m pip install wheel
311316
- name: Check whats_left is not broken
312317
run: python -I whats_left.py
313318

Lib/site.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ def joinuser(*args):
275275

276276
if os.name == "nt":
277277
base = os.environ.get("APPDATA") or "~"
278-
return joinuser(base, "Python")
278+
# XXX: RUSTPYTHON; please keep this change for site-packages
279+
return joinuser(base, "RustPython")
279280

280281
if sys.platform == "darwin" and sys._framework:
281282
return joinuser("~", "Library", sys._framework,
@@ -368,7 +369,8 @@ def getsitepackages(prefixes=None):
368369

369370
for libdir in libdirs:
370371
path = os.path.join(prefix, libdir,
371-
"python%d.%d" % sys.version_info[:2],
372+
# XXX: RUSTPYTHON; please keep this change for site-packages
373+
"rustpython%d.%d" % sys.version_info[:2],
372374
"site-packages")
373375
sitepackages.append(path)
374376
else:

Lib/sysconfig.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# XXX: RUSTPYTHON; Trick to make sysconfig work as RustPython
2+
exec(r'''
13
"""Access to Python's configuration information."""
24
35
import os
@@ -851,10 +853,6 @@ def _main():
851853
print()
852854
_print_dict('Variables', get_config_vars())
853855
854-
# XXX RUSTPYTHON: replace python with rustpython in all these paths
855-
for group in _INSTALL_SCHEMES.values():
856-
for key in group.keys():
857-
group[key] = group[key].replace("Python", "RustPython").replace("python", "rustpython")
858-
859856
if __name__ == '__main__':
860857
_main()
858+
'''.replace("Python", "RustPython").replace("/python", "/rustpython"))

Lib/test/test_site.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,15 @@ def test_getsitepackages(self):
288288
if sys.platlibdir != "lib":
289289
self.assertEqual(len(dirs), 2)
290290
wanted = os.path.join('xoxo', sys.platlibdir,
291-
'python%d.%d' % sys.version_info[:2],
291+
# XXX: RUSTPYTHON
292+
'rustpython%d.%d' % sys.version_info[:2],
292293
'site-packages')
293294
self.assertEqual(dirs[0], wanted)
294295
else:
295296
self.assertEqual(len(dirs), 1)
296297
wanted = os.path.join('xoxo', 'lib',
297-
'python%d.%d' % sys.version_info[:2],
298+
# XXX: RUSTPYTHON
299+
'rustpython%d.%d' % sys.version_info[:2],
298300
'site-packages')
299301
self.assertEqual(dirs[-1], wanted)
300302
else:

0 commit comments

Comments
 (0)