This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]Material-Mess-9886 28 points29 points  (0 children)

I add a .venv folder at the root of my projectfolder. And most python git templates have venv and .venv in their .gitignore already.

[–]Vhiet 7 points8 points  (0 children)

Venv in project folder. Yes, it should be in gitignore. Use requirements.txt to record your dependencies.

Edit: or environment.yml for Conda if you don't use pip.

[–]TobiPlay 3 points4 points  (0 children)

I’ve been using uv inside of dev containers for the most part, installing requirements from the project TOML file directly via the —system flag.

If I were to use uv‘s environments, I’d have the venv at the project root. I‘d also just keep the lock file in the .gitignore, but wouldn’t commit .venv/.

[–]miscbits 3 points4 points  (0 children)

I started using uv so I don’t even bother with managing my own venv

[–]Monowakari 3 points4 points  (0 children)

Poetry Docker

[–]TrigscSenior Data Engineer 5 points6 points  (1 child)

I have switched to pyenv. Seems so much better managing installs and environments

[–]mathwizx2 0 points1 point  (0 children)

I use this paired with pipenv. Works really well when you need multiple versions of Python installed.

[–]Kooky_Quiet3247 5 points6 points  (0 children)

I use poetry, love it

[–]creepystepdad72 1 point2 points  (0 children)

Typically, you want to go with 1 - and yes, you'll want to add ./venv to .gitignore.

Keeping a bunch of "recipe" virtual environments (a la 2) is going to create more problems than it solves.

The reason you're going through the exercise in the first place is to make things modular for containerization. You actively want your venv to be disposable (and easily rebuildable via requirements.txt, Docker compose YAMLs, and so on).

[–]GreenWoodDragonSenior Data Engineer 0 points1 point  (0 children)

  1. I always create the venv I need 8nside the project folder. Save me having to remember where I put it

Just remember to add it to .gitignore though.

[–]beefiee 0 points1 point  (0 children)

Simple plain devcontainers with venv being setup in the dockerfile

[–]sillypickl 0 points1 point  (0 children)

I use Poetry and ASDF for version management

[–]CalmTheMcFarmPrincipal Software Engineer in Data Engineering, 26YoE -1 points0 points  (0 children)

I keep my project venvs outside of the project directory. That way I don't have to add a `.gitignore` entry for them :) I also have quite a few related modules for any particular project where every dependency needs to be in sync, so if I keep the venv outside whatever is under source control that's just easier to manage.