Skip to content

Comments

force recreation of venv if it is not sane (#286)#1797

Merged
sdispater merged 4 commits intopython-poetry:masterfrom
finswimmer:issue-0286-empty-venv
Jan 9, 2020
Merged

force recreation of venv if it is not sane (#286)#1797
sdispater merged 4 commits intopython-poetry:masterfrom
finswimmer:issue-0286-empty-venv

Conversation

@finswimmer
Copy link
Member

With this PR a virtual environment is recreated if it's not sane, meaning the python and pip executable is not found within the venv path.

I'm not sure how to write a test for it. If it's necessary, please give me a hint :)

Fixes: #286

Pull Request Check List

This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!

  • Added tests for changed code.
  • Updated documentation for changed code.

@finswimmer finswimmer requested a review from a team December 27, 2019 17:36
@finswimmer finswimmer added kind/bug Something isn't working as expected area/venv Related to virtualenv management labels Dec 27, 2019
Copy link
Member

@sdispater sdispater left a comment

Choose a reason for hiding this comment

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

We might go into a loop here since there is no guarantee that recreating the virtual environment will fix the issue. If we go this route we should at least display a warning that we recreate the environment because it's invalid.

Another approach, or an addition to this PR, could be to check if the environment is valid after creating it and, if it's not, we could warn the user. A lot of cases we had here comes from the fact that Debian-based systems do not include the venv module by default which leads to a broken environment. If it's only pip missing, we could try to install it by using the get-pip.py script.

@finswimmer finswimmer requested a review from sdispater January 3, 2020 21:41
@finswimmer
Copy link
Member Author

I've added a more explicit warning.

I also have a variant in preparation where I check the sanity of the venv after creating this. But I have a problem to pass the tests in env/test_use, because the build_venv is mocked and just create a folder without any content. I'm not sure yet, how to fix these tests...

Co-Authored-By: Sébastien Eustace <[email protected]>
@finswimmer finswimmer requested a review from sdispater January 8, 2020 05:27
@sdispater sdispater merged commit cbb1c18 into python-poetry:master Jan 9, 2020
@finswimmer finswimmer mentioned this pull request Jan 10, 2020
2 tasks
@finswimmer finswimmer deleted the issue-0286-empty-venv branch April 4, 2020 19:06
@github-actions
Copy link

github-actions bot commented Mar 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area/venv Related to virtualenv management kind/bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If .venv is an empty directory, poetry installs dependencies globally

2 participants