DataDog / riot

A Python virtual env builder and command runner
https://ddriot.readthedocs.io/
Apache License 2.0
23 stars 15 forks source link

Fix: Ensure a "restart" of virtualenv deleting the old one with recreation option (-r) #179

Closed avara1986 closed 2 years ago

avara1986 commented 2 years ago

Description

riot runs virtualenv [directory] to create a virtualenv. If venv 01 directory exists and you run virtualenv venv01, the old virtualenv still has the same packages with no reset.

Manually test

# Create a new virtualenv
python3.8 -m virtualenv -p38 venv_test_38
source venv_test_38/bin/activate 
pip install flask
deactivate

# Recreate
python3.8 -m virtualenv -p38 venv_test_38
source venv_test_38/bin/activate 
pip freeze

Output:

click==8.1.3
Flask==2.1.3
importlib-metadata==4.12.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
Werkzeug==2.1.2
zipp==3.8.1
P403n1x87 commented 2 years ago

🤔 I wonder if this shouldn't be the default riot behaviour, as opposed to the -s option?

avara1986 commented 2 years ago

:thinking: I wonder if this shouldn't be the default riot behaviour, as opposed to the -s option?

I think this is an other behavior.-s skips the installation of packages in a new or existing virtualenv.

If I create a virtualenv, I could have a mistake and install different versions or I could install packages the project doesn't need, at this moment, the option -r doesn't restart the environment

What are your thoughts about this? @P403n1x87

brettlangdon commented 2 years ago

🤔 I wonder if this shouldn't be the default riot behaviour, as opposed to the -s option?

@P403n1x87 you mean every time we do riot run it recreates the virtualenv and re-installs the dependencies?

P403n1x87 commented 2 years ago

@P403n1x87 you mean every time we do riot run it recreates the virtualenv and re-installs the dependencies?

Yes, to ensure that we test with exactly what we declare, and remove any potential mess created while messing around with riot shell inside the venvs. Currently, I'm doing rm -rf .riot as a last resort. I wonder if this also answers your question, @avara1986 ? I'm not sure I understand what restart means here. I think I might have missed some offline discussions?

avara1986 commented 2 years ago

@P403n1x87 as we talk, I added tests to check nested environments :muscle: