-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
fix(pypi): choose the stock python version before the versioned one (#1637) #1639
Conversation
👍 for this MR. This is something I really need. Thanks for the work. |
@williamboman is there something preventing this from getting merged? |
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.
Thanks for the PR! This will effectively create the inverse problem where the "stock target" version is too old. The current implementation tries to find a versioned executable that is greater than the stock target.
I believe one thing that could be done to alleviate the issue is to remove python3.12 as a candidate as it seems like it has pretty poor support among pypi packages. It would be optimal if we'd be able to gather information about the supported range of python versions, but there are no convenient out-of-the-box pypi APIs for that afaik.
@williamboman
> ~ curl https://pypi.org/pypi/nginx-language-server/0.8.0/json -sw '' | jq '.info.requires_python'
">=3.8,<3.12" I think it is possible to match the Python version candidates with "Requires-Python" metadata and select the most recent & appropriate version for the package. What do you think?
|
Yeah I've seen that field in the API earlier. In order to parse that field properly there'd need to be a PEP440-compatible implementation somewhere. There's a https://docs.rs/pep440_rs/latest/pep440_rs/ crate which could potentially be leveraged in the registry API service, however that API service is opt-outable so a Lua implementation would be preferable. That's pretty much as far I've gotten so far in terms of finding a better solution |
I think a simpler implementation would suffice, I'd wager most version specifiers in that particular field are simple in nature so we don't need to support the full version specifier specification. I'll look into it right now |
@dgdsingen Would you mind trying #1725 (branch |
@williamboman "nginx-language-server v0.8.0" is now installed successfully with python v3.11 (>=3.8,<3.12) on this new branch. [INFO 토 6/ 1 10:13:45 2024] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:184: Executing installer for Package(name=nginx-language-server) {}
...
[DEBUG 토 6/ 1 10:13:46 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:88: Finding versioned candidates for ">=3.8,<3.12"
...
[DEBUG 토 6/ 1 10:13:46 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:117: Found python3 installation version=3.11.8, executable="python3.11"
...
[DEBUG 토 6/ 1 10:13:50 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:189: pypi: install "nginx-language-server" "0.8.0"
...
[INFO 토 6/ 1 10:13:51 2024] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:245: Installation succeeded for Package(name=nginx-language-server) And I also tested several other packages I am using ( [INFO 토 6/ 1 10:16:28 2024] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:184: Executing installer for Package(name=isort) {}
...
[DEBUG 토 6/ 1 10:16:29 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:88: Finding versioned candidates for ">=3.8.0"
...
[DEBUG 토 6/ 1 10:16:29 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:117: Found python3 installation version=3.12.3, executable="python3.12"
...
[DEBUG 토 6/ 1 10:16:31 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:189: pypi: install "isort" "5.13.2"
...
[INFO 토 6/ 1 10:16:32 2024] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:245: Installation succeeded for Package(name=isort) [INFO 토 6/ 1 10:45:33 2024] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:184: Executing installer for Package(name=black) {}
...
[DEBUG 토 6/ 1 10:45:33 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:88: Finding versioned candidates for ">=3.8"
...
[DEBUG 토 6/ 1 10:45:33 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:117: Found python3 installation version=3.12.3, executable="python3.12"
...
[DEBUG 토 6/ 1 10:45:35 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:189: pypi: install "black" "24.4.2"
...
[INFO 토 6/ 1 10:45:36 2024] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:245: Installation succeeded for Package(name=black) [INFO 토 6/ 1 10:42:52 2024] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:184: Executing installer for Package(name=ruff-lsp) {}
...
[DEBUG 토 6/ 1 10:42:53 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:88: Finding versioned candidates for ">=3.7"
...
[DEBUG 토 6/ 1 10:42:53 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:117: Found python3 installation version=3.12.3, executable="python3.12"
...
[DEBUG 토 6/ 1 10:42:55 2024] ...zy/mason.nvim/lua/mason-core/installer/managers/pypi.lua:189: pypi: install "ruff-lsp" "0.0.53"
...
[INFO 토 6/ 1 10:42:57 2024] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:245: Installation succeeded for Package(name=ruff-lsp) Thank you very much for your work! |
Perfect, thanks! I'll close this PR in favour of that one. |
for #1637