Skip to content
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

Also add executables for pythonX.X under pypy #1615

Merged
merged 3 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/changelog/1612.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Also create ``pythonX.X`` executables when creating pypy virtualenvs - by :user:`asottile`
1 change: 1 addition & 0 deletions docs/changelog/1614.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix losing of libpypy-c.so when the pypy executable is a symlink - by :user:`asottile`
3 changes: 2 additions & 1 deletion src/virtualenv/create/via_global_ref/builtin/pypy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def exe_names(cls, interpreter):
cls.exe_stem(),
"python",
"python{}".format(interpreter.version_info.major),
"python{}.{}".format(*interpreter.version_info),
}

@classmethod
Expand All @@ -40,7 +41,7 @@ def sources(cls, interpreter):
@classmethod
def _add_shared_libs(cls, interpreter):
# https://bitbucket.org/pypy/pypy/issue/1922/future-proofing-virtualenv
python_dir = Path(interpreter.system_executable).parent
python_dir = Path(interpreter.system_executable).resolve().parent
for libname in cls._shared_libs():
src = python_dir / libname
if src.exists():
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/create/test_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ def list_to_str(iterable):
if sys.platform == "win32":
exes = ("python.exe",)
else:
# TODO: also test "python{}.{}" once fixed
exes = ("python", "python{}".format(sys.version_info[0]))
exes = ("python", "python{}".format(*sys.version_info), "python{}.{}".format(*sys.version_info))
# pypy3<=7.3: https://bitbucket.org/pypy/pypy/pull-requests/697
if IS_PYPY and CURRENT.pypy_version_info[:3] <= [7, 3, 0] and creator == "venv":
exes = exes[:-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is correct. On CPython, the actual exe (what is at the base of all the symlinks) is python/path/python3.6, on PyPy it is pypy/path/pypy3. Then venv copies that base exe and creates aliases for newpath/bin/python and newpath/bin/python3. So the test should be something like

if IS_PYPY:
    exename = f'pypy{sys.version_info.major}'
else:
    exename = f'python{sys.version_info.major}.{sys.version_info.minor}'
exes = ("python", f'pypy{sys.version_info.major}', exename)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattip the fact that the base is python3.6 is just a matter of luck; of under what name we discover the python. It well could be any of the python, python3 or python3.6 depending on how we discover it on the path. How it's exposed at root level from should not affect how the virtualenv makes it available 👍

for exe in exes:
exe_path = result.creator.bin_dir / exe
assert exe_path.exists()
Expand Down