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
Python version changes depending on command line arguments #1807
Comments
Found the reason. It's rbenv/rbenv@283e67b . It's a feature (?) where if the shim is invoked with a script, the version to use is taken from the script's directory rather than the current one. The problem is, the shim code doesn't find the script parameter reliably. Moreover, due to different Python versions and implementations having different command line parameters, I seriously doubt this is even possible: we'll need to maintain version-specific procedures of extracting the script argument from the command line (not mentioning As such, I propose to remove the feature of taking the version from the script's directory as fundamentally broken. |
@anton-petrov Not too hasty? Without a PR? The bug is real. The immediate problem is that the shim detects the script argument erroneously. It thinks it's |
@native-api Don't you think this use case is a bit far-fetched? It looks strange enough to install the local version in the data directory (where are arguments stored) and then run python from the directory above. If, in your opinion, the bug is real... Hmm, let's try to fix it... But, I don't have any ideas on this yet again.
@yyuu What do you think? |
It's only "data directory" in this sample demonstration. In real use, it can very well be a project directory with the file somewhere below it.
Agree. I'll create a separate issue for that. |
|
@native-api in what cases we may need different python versions in one project? And again, this is bad practice. |
I personally have never find this behavior useful, but, so far have been maintaining to not break the compatibility with rbenv behavior. My speculation is, this feature could be brought to look up appropriate runtime setting of some command symlink installed in /usr/local/bin, etc., but, again, myself have never used this. |
(correction) That's not it, it's not "different python versions in one project". This is better discussed in the linked topic where I even asked this question from the person who added the feature. |
Too many issues will kill our team's development velocity, drastically.
Make sure you have checked all steps below.
Prerequisite
pyenv
and the defaultpython-build
plugin only. Please refrain from reporting issues of other plugins here.Description
PYENV_DEBUG=1
, e.g.env PYENV_DEBUG=1 pyenv install -v 3.6.4
Issue
Python version changes depending on command line arguments.
Details
The bar.py is as below. That code displays python version by
print(sys.version)
regardless of the command line arguments.The directory structure is as below.
foo/.python-version
is as below.foo/with-pv/.python-version
is as below.system
is Python 2.7.18.foo/with-pv/a.txt
is as below.foo/without-pv/a.txt
is as below.The command history is as below.
Since we are executing the same code from the same directory, the results of the two commands should be the same. However, if the command line argument directory contains .python-version, the unexpected result is displayed.
The Japanese explanation is here.
https://qiita.com/more-ishy/items/d44f288381bb979751da
The text was updated successfully, but these errors were encountered: