GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add (experimental) option to use current active python to create venv ("pyenv way") by finswimmer · Pull Request #4852 · python-poetry/poetry Conversation
|
| executable = decode( | ||
| subprocess.check_output( | ||
| list_to_shell_command( | ||
| ["python", "-c", '"import sys; print(sys.executable)"'] |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is not necessarily universal.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You mean python? In theory yes.
But if you have e.g. python2 and python3 in your shell but no python it is impossible to decide what python the user expects.
The main use case for the implementation here is for users who switch there python to different versions (e.g. with pyenv). I'm not aware of other tools, but I guess they all will provide a python. As a fallback if no python is found and the option is activated, the default behavior will be used.
The only generic solution for all edge cases I can imagine right now, is to let the user set a "default python executable" that should be used. But in this case I have some security concerns. Running a user provided command listed in a config, doesn't sound good.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is not just about python2 vs python3. There also are other issues like for .exe extensions on windows etc depending on where poetry is running. Additionally, quite a lot of tools rely on environment magic to wrangle which python version to use etc., this can also be impacted by how the subprocess shell is spawned (eg: is it a login shell?, how does the tool configure the "current" python?, are profile scripts required? is the PATH discoery set correctly? etc.). There are too many variables here. Not sure if this is a show stopper, but we should really consider if this makes things more obscure.
An additional point might be that we should fall back gracefully to compatible version detection than crashing as the option is "prefer" and not "use".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
An additional point might be that we should fall back gracefully to compatible version detection than crashing as the option is "prefer" and not "use".
This is already the case :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
6903560 to
5c65efd
Compare
There was an error while loading. Please reload this page.
QA @ 5c65efdHowever, if I have a Normal shellProject directory (w/
|
| io.write_line( | |
| f"<warning>The currently activated Python version {python_patch} " | |
| f"is not supported by the project ({self._poetry.package.python_versions}).\n" | |
| "Trying to find and use a compatible version.</warning> " | |
| ) |
Is this something that can be backported to 1.1 potentially?
The reason why is while 1.2 entails a significant release but this, if on 1.1, makes the experience much more convenient.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks a lot for your feedback @tony. I'm not familiar with
For now it's unclear if we will will merge this at all or if we try to make a plugin out of it. If we will merge it, I don't think we will backport it to 1.1. There you can have this functionality if you use the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
You're welcome and let me know if another QA would be helpful (assuming / if there's any revisions from here)
Also following this and interested to see where it goes. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@tony: I've found some time to test |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@finswimmer I made a mistake, I didn't test your PR with And upon further examination, I'm detecting my asdf's project-based python correctly on 1.1.12 installed on A shot in the dark: Do we have any high-level, integration-level tests for Enlisting more assistance since there are @shawon-crosen @crflynn @Kurt-von-Laven As you are part of a related issue at asdf-community/asdf-poetry#10 this relates to you, would you like to QA finswimmer's 1.2 branch and see if it fails to detect your python version? Without and with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Good news: Assume
With this PR, the minor version works correctly |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… to EnvManager.create_venv()
5c65efd to
bfe848c
Compare
|
Sounds good @tony 👍
We don't have something like this yet. We would like to have some kind of end-to-end-test for several usecases, in different environments and with different settings. But I'm afraid this is nothing what can be done easily, because the possible combinations are endless ... For now I'm happy to see, that the implementation seems to work for I would like to hear something from people, that have use cases with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I borrowed @finswimmer's shell commands and have a simple Docker test here using |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This change is relatively minor, marked experimental, and arguably is less surprising behavior for the end user. I think we're good to go ahead and merge this, and tweak it if needed in the future.
Personally, I think that we should check the current python3 instead of python given that Python 2 is well and truly dead now, but we can correct that later if it's an issue.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@neersighted, I don't have a lot of expertise on the topic, but that makes sense to me. This may already be what you are suggesting, but to clarify I would think it wise to also continue to check |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
We only support Python 3 (Python 2 has been out of support for years now) and a python3 should always be present (both a PEP and distro packaging guidelines call for this) when Python is installed. Therefore I see no need to check both as the python binary is either Python 2 (unsupported), Python 3 (good), or does not exist. Some distros provide python as a symlink to python3, and others require a package like Debian's python-is-python3 or FreeBSD's lang/python. That being said, asdf and pyenv will both work with this change, and I can see this version as being more in line with the principle of least surprise. We can always change it if needed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you for the explanation! That was very educational. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
After the installation of poetry via the new scriptinstall-poetry.py poetry ignores pyenv local python version
There was an error while loading. Please reload this page.