-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
get-poetry.py: Use correct python when installed with non-default python #1042
Conversation
|
I have submitted and asked, per the PR template. It has been 7 weeks, can anyone offer some insight as to how we can move forward with this? |
483c87a
to
80319ca
Compare
I've rebased to resolve a merge conflict. Any chance I can get some answers regarding testing? |
@terminalmage thanks for your contribution. sorry we've been swamped. I'm still getting up to speed so I can't make promises as to when we'll be able to look at this. Would you be able to fix the formatting issue? (run black on the code) |
On CentOS 6, `/usr/bin/env python` is Python 2.6. This results in poetry being unusable since 2.7 is required. Poetry should still work when an alternative Python is installed. That is, you should be able to run `python2.7 get-poetry.py` and end up with a usable installation of poetry. This will use the python executable used to run get-poetry.py in the shebang, ensuring that a valid python is used.
80319ca
to
7424d89
Compare
@brycedrennan Formatting should be taken care of now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it still won't fix the issue. Examples:
- my system python is 2.6, but I run
python get-poetry.py
in my 3.6 virtual environment, we'll still have the same issue. - my system python is 2.6 but I run
/path/to/python3/python get-poetry.py
We could alternatively change this fix to use the full path to the python executable, but then I worry about someone running this inside of a virtualenv and then later deleting a virtualenv. Perhaps we could error out if someone runs get-poetry.py inside a virtualenv and then use the full path?
Thanks for your excellent points. Disallowing Poetry from running within a virtualenv seems unnecessary perhaps. I think the rationale for this is not being able to set the path to the Python executable to use for Poetry, which perhaps can be made configurable. The way this can be done is to add a little script that checks a configuration value and uses that to start Poetry with the correct Python interpreter. This would allow people to change the Python version used as well. If this is populated with the system interpreter (e.g. |
If your system Python is 2.6, and you run
Very good points. |
@michielboekhoff To be clear, I don't want to prevent poetry from running in virtualenvs, I want to prevent the global, system-wide installation of poetry in a virtualenv. This would allow us to solve the problem you're having while not creating a new situation that people will get into trouble with. @terminalmage in my first example the |
Ahh yes, thanks for clarifying. |
Can't poetry only be started from interpreters it's been installed in? So the configuration would only have one valid option. That feels not a great fit for a setting. Also wouldn't |
@brycedrennan - This is true, it wouldn't fix it for Python 2.6 (and other unsupported versions of Python). The only reason I mention this is this: say, you're a user who only has Python 2 installed. You upgrade your things to Python 3, potentially even removing Python 2 altogether, only to find Poetry still uses 2 and now fails to start. The way I understand it, it's all just Python scripts invoking the interpreter as defined by There very well might be a much nicer mechanism to handle this. |
interesting. thanks I'll have to think about this |
Okay I think we should solve this with two changes:
arguments can be added like this: This would silently fix the problem for many people while also giving a configuration option to address any other edge cases. What do you guys think? Psuedocode: def find_compatible_python_binary():
if command_line_binary_specified:
return command_line_args['python_binary']
# default to trying to use python3 if its available
if command_exists('python3'):
return 'python3'
if version_of_binary('python') < (2,7,0):
raise RuntimeError("Poetry only works with Python >=2.7. You can manually specify a python binary for poetry to use with the `--python-binary` argument.") |
@brycedrennan - I like it! If no one else has any time, I can pick this up later this evening. |
@michielboekhoff I will be very busy for the next two weeks, so if you are free and have the time, I would be very interested to see what you come up with. |
@michielboekhoff that's the purpose of package management. Custom script installation defeat the functionnality. I think it's better to fail if user removed required python, rather than picking random interpreter from either virtual_env or interpreter-version-of-the-day. If one choose to install poetry with /usr/bin/python3, it will still works when upgrading from 3.7 to 3.8. But it should effectively fails if one installs poetry with /usr/bin/python3.7 and drops python3.7.
I think that this my 2c. :-) |
Sorry it took me so long to get around to this. I've taken a stab at this in #1518. @brycedrennan - I couldn't (easily) figure out how to detect the version of a given Python parser - without running |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
On CentOS 6,
/usr/bin/env python
is Python 2.6. This results in poetry being unusable since 2.7 is required. Poetry should still work when an alternative Python is used to install it. That is, you should be able to runpython2.7 get-poetry.py
and end up with a usable installation of poetry.This will use the python executable used to run get-poetry.py in the shebang, ensuring that a valid python is used.
NOTE: I didn't see a place to add tests for this, the "installation" dir seems to refer to installing python packages using poetry, not installing poetry itself via
get-poetry.py
. Any help in this respect would be much appreciated.