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

Resolve symlinks when looking for the python interpreter #1979

Conversation

ericriff
Copy link

@ericriff ericriff commented Oct 12, 2020

This makes the symlink point to the actual python exec, i.e. python3.6 instead of plain python3.
By doing this we ensure that the environment will survive a change in the default python3 version of the host system,
which can be caused by update-alternatives, an upgrade of the OS, etc.

This addresses 1974

Thanks for contributing, make sure you address all the checklists (for details on how see

development documentation)!

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

@ericriff
Copy link
Author

@gaborbernat
I managed to get the symlinks resolved by replacing this abspath call with realpath. To be honest I'm not sure if this is a fix or a hack or the ramifications that this change might introduce.
But after this change virtualenv resolves the python3 symlink.

$virtualenv ~/delme/.venv            
created virtual environment CPython3.6.12.final.0-64 in 116ms
  creator CPython3Posix(dest=/home/eric/delme/.venv, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/eric/.local/share/virtualenv)
    added seed packages: pip==20.2.3, setuptools==50.3.0, wheel==0.35.1
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
$ tree ~/delme/.venv/bin
/home/eric/delme/.venv/bin
├── activate
├── activate.csh
├── activate.fish
├── activate.ps1
├── activate_this.py
├── activate.xsh
├── easy_install
├── easy_install3
├── easy_install-3.6
├── easy_install3.6
├── pip
├── pip3
├── pip-3.6
├── pip3.6
├── python -> /usr/bin/python3.6
├── python3 -> python
├── python3.6 -> python
├── wheel
├── wheel3
├── wheel-3.6
└── wheel3.6

@codecov
Copy link

codecov bot commented Oct 12, 2020

Codecov Report

Merging #1979 into main will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1979   +/-   ##
=======================================
  Coverage   94.13%   94.13%           
=======================================
  Files          86       86           
  Lines        4266     4266           
=======================================
  Hits         4016     4016           
  Misses        250      250           
Flag Coverage Δ
#tests 94.13% <100.00%> (ø)

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

Impacted Files Coverage Δ
src/virtualenv/discovery/py_info.py 95.06% <100.00%> (ø)

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 567d64b...95daf2a. Read the comment docs.

@ericriff ericriff force-pushed the eriff/resolve-symlinks-for-python-interptrter branch from b870ae6 to cf18b25 Compare October 12, 2020 22:49
This makes the symlink point to the actual python exec, i.e. python3.6 instead of plain python3.
By doing this we ensure that the environment will survive a change in the default python3 version of the host system,
which can be caused by update-alternatives, an upgrade of the OS, etc.
@ericriff ericriff force-pushed the eriff/resolve-symlinks-for-python-interptrter branch from cf18b25 to 95daf2a Compare October 12, 2020 22:54
Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

This file should not be touched. If we do need to resolve paths we should do it within the creators, not here.

@ericriff ericriff marked this pull request as draft October 12, 2020 23:14
@gaborbernat
Copy link
Contributor

Closing due to inactivity will re-open if you pick it up again.

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.

2 participants