Skip to content
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

Detect and select a compatible installed Python interpreter #9593

Closed
Bengt opened this issue Jul 31, 2024 · 5 comments
Closed

Detect and select a compatible installed Python interpreter #9593

Bengt opened this issue Jul 31, 2024 · 5 comments
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged

Comments

@Bengt
Copy link

Bengt commented Jul 31, 2024

Issue Kind

Change in current behaviour

Description

My ambition for the README of my poetry project is to be executable from top to bottom on a new system (without errors or warnings). I see that other projects spare the installation steps that concern the operating system. My strong-man argument for their ambition is that users should be able to configure their system suitably themselves. poetry is one such example, but I am not capable of configuring all three major operating systems in a way that is workable for each and every software project I might set up. Neither are the users of poetry, as it turns out. As a result, the issue that the default Python installation could not be found comes up repeatedly, at least:

2022: #4416
2022: #4542
2022: #6841
2023: #7456

Impact

I would argue that in an effort to cater to one's users, each project should specify a best-practice configuration on the operating system level. I suppose to draw the line for a handover of responsibility when the user accepts or deviates from the instructions in executing them to configure their system. Since our project is employing poetry and it is not handling this complexity for us and our users, we need to handle it on the level of our project. For this purpose, I would suggest adding these instructions to the README, but alternatives include creating an installer script, as is common for projects with system-level dependencies.

In this case, configuring the operating system correctly is wholly impossible. Because poetry expects python to be a Python 3 and older Python projects might expect python to be Python 2.7, one cannot configure it to run poetry and many older Python projects. This hints at the root cause of this issue is not at all a (mis-)configuration, but mismatched expectations. While it might seem naive that older Python projects expected Python to always stay on version 2, poetry should really strive to be better than that and at least notice its (equally naive) expectation of Python to always have been on version 3.

As a solution, poetry should detect installed Python versions and choose a suitable one to run on. For poetry is currently tested against Python 3.8, 3.9, 3.10, 3.11, and 3.12. This seems to give sufficient guidance in selecting a compatible Python interpreter to run poetry on.

Workarounds

Each time before working on a poetry project:

unlink /opt/homebrew/bin/python || true &&
ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python

Each time before working on a Python 2 project:

unlink /opt/homebrew/bin/python || true &&
ln -s /opt/homebrew/bin/python2 /opt/homebrew/bin/python
@Bengt Bengt added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Jul 31, 2024
@Bengt Bengt changed the title Detect and select an installed Python interpreter Detect and select a compatible installed Python interpreter Jul 31, 2024
@dimbleby
Copy link
Contributor

#6940 looks like the open duplicate, please close

as the years go by I would think that reasons to worry about python2 become fewer and fewer, but I expect if you submit a pull request then it has every chance

@Bengt
Copy link
Author

Bengt commented Jul 31, 2024

Thanks for pointing out the duplicate issue.

Yes, the reasons to worry about Python 2 projects become fewer and fewer over time. In other words, using poetry remains a compatibility risk indefinitely. This is especially worrying because if you still use a Python 2 project today, you most certainly absolutely have to use it for some business reason. This means that in this scenario, the only workable way is most likely to port away from poetry instead of porting the Python 2 project to Python 3. Because this defeats the purpose of using poetry in the first place, the reasonable recommendation is to not use poetry unless you are absolutely sure to never need to run it on a system with Python 2 projects.

There is _find_python_executable. Shouldn't this select a compatible Python interpreter? From what I read, it actually does not check for tested (3.8 - 3.12) compatibility.

def _find_python_executable(self) -> None:

@dimbleby
Copy link
Contributor

I again invite you to make a pull request. People who care about python2 are going to be an ever-dwindling minority, your chances of someone else showing up and doing something about this for you are only going to decrease.

Anyway: please close this issue, discussion should happen in the already open one. Dividing that into several places will not help future readers!

@Bengt
Copy link
Author

Bengt commented Jul 31, 2024

Thanks for being open for a potential pull request. I might just create one if I find a way to fix this.

Thanks for being clear about poetry dismissing users who (have to) care about Python 2. This is valuable information for my future recommendations.

I agree that we should keep discussions focussed. Closing in favor of #6940.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants