New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Vox: Choose Python version with -p
, similar to virtualenv and other tools
#692
Comments
The problem with implementing this feature it we have to add virtualenv as a dependency. |
@moigagoo, as long as it is an optional dependency I don't see the problem. |
+1 to this. I still need to be able to work with py2.7 virtualenvs, and I seem to be shut out from even using existing virtualenvs because bin/activate no longer works. 😢 |
Pull requests most welcome! Preferably by someone who uses virtual envs :) |
Who doesn't use virtualenvs? 😉 I don't understand xonsh's or virtualenv's inner workings well enough to dash anything off. Also, if pyenv is involved, it gets weird (the OP workaround doesn't work for me). I did, however, figure out a workaround, which may or not be helpful to anyone else. Put this in your
UPDATED: Fixed the snippet to use |
Cool. Maybe you could add this the docs as a potential work around: http://xon.sh/python_virtual_environments.html |
@eykd why break the So this code is more straigh-forward and elegant: #!/usr/bin/env xonsh
import os
def _venv(args, stdin=None):
"""
venv <env-name> <python>
Activate with `vox activate <env-name>`
"""
name, version = args
venv_path = os.path.join(os.path.expanduser('~/.virtualenvs'), name)
print('Creating a virtualenv "{}" with "{}"'.format(name, version))
virtualenv @(venv_path) -p @(version)
aliases['venv'] = _venv
|
Again, PRs welcome! |
This is a duplicate of #1588 |
Need: Vox in xonsh from conda breaks. Should probably be detecting the correct python to use anyway. |
Breaks how, @astronouth7303 ? Is it a problem with |
This might be a Debian thing, though. Happens even when I call (This is why we can't have nice things.) |
Hey, Is there still interest in this feature? It seems a little strange having It would be cool if Thoughts? (Thanks for |
Hi @deeuu - I think that there is still interest in this.
Thanks for using xonsh! |
My experiment:
add to .xonshrc
restart xonsh and install needed version of python
I has avox with $PROJECT_DIRS = ["~/code"] for autoactivate vox env
looks like vox did not use pyenv python |
knowsuchagency's PR (cf, #2968) would make vox pyenv-friendly, but relegate pyenv to a python version installer when used in conjunction with vox. This is the best solution, IMO, as vox would then take the absolute path to the desired interpreter, and that could be one that pyenv installed. I.e., Note the further benefit that vox could use the same interpreter and site packages as a venv, virtualenv or pyenv-virtualenv, allowing the user to activate the same virtual environment in any shell. |
@joseph8th thanks for information about PR.
Looks good! |
virtualenv supports xonsh now, and this has been implemented. |
Currently, Vox invokes
venv.create
from Python 3 to create environments. This means that you can't create Python 2 environments.Workaround: Create the environment in $VIRTUALENV_HOME (~/.virtualenvs by default) manually with
virtualenv -p python2 ~./virtualenvs
.The text was updated successfully, but these errors were encountered: