-
-
Notifications
You must be signed in to change notification settings - Fork 164
Add option to use pyenv instead of virtualenv? #4
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
Comments
Hmm. Can you illustrate a use case? From what I understand pyenv can help provide interpreters for virtualenv, but it does not itself handle management of virtualenvs. |
While pyenv does provide interpreters, it also has a plugin for creating/managing virtualenvs built from those interpreters. https://github.com/yyuu/pyenv-virtualenv I use that to create the virtualenvs. Internally, pyenv uses either the venv command (if python 3) or the virtualenv command (if not). I have forked the project, and will try to work up a PR for you. |
Cool, PRs are welcome. 👍 |
Why doesn't the normal workflow works for you? I'm using nox with pyenv like this |
If you are having trouble getting nox to pick the right Python when using pyenv, this guide may help: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/MAC_SETUP.md |
I'm thinking of closing this, unless there's something we can actually do here. Somethings that come to mind:
|
I would definitely appreciate [1]. I've been fighting with getting nox to see my pyenv-ish 3.7.0 for a couple of hours. |
Going through some of the older issues to see if we can close any off. cc @cjolowicz I'm not sure this one is still relevant? Perhaps we've changed stuff in the time since this was raised but I was able to install python 3.8.12 using pyenv and run a nox session utilising this python: (I have python 3.10.1 (pyenv), python 3.9.9 (homebrew) and this python 3.8.12 (pyenv) on my machine) # noxfile.py
import nox
@nox.session(python="3.10")
def py310(session: nox.Session) -> None:
"""
Do stuff with 3.10
"""
session.install("pytest")
session.log(f"My python is {session.python}")
@nox.session(python="3.9")
def py39(session: nox.Session) -> None:
"""
Do stuff with 3.9
"""
session.install("pytest")
session.log(f"My python is {session.python}")
@nox.session(python="3.8")
def py38(session: nox.Session) -> None:
"""
Do stuff with 3.8
"""
session.install("pytest")
session.log(f"My python is {session.python}") Which results in: And catting the The trick with pyenv is that in order for Nox to have access, you must declare the python version to be the "global" one Or you can include a I tested this approach too:
In between each of these runs I |
Closing this as suggested by @FollowTheProcess . Happy to reopen if people want to pursue this further. As far as I understand, there were two separate points raised in this issue:
I'm not sure about the value of 1, given that For users affected by 2 with a recent pyenv and virtualenv, I'd suggest to:
|
For anyone coming to this issue later (likely me), I am totally fine with However,
Turns out It seems So I created the below basic script to discover what versions are available, check if that path is not already on PATH and generate a shell command you can run yourself to update your PATH for the sake of that shell session by appending them to the end of your PATH. import os
from os import listdir
from os.path import isfile, join
from pathlib import Path
PATH = os.environ["PATH"]
# Maybe change this to get the result from subprocess.run(["pyenv", "root"])
target = Path(Path.home() / ".pyenv/versions/")
dirs = [
d
for d in [
str(target / e / "bin")
for e in os.listdir(target)
if not isfile(join(target, e))
]
if d not in PATH
]
if dirs:
print(f"PATH=$PATH:{':'.join(dirs)}") So for me it is these extra steps to get a eval $(python3 pyenv_discover_paths.py)
nox No need to reopen this ticket, just wanted to add this here since this is where google took me and I wanted to leave my solution on the bread crumb trail for the next person (most likely me again). |
Just run into this issue today and I found that
and it now works as expected. Hope this helps for whoever run into this in the future. :) |
pyenv is an alternative way to create virtualenvs, by installing multiple copies of python (different versions). It uses the pyenv virtualenv syntax instead of virtualenv , and activates with pyenv activate . Should be possible as a config option.
The text was updated successfully, but these errors were encountered: