Closed BVMiko closed 1 month ago
Why not pdm venv remove || true
?
That's the route that I ended up taking shortly after posting this. It makes sense to not add another argument for use with shell scripts when it's easy enough to do with shell code.
Is your feature/enhancement proposal related to a problem? Please describe.
I submitted #3137 while looking into this, but that was only a side issue.
What I'm hoping for is a command which can be run from a script, and will delete the
./.venv/
folder if present and also remove the./.pdm-python
file if applicable. This is going to go into a Makefile'smake clean
script, so I hope for it to return a zero (success) exit status even if there is no existing./.venv/
folder.pdm venv remove in-project --yes
command is almost exactly what I need, but it raises aPdmUsageError
if there is currently noin-project
venv.pdm venv purge
command sounds like it might be more appropriate at first, but it uses a different list of venvs which does not include the in-project venv. (Also it doesn't remove the./.pdm-python
file, my PR above is a fix for that)The
src/pdm/cli/commands/venv/utils.py
file has two distinct iterators (iter_venvs
used bypdm venv remove
anditer_central_venvs
used bypdm venv purge
). The existence of the separate iterator makes it look as though thepdm venv purge
is intended to excludein-project
venvs. So, it seems likepdm venv remove
would be the correct target for this change.Describe the solution you'd like
I would like to add a new argument to the
pdm venv remove
command (perhaps-i
|--ignore
or-s
|--suppress
?) which will suppress thePdmUsageError
, and return a success exit status if there is no matching venv.