mise icon indicating copy to clipboard operation
mise copied to clipboard

Plans for Python virtualenv support

Open rsyring opened this issue 2 years ago • 4 comments

Are there docs anywhere for how Python virtualenv support will be expanded? I really like the idea of managing virtualenvs with rtx but there are rough edges right now. Thought it might be helpful to identify the features that rtx will (and will not) support.

  1. Set a base directory where all virtualenvs will be created. Ala WORKON_HOME from virtualenvwrapper.
  2. Add cli command(s) or extend use to manage virtualenvs: e.g. rtx use --venv [email protected]
  3. How can multiple Python versions but also venvs be automatically supported? E.g. rtx use --venv-prefix myproj [email protected] [email protected] creates myproj-3.10 and myproj-3.11 virtualenvs.
  4. Fix: rtx use [email protected] will cause virtualenv settings to be removed in .rtx.toml
  5. rtx should prompt before removing everything at the path of a virtualenv. Currently, if you mistype the location, you could end up with big problems since that path is mercilessly replaced with a virtualenv.
  6. Support for passing commands through to the venv creation?
  7. Support creating venvs with virtualenv?

rsyring avatar Jun 27 '23 21:06 rsyring

  1. can't you just use an env var?
  2. at least for right now I don't see myself modifying the rtx CLI for python-specific commands like this
  3. you might be able to do this right now with templates
  4. this is a bug that should be fixed, though it's a little tricky. What needs to happen is if a plugin exists it should retain the options I think.
  5. this is harder to fix than it sounds. rtx isn't doing any deleting I don't think, that's all python.
  6. like?
  7. isn't that just for python2?

In general I don't see expanding venv support too much, except for better support for poetry and other build tools. The rough edges should be resolved, but this is a complex feature to support and I'm not a python developer so I want to keep the feature creep to a minimum.

The main purpose for including it at all was so python users wouldn't need to get direnv to work with rtx which was kind of a pain.

jdx avatar Jun 27 '23 21:06 jdx

I agree that it would be nice to be able to add the venv part of python = {version='3.11', virtualenv='.venv'} from the CLI (some variation of option 2). Perhaps support for this could be done via a plugin?

thomasaarholt avatar Jul 10 '23 09:07 thomasaarholt

@rsyring you can try pdm plugin

when you run pdm install, pdm create .venv in your project root.

with this config, when you cd into your project root, rtx will run source .venv/bin/activate for you automatically

$ cat .rtx.toml 
[tools]
python = {version='3.10.12', virtualenv='.venv'}
pdm = {version='2.7.4'}

dfang avatar Jul 14 '23 05:07 dfang

Per #690 - the time it takes to create the virtualenv is significant from a UX perspective. Should at least let the user know what is happening: "Creating Python virtualenv at: /some/file/path..."

rsyring avatar Jul 17 '23 18:07 rsyring

venv creation is now optional and behind a setting, defaulting to disabled: https://github.com/jdx/mise/discussions/1357

I also plan to move this configuration from the [tools] section to the [env] section #1303

I'm going to close this one because those tickets are more actionable.

jdx avatar Jan 07 '24 09:01 jdx