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

Fix provisioning from pyvenv interpreter #1452

Merged
merged 1 commit into from
Nov 11, 2019

Conversation

Kentzo
Copy link

@Kentzo Kentzo commented Nov 6, 2019

The bug is related to #148.

When the original interpreter [0] tox is called with is actually a pyvenv
it will set the __PYVENV_LAUNCHER__ environment variable the path of pyvenv
interpreter.

If tox configuration specifies requires and the requirements are not
satifsfied by [0], tox will create an intermediate virtual environment [1].

After setting up [1] tox will delegate the original call to it by spawning
a new [1] interpreter with the list of arguments identical to [0].

It would also pass the value of __PYVENV_LAUNCHER__ if present. This in turn
causes sys.executable to resolve to [0] instead of [1] therefore ignoring all
modifications including installed requirements.

The fix is to make sure that when [0] spawns [1], __PYVENV_LAUNCHER__ is removed
from the environment.

Contribution checklist:

(also see CONTRIBUTING.rst for details)

  • wrote descriptive pull request text
  • added/updated test(s)
  • updated/extended the documentation
  • added relevant issue keyword
    in message body
  • added news fragment in changelog folder
    • fragment name: <issue number>.<type>.rst for example (588.bugfix.rst)
    • <type> is must be one of bugfix, feature, deprecation,breaking, doc, misc
    • if PR has no issue: consider creating one first or change it to the PR number after creating the PR
    • "sign" fragment with "by :user:<your username>"
    • please use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files - by :user:superuser."
    • also see examples
  • added yourself to CONTRIBUTORS (preserving alphabetical order)

When the original interpreter [0] tox is called with is actually a pyvenv
it will set the `__PYVENV_LAUNCHER__` environment variable to the path of
pyvenv interpreter.

If tox configuration specifies `requires` and the requirements are not
satifsfied by [0], tox will create an intermediate virtual environment [1].

After setting up [1] tox will delegate the original call by spawning
a new [1] interpreter with the identical identical list of arguments.

It will also pass the value of `__PYVENV_LAUNCHER__` if present. This in turn
causes `sys.executable` to resolve to [0] instead of [1] therefore ignoring all
modifications including installed requirements.

The fix is to make sure that when [0] spawns [1], `__PYVENV_LAUNCHER__` is
removed from the environment.
@Kentzo Kentzo force-pushed the fix-provisioning-from-pyvenv branch from 4f1743a to 40f4860 Compare November 6, 2019 02:21
Copy link
Contributor

@asottile asottile left a comment

Choose a reason for hiding this comment

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

@asottile
Copy link
Contributor

asottile commented Nov 7, 2019

@Kentzo could you fix the tests so this can be merged? thanks!

@Kentzo
Copy link
Author

Kentzo commented Nov 7, 2019

@asottile Are you sure the failure is related to the change? I may take a look, but I'm completely unfamiliar with the codebase.

@gaborbernat
Copy link
Member

I don't think the ci failure is related, but let's not merge until we fix master and rebase. Thanks!

@gaborbernat gaborbernat merged commit 5582194 into tox-dev:master Nov 11, 2019
@Kentzo Kentzo deleted the fix-provisioning-from-pyvenv branch November 11, 2019 16:58
@gaborbernat
Copy link
Member

gaborbernat commented Nov 13, 2019

This now has been released under https://tox.readthedocs.io/en/latest/changelog.html#v3-14-1-2019-11-13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants