-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
use base python installation (not virtual environment's Python) during python interpreter resolution #233
Comments
While a recent fix improved the situation under windows, things are still a big flaky. Also,
VS this on the same environment:
So things are still flaky in this department. One way to make this better is to allow the user to actually indicate which python interpreter to use more directly while still maintaining compatibility with the existing logic.
can be made to also support:
Or possibly, to make it easier to control from an environment variable:
Thoughts? |
I'm not super keen on the idea of putting system-specific paths into the
Noxfile, as they're supposed to be portable.
…On Sat, Aug 24, 2019 at 4:38 PM Omry Yadan ***@***.***> wrote:
While a recent fix improved the situation under windows, things are still
a big flaky.
for example, it's unclear how to test python 2.7 (we can't have it in the
path as Python because then nox would not run).
Also,
(hydra36) PS>nox -s "test_plugin-3.6(fairtask, pip install -e)"
nox > Running session test_plugin-3.6(fairtask, pip install -e)
nox > Creating virtual environment (virtualenv) using python.EXE in .nox\test_plugin-3-6-fairtask-pip-install-e
nox > pip install --upgrade setuptools pip
nox > python C:\Users\Administrator\checkout\hydra\plugins\fairtask\setup.py --classifiers
]..7> Session test_plugin-3.6(fairtask, pip install -e) skipped: Not testing fairtask on Python 3.6, supports [3.6
VS this on the same environment:
(hydra36) PS>nox -s "test_core-3.6(pip install -e)"
...
nox > Session test_core-3.6(pip install -e) was successful.
So things are still flaky in this department.
One way to make this better is to allow the user to actually indicate
which python interpreter to use more directly while still maintaining
compatibility with the existing logic.
@nox.session(python='2.7')
def tests(session):
pass
can be made to also support:
@nox.session(python='2.7', python_path='c:/python2/bin/python.exe')
def tests(session):
pass
Or possibly, to make it easier to control from an environment variable:
@nox.session(python='2.7=c:/python2/bin/python.exe')
def tests(session):
pass
Thoughts?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#233>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB5I46MFDZTL77LF5FT3K3QGHA7ZANCNFSM4IJYJNJQ>
.
|
Not into the noxfile, Into an environment variable. that was a simplified example to explain the syntax, what I actually had in mind was something like:
And then:
|
A possibly cleaner approach would be a nox specific environment variables:
User code and logic are unchanged, but now nox would resolve python 2.7 with this environment variable if it's present. |
@theacodes, do you think this approach would be preferred? |
when I have some free time I'm going to test this on my windows machine. If
someone else with Windows wants to give this a stab, let me know.
…On Thu, Aug 29, 2019 at 11:31 PM Omry Yadan ***@***.***> wrote:
@theacodes <https://github.com/theacodes>, do you think this approach
would be preferred?
right now I am not quiet able to test python 2.7 on Windows, so
workarounds would be appreciated.
I tried several tricks but was not able to get nox to detect the right
python2.7 interpreter.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#233>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB5I45IHYP5J5CK53QW7STQHC5FJANCNFSM4IJYJNJQ>
.
|
Thanks! Regardless of this, I think a method to specify what Python interpreter to use for a given Python version can be a helpful way to short cut through imperfect heuristics in the rare cases they don't do what I want - but your call :). |
I think so too, I'm just not sure about how we should let folks specify
that.
…On Wed, Sep 4, 2019 at 2:04 PM Omry Yadan ***@***.***> wrote:
Thanks!
Regardless of this, I think a method to specify what Python interpreter to
use for a given Python version can be a helpful way to short cut through
imperfect heuristics in the rare cases they don't do what I want - but your
call :).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#233>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB5I45CYHIEAHSZ4UNKNELQIAPEHANCNFSM4IJYJNJQ>
.
|
Do you have any reservations about my second suggestion to use a per-version optional environment variable?
|
I always have reservations about new config options and especially
environment variables. Maybe some of the other maintainers have opinions?
…On Wed, Sep 4, 2019 at 2:20 PM Omry Yadan ***@***.***> wrote:
Do you have any reservations about my second suggestion to use a
per-version optional environment variable?
NOX_PYTHON_OVERRIDE_PY27=c:/python2/bin/python.exe
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#233>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB5I47UCVTZVMNSRQRUADLQIARCPANCNFSM4IJYJNJQ>
.
|
In case we needed another example where the current checks fail us: logs The problem is that in the GitHub Actions runner there is a version of Python 2.7 installed in As a workaround, deleting that python2.7.exe causes nox to resolve to something else (probably via I'm not sure how well an environment variable would work in this case - the base directory of the installation is available with |
@chrahunt, if you know the location of the python2.7 in advance, you would have added to your circle config for python 2.7 runs:
For me at least, I have a separate circle job for each python version (and each OS version as well) so having a - per OS+python ver logic is acceptable. |
Let's see what @dhermes @lukesneeringer @stsewd and @crwilcox think? I think for the issue described by @chrahunt in #233 (comment) we could fix that by preferring the For other cases, I'm not sure how we should handle ambiguous resolution. Nox currently early-outs when it finds an interpreter that looks good. Should we keep going and then somehow figure out how to pick one out of many possible interpreters? And then there's the question of letting users somehow specify the exact location for an interpreter. I'm not super keen on environment variables but I'm also not keen on having a dozen more command-line options to handle it. |
Yes, giving priority to py.exe on Windows would fix my issue. I think it would be a pretty nice approach too, since |
Is it safe to summarize that this is a strictly Windows problem? If yes, then isn't the |
I think we have two issues here:
Those two things are not in conflict, and while implementing 1 alleviates the pressure to implement 2, we WILL have additional python resolution issues in the future. |
The intent of the issue when I originally created it was for nox to find and use system Python installations when working from within a virtual environment, rather than using the Python installation from within a virtual environment (new virtual environments can only be created with Python executables outside of the virtual environment). Fixing this would allow projects like pipx and pipenv to use nox for testing. I should have been more clear in the original issue title. Perhaps new, more targeted issues can be created for the other topics that have come up. I will rename this issue to be more precise as well. |
Sorry for the late reply, I don't have experience on windows, so I can't have an opinion there. For other cases maybe an option like |
Also sorry for delay getting around to this I agree that preferring py.exe on windows is likely the best path forward. It will keep version resolution out of nox. It would be odd to add logic that didn't respect the path and I imagine would be confusing. I think we can close this and move discussion to #250. @cs01 does this resolve pipx/pipenv issues? |
I think using |
@gaborbernat says |
Hey @omry
As of Nox 2020.12.31, this can be achieved by passing the full interpreter path via
This will still resolve the other interpreters normally. To restrict the run to a specific interpreter, you'd need to pass the path to
(We may introduce a shorthand for this eventually.) Would this technique work for your use case? |
Just for the record this is no longer a record for me, as the pipx tests now work with nox. I am not sure exactly what changed, but I suspect the venv module has been modified. In any case, I am fine if this issue is closed. |
Thanks @cs01 ! |
Describe the bug
Current logic to determine which python interperter to use will use whichever is on the current PATH, which can be a virtual environment's python (venv or virtualenv) or a system installation.
This can be problematic when creating new virtual environments, as pipx and probably others like pipenv must do.
How to reproduce
Run pipx's unit tests. Clone pipx, then run
nox
.Expected behavior
The base python interpreter should be resolved rather than the virtual environment's python interpreter.
Example implementations for interpreter resolution:
Note: #199 suggests using venv will fix this. I think this is necessary but not sufficient to create a new venv from within a virtual environment. (cc @pfmoore)
The text was updated successfully, but these errors were encountered: