-
update env remove logic (#6195) · 2def3571
Resolves: #6018 1. Added a check so that if `python` argument is a file (then it should be a python path) - extract it's venv name and raise `IncorrectEnvError` if it doesn't belong to this project **Before** ``` └❯ poetry env remove ~/.cache/pypoetry/virtualenvs/different-project-OKfJHH_5-py3.10/bin/python /bin/sh: 1: different-project-OKfJHH_5-py3.10: not found Deleted virtualenv: ~/.cache/pypoetry/virtualenvs/poetry-4pWfmigs-py3.10 ``` Removes current project's env, which is wrong. **After** ``` └❯ poetry env remove ~/.cache/pypoetry/virtualenvs/different-project-OKfJHH_5-py3.10/bin/python Env different-project-OKfJHH_5-py3.10 doesn't belong to this project. ``` 2. Added the exact same check as before ^, but for cases where env name is passed. **Before** ``` └❯ poetry env remove different-project-OKfJHH_5-py3.10 /bin/sh: 1: different-project-OKfJHH_5-py3.10: not found Command different-project-OKfJHH_5-py3.10 -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))" errored with the following return code 127, and output: ``` Errors while trying to exec env name as an interpreter, error is not clear. **After** ``` └❯ poetry env remove different-project-OKfJHH_5-py3.10 Env different-project-OKfJHH_5-py3.10 doesn't belong to this project. ``` 3. Added a couple of tests for **new** and for **old** scenarios which weren't tested. 4. Added `venv_name` fixture for `tests/utils` directory to use in `test_env`. Also replaced some of `"simple-project"` hardcoded value to use `poetry.package.name` It's up to maintainers to choose what they want for this project - I'm happy either way if we at least fix the bug. I can remove/change any of the stuff I added on top of the fix. But yeah I just decided that if we fix the bug, we might also make some improvements/changes in this area of code. Any thoughts on this are welcome, thanks!Alexey committed
| Name |
Last commit
|
Last Update |
|---|---|---|
| .. | ||
| __init__.py | Loading commit data... | |
| _compat.py | Loading commit data... | |
| authenticator.py | Loading commit data... | |
| constants.py | Loading commit data... | |
| dependency_specification.py | Loading commit data... | |
| env.py | Loading commit data... | |
| extras.py | Loading commit data... | |
| helpers.py | Loading commit data... | |
| password_manager.py | Loading commit data... | |
| patterns.py | Loading commit data... | |
| pip.py | Loading commit data... | |
| setup_reader.py | Loading commit data... | |
| shell.py | Loading commit data... | |
| source.py | Loading commit data... |