@brettcannon @SebRaschka I'm with Sebastian on this, the difference between conda envs vs venvs vs {the other tools} is thin.
I'm 95% sure you can get away without activating conda envs in most cases (if you do not have any activate scripts or extra env exports). You lose some of the self-description that you _are_ using a conda installed Python, but 🤷
I somewhat regularly do `/path/to/conda/env/bin/python blah` and have not had any issues (but now I'm a bit worried....)
I remember some early discussion about those start up scripts / envs with Aaron Meurer arguing they were a Bad Idea ™️ .
Seems he was right (and I was wrong).
@SebRaschka @brettcannon The problem is conda packages can install on activate scripts and ENVS exports so while not strictly needed for _Python_ to work (modulo the zlib bug), if you are a tool like vscode it will break a lot of users expectations that their conda installed custom-what ever well be run!
I can totally see people shipping things like ENVS for access / configuration in a conda package that exports them on activate (because I, ah, tried to do that..my coworker talked me out of it)
@shaib @carlton There will be a follow-up poll around multiple environments per project; one thing at a time. 😉
As for switching per directory, that's entirely how I work and I think it's great since I never have to worry about using the wrong environment for the project. I have one primary environment I directly dev in and then let nox handle testing against other versions. If I have to create a quick environment then it's cheap since the wheels are already cached from nox installing them.
@brettcannon Largely yes, though I'd probably do the same even if weren't, assuming easy configurability, due to environment sharing and inability to accidentally commit the venv.
In other words, I'm a vote for "combination of multiple choices."
@brettcannon I was annoyed when I forgot to activate venv in terminal, or switch to another one. So I wrote a simple tool for activating and deactivating venv automatically basen on current path. And I just decided to keep all those venvs in one place.
Here's link for powershell version: https://github.com/dejvidq/autoenv-ps1
I need to merge this repo with second one I created for zsh version.
@lgw4 We have seen this for the Python extension for VS Code. This is why we drop a `.gitignore` file containing just `*` when the extension creates a virtual environment via its `Create Environment` command.
Does the tool you use tie the environment back to the project directory somehow? The motivator for me asking this is how does one know what environment to use for a project directory?
@brettcannon For personal use, I switch between `virtualenvwrapper` and `virtualfish`. My team at work selected Poetry, but configured to use `~/.virtualenvs` for virtual environments.
I guess that is a long way of saying "yes."
@brettcannon two reasons:
1. I frequently use environments outside of the root directory for a project. `workon project` saves me from needing to remember where I am to source the venv.
2. Relatedly, when I use `git worktree` I don't need to have a venv/ dir per root.
@brettcannon Similar to @ogimoore I tend to keep a couple of environments with different versions of Python around.
I also do mostly library development so I'm interested in how changes to library A affects library B and how both interact in application C.
Under this workflow it in very non-obvious which of those source checkouts should "own" the env and installing things N**2 times (each project in each other projects env) seems overkill.
Maybe this should have been "sharing/reuse", but 🤷
@tacaswell I would have put that under "sharing/reuse" as that's the primary reason you have structured things this way.
Does this mean you typically have a checkout associated with a single environment? Or at least only one environment per Python version? IOW how could a tool ever know which environment you meant to be used (potentially by Python version)?
BTW I'm also happy with, "it's not possible" as you're obviously a power user. 😅
@brettcannon I tend to have my "bleeding" environment with I build from the main branch of as many things as I can (starting at CPython and going up), and then a bunch `dd3x` environments per python version (via Arch + AUR I have py34 - py311 available).
I think of envs as a per-terminal thing and tend to have multiple terminals open. I will (editable) install a checkout into more than one venv if I have to and select the venv by what terminal I am on (independent of the cwd).
@brettcannon That is one step better than I am doing to myself were I keep trying to make my life harder: https://github.com/tacaswell/build_the_world
But seriously, please do not make this sort of workflow _worse_.
Super opinionated tools are great until they are utterly unusable. Assuming all Python development is fundamentally application-like and propagating those patterns as general Python "best practices" worries me (and I do not think writing off all library developers as "power users" is fair either).
@tacaswell I'm not sure what hat you think I'm wearing here, but it's for https://github.com/brettcannon/python-launcher which is a personal project, so you don't have to use it. And even in context of the Python Launcher for Unix, I'm thinking of https://github.com/brettcannon/python-launcher/discussions/168 and https://github.com/brettcannon/python-launcher/discussions/222 which increases the flexibility to potentially support you.
But I also can't write code to read minds, so I'm trying to figure out how much people's workflows require thought vs just happen to lack some easy automation.
@tacaswell Mastadon might have more characters to use than some of us are used to, but it still isn't infinite to always explain which 🤠 I'm wearing. 😉
I'm unfortunately also being a bit vague on purpose as I want to conceptually understand the environment workflow people have instead of what tools people use. I want the "what do I need" answers instead of "what I use".
@brettcannon I tend to avoid putting venv in-project since I started doing some work on windows; sometimes I’m in WSL, sometimes I’m in windows native. Keeping the venv globally avoids conflicts.
I also find myself using multiple python versions for one project lately, so I often use pyenv’s virtualenv wrapper, which stores venvs globally and lets you refer to it with an in project .python-version file
@brettcannon with pyenv, the .python-version file points to the venv name (which is a directory somewhere in $HOME/.pyenv). Pyenv auto activated the right venv when you cd into the project where the python-version file is.
If I want to switch to another venv with another python ver I just “pyenv use <venv name>” which temporarily activates that instead. This works for me as I usually just want to use other versions a briefly to test things