brettcannon,
@brettcannon@fosstodon.org avatar

FYI do NOT put your source code inside your virtual environment. Editable installs are fine, but don't do something like py -m venv some_env and then put your code inside some_env as they canonical place to store it. Keep your virtual environment either as a subdirectory of your workspace or somewhere else entirely separate.

Pretend your virtual environment could be deleted at any moment if you need some guideline follow.

fschulze,
@fschulze@mastodon.social avatar

@brettcannon could you explain why? I was wondering about the automatic .gitignore. I never had issues doing this, but maybe I use it differently somehow?

brettcannon,
@brettcannon@fosstodon.org avatar

@fschulze Because that directory is meant to be somewhat like a cache; look at how tools like tox, nox, etc. create and delete virtual environment constantly. Plus virtual environments are not designed to be relocatable or committed to version control. They are very much meant to be so lightweight you recreate them as needed (it's installation that typically takes a while).

fschulze,
@fschulze@mastodon.social avatar

@brettcannon none of that is a problem for me or a good argument. I can use git clean or rm -rf bin include lib and recreate the venv easily in place. For me it is much more convenient than having it some where else. I have the venv dirs in my .gitignore. I thin the automatically added one should do that instead of having * in it

brettcannon,
@brettcannon@fosstodon.org avatar

@fschulze I don't appreciate the judgment that my argument is not a "good argument"; it's simply my argument and position and you're are welcome to disagree. But making a judgment of quality is not appreciated.

fschulze,
@fschulze@mastodon.social avatar

@brettcannon I’m sorry about that

pkw,
@pkw@mastodon.sdf.org avatar

@brettcannon I have this in my finger memory:

find . -name "*.py" ! -path "venv | xargs grep <something>

I didn't know people were putting code in venv.

EMR,
@EMR@mastodon.sdf.org avatar

@brettcannon I'm scared about the circumstances that lead to you needing to post this.

brettcannon,
@brettcannon@fosstodon.org avatar

@EMR Review of the Black extension for VS Code claims it's the reason for the 1-star reviews which wouldn't shock me based on the review that was posted after it: https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter&ssr=false#review-details

EMR,
@EMR@mastodon.sdf.org avatar

@brettcannon come for the people with the code inside venv, stay for the people ranking on Black's divisive linting choices.

pfmoore,
@pfmoore@mastodon.social avatar

@EMR @brettcannon In the very very early days of virtual environments, the standard pattern was for environments to be long term, and for there to be a src directory inside the environment for your code. There may even be remnants of that pattern still in the code of some tools...

EMR,
@EMR@mastodon.sdf.org avatar

@pfmoore @brettcannon huh, didn't know that. Now I want to check some of my old Python books to see if they mention that pattern.

pfmoore,
@pfmoore@mastodon.social avatar

@EMR @brettcannon I think the cdvirtualenv command in virtualenvwrapper (https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html#cdvirtualenv) is probably a relic of this - although I'm not a virtualenvwrapper user so I may be wrong.

brettcannon,
@brettcannon@fosstodon.org avatar

@pfmoore @EMR The problem we are seeing are people putting code directly into site-packages. My guess is people are reading tutorials about creating virtual environments, run pip, and then either through lack of further instruction or stop reading/watching, poke around, see where the .py files "live", and assume that's where their code goes as well.

diazona,
@diazona@techhub.social avatar

@brettcannon which is a rather apt analogy when using something like tox which actually does (create and) delete virtual environments at will.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • khanakhh
  • DreamBathrooms
  • ethstaker
  • magazineikmin
  • osvaldo12
  • Durango
  • Youngstown
  • ngwrru68w68
  • slotface
  • rosin
  • mdbf
  • kavyap
  • InstantRegret
  • normalnudes
  • megavids
  • thenastyranch
  • modclub
  • tacticalgear
  • GTA5RPClips
  • everett
  • tester
  • cubers
  • provamag3
  • anitta
  • cisconetworking
  • Leos
  • JUstTest
  • lostlight
  • All magazines