Plans for Python virtualenv support
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.
- Set a base directory where all virtualenvs will be created. Ala
WORKON_HOMEfrom virtualenvwrapper. - Add cli command(s) or extend
useto manage virtualenvs: e.g.rtx use --venv [email protected] - How can multiple Python versions but also venvs be automatically supported? E.g.
rtx use --venv-prefix myproj [email protected] [email protected]createsmyproj-3.10andmyproj-3.11virtualenvs. - Fix:
rtx use [email protected]will cause virtualenv settings to be removed in .rtx.toml - 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.
- Support for passing commands through to the venv creation?
- Support creating venvs with virtualenv?
- can't you just use an env var?
- at least for right now I don't see myself modifying the rtx CLI for python-specific commands like this
- you might be able to do this right now with templates
- 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.
- this is harder to fix than it sounds. rtx isn't doing any deleting I don't think, that's all python.
- like?
- 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.
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?
@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'}
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..."
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.