News for hackers. Stuff that matters.
Re:PEP 704 – Require virtual environments by default for pac... by twic on Wednesday March 15, 2023 @10:17AM (#35168667)
At some point i did this with gradle (i'm a Java guy):

https://hg.sr.ht/~twic/devtools/browse/bin/gradle?rev=tip

If i'm in a directory with a gradle wrapper, i essentially never want to run any globally installed gradle, i want to run the one in the wrapper.

It's more of a mixed bag with python. If i do:

  cd ~/myproject
  python main.py
Then yes, i want to use the venv in ~/myproject.

If i do:

  cd ~/myproject
  salt '*' status.all_status
I do not want to run salt using the venv in ~/myproject!

On the other hand, if i do:

  python ~/myproject/main.py
I think i'd like to use the venv in ~/myproject.

So maybe resolve the file that will get run, then look for a venv in the vicinity of that?

What happens when you do:

  cd ~/myproject
  python -m json.tool data.json
?

Another option would be to introduce a new set of commands - vpython runs python using a nearby venv, vpip runs pip using it, etc. Or call the ppython, ppip, etc - less mnemonic, but faster to type.

There are no comments on this comment yet.