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

Skip directories when symlinking libraries for PyPy3 #2204

Closed
wants to merge 1 commit into from

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Oct 2, 2021

The PyPy3 logic creates symlinks for all files from the library
directory existing alongside the PyPy executable. This is meant
to ensure that the bundled libraries to which PyPy is linked can also
be found from inside the virtualenv. However, this logic also symlinks
all directories which is unnecessary and causes library directory
collisions with the new install layout. Change to logic to symlink
non-directories only.

A similar fix has been applied to the internal venv module in PyPy3.8:
https://foss.heptapod.net/pypy/pypy/-/commit/713b2af9abd2b9453e12c60143e17431a1aefb33

Fixes #2182

  • ran the linter to address style issues (tox -e fix_lint)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix (n/a?)
  • added news fragment in docs/changelog folder
  • updated/extended the documentation (n/a)

The PyPy3 logic creates symlinks for all files from the library
directory existing alongside the PyPy executable.  This is meant
to ensure that the bundled libraries to which PyPy is linked can also
be found from inside the virtualenv.  However, this logic also symlinks
all directories which is unnecessary and causes library directory
collisions with the new install layout.  Change to logic to symlink
non-directories only.

A similar fix has been applied to the internal venv module in PyPy3.8:
https://foss.heptapod.net/pypy/pypy/-/commit/713b2af9abd2b9453e12c60143e17431a1aefb33

Fixes pypa#2182
@codecov
Copy link

codecov bot commented Oct 2, 2021

Codecov Report

Merging #2204 (6cc2dde) into main (5d14665) will decrease coverage by 4.51%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2204      +/-   ##
==========================================
- Coverage   93.38%   88.87%   -4.52%     
==========================================
  Files          88       88              
  Lines        4402     4404       +2     
==========================================
- Hits         4111     3914     -197     
- Misses        291      490     +199     
Flag Coverage Δ
tests 88.87% <0.00%> (-4.52%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ualenv/create/via_global_ref/builtin/pypy/pypy3.py 63.63% <0.00%> (-36.37%) ⬇️
src/virtualenv/util/subprocess/_win_subprocess.py 0.00% <0.00%> (-95.39%) ⬇️
src/virtualenv/util/path/_pathlib/via_os_path.py 0.00% <0.00%> (-91.51%) ⬇️
.../create/via_global_ref/builtin/cpython/cpython3.py 78.68% <0.00%> (-16.40%) ⬇️
src/virtualenv/util/subprocess/__init__.py 88.88% <0.00%> (-11.12%) ⬇️
src/virtualenv/util/path/_pathlib/__init__.py 88.88% <0.00%> (-11.12%) ⬇️
src/virtualenv/util/path/_sync.py 86.20% <0.00%> (-6.90%) ⬇️
...env/seed/embed/via_app_data/pip_install/symlink.py 86.36% <0.00%> (-6.82%) ⬇️
src/virtualenv/info.py 95.12% <0.00%> (-4.88%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d14665...6cc2dde. Read the comment docs.

@@ -44,6 +44,8 @@ def sources(cls, interpreter):
host_lib = Path(interpreter.system_prefix) / "lib"
if host_lib.exists() and host_lib.is_dir():
for path in host_lib.iterdir():
if path.is_dir():
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Once upon a time we needed to copy any shared object files in base/lib but these days we use RPATH in the libpypy3-c.so to find the lib dir, and that main shared object is now symlinked.

So in short, iterating over base/lib and copying the files is no longer needed, so lines 45-48 can be deleted. That means this whole method can be deleted.

Copy link
Contributor

Choose a reason for hiding this comment

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

... as long as os.symlink is available where the "portable PyPy" downloads (the ones from https://www.pypy.org/download.html) are used. Linux and brew build PyPy against system libraries, so they do not need the shared objects in the base/lib directory .

Copy link
Contributor

Choose a reason for hiding this comment

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

@mattip for 3.6 we still need this, not? What about Windows?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, 3.6 also uses symlinks and RPATH. Windows never needed this.

@mgorny could you change line 30, 31 to use pypy instead of python ?

@mattip
Copy link
Contributor

mattip commented Oct 2, 2021

I validated this (both the minimal change first suggested and my more extensive suggested change) against the upcoming PyPy3.8 rc1 and against PyPy 3.7. I don't think the failures are connected to this change.

@mattip
Copy link
Contributor

mattip commented Oct 4, 2021

I tried to emit a PR to update this from mattip/virtualenv but for some reason could not make a PR to mgorny/virtualenv. While this version is fine, I think removing the whole source class method is cleaner.

@mgorny
Copy link
Contributor Author

mgorny commented Oct 4, 2021

I tried to emit a PR to update this from mattip/virtualenv but for some reason could not make a PR to mgorny/virtualenv. While this version is fine, I think removing the whole source class method is cleaner.

I'll just close my PR and please submit yours instead ;-).

@mgorny mgorny closed this Oct 4, 2021
@mattip mattip mentioned this pull request Oct 4, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect (broken) virtualenv layout with pypy3.8's new layout
3 participants