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

[PyPI] platform_system parsing problem #146

Closed
ismail opened this issue Jan 15, 2024 · 11 comments · Fixed by #167
Closed

[PyPI] platform_system parsing problem #146

ismail opened this issue Jan 15, 2024 · 11 comments · Fixed by #167
Assignees

Comments

@ismail
Copy link

ismail commented Jan 15, 2024

Reproducer on linux-aarch64:

pixi.toml

[project]
name = "stats"
channels = ["conda-forge"]
platforms = ["linux-aarch64"]

[dependencies]
python = ">=3.12.*"

[pypi-dependencies]
jupyterlab = '*'
❯ pixi --version
pixi 0.12.0

pixi install results in:

❯ pixi install
ERROR rattler_installs_packages::types::core_metadata: ignoring Requires-Dist: matplotlib-inline (<0.2.0appnope,>=0.1.0) ; platform_system == "Darwin", failed to parse: Version specifier `<0.2.0appnope` doesn't match PEP 440 rules
matplotlib-inline (<0.2.0appnope,>=0.1.0) ; platform_system == "Darwin"
                   ^^^^^^^^^^^^^
ERROR rattler_installs_packages::types::core_metadata: ignoring Requires-Dist: matplotlib-inline (<0.2.0appnope,>=0.1.0) ; platform_system == "Darwin", failed to parse: Version specifier `<0.2.0appnope` doesn't match PEP 440 rules
matplotlib-inline (<0.2.0appnope,>=0.1.0) ; platform_system == "Darwin"
                   ^^^^^^^^^^^^^
ERROR rattler_installs_packages::types::core_metadata: ignoring Requires-Dist: matplotlib-inline (<0.2.0appnope,>=0.1.0) ; platform_system == "Darwin", failed to parse: Version specifier `<0.2.0appnope` doesn't match PEP 440 rules
matplotlib-inline (<0.2.0appnope,>=0.1.0) ; platform_system == "Darwin"
                   ^^^^^^^^^^^^^
✔ Project in /home/ismail/envs/stats is ready to use!
@notatallshaw
Copy link

FYI, this does indeed look like an invalid version specification to me. Did the command successfully install?

It would be great if the error message included the parent, i.e. the package which had the requirement with the invalid specifier.

@ismail
Copy link
Author

ismail commented Jan 15, 2024

The installation looks good to me:

❯ ls .pixi/env/lib/python3.12/site-packages/matplotlib_inline*
.pixi/env/lib/python3.12/site-packages/matplotlib_inline:
backend_inline.py  config.py  __init__.py

.pixi/env/lib/python3.12/site-packages/matplotlib_inline-0.1.6.dist-info:
HASH  INSTALLER  LICENSE  METADATA  RECORD  WHEEL  top_level.txt

@ismail
Copy link
Author

ismail commented Jan 15, 2024

This looks like a parser error to me, the line is

    "matplotlib-inline>=0.1",
    'appnope;platform_system=="Darwin"',

see https://github.com/ipython/ipykernel/blob/main/pyproject.toml#L34C6-L34C13

site-packages/ipykernel-6.0.1.dist-info/METADATA shows that two lines are mangled together:

Requires-Dist: matplotlib-inline (<0.2.0appnope,>=0.1.0) ; platform_system == "Darwin"

Updated the issue title to reflect the real problem.

@ismail ismail changed the title [PyPI] Error parsing version specification for matplotlib-inline [PyPI] Add support for platform_system directive. Jan 15, 2024
@ismail ismail changed the title [PyPI] Add support for platform_system directive. [PyPI] platform_system parsing problem Jan 15, 2024
@ismail
Copy link
Author

ismail commented Jan 15, 2024

The issue is not reproducible on macOS, so I'm guessing parsing of platform_system do actually work.

@tdejager
Copy link
Contributor

Sorry, still don't really understand, is this a valid specification?

Requires-Dist: matplotlib-inline (<0.2.0appnope,>=0.1.0) ; platform_system == "Darwin"

specifically the appnope part?

@ismail
Copy link
Author

ismail commented Jan 16, 2024

I downloaded https://files.pythonhosted.org/packages/b0/71/348c659f0fbbf526ca77fae9fd31d43a3c90d4d60ae3df6d477055ee90d5/ipykernel-6.28.0-py3-none-any.whl and unpacked it.

ipykernel-6.28.0/ipykernel-6.28.0.dist-info/METADATA shows this

Requires-Dist: appnope; platform_system == 'Darwin'

but if you install with pixi, METADATA shows:

Requires-Dist: matplotlib-inline (<0.2.0appnope,>=0.1.0) ; platform_system == "Darwin"

so there is no appnope version specification. There is a bug in rip/pixi mangling the lines together. Again upstream https://github.com/ipython/ipykernel/blob/main/pyproject.toml#L34C6-L34C13 has

    "matplotlib-inline>=0.1",
    'appnope;platform_system=="Darwin"',

@wolfv
Copy link
Member

wolfv commented Jan 16, 2024

This error comes from a previous ipykernel version (ipython/ipykernel#709)

I think we could do a better job at reporting the error (add the version it comes from).

I believe pip (and we) just skip over packages with wrong metadata. Not sure if we should show this to the user by default (since they can't change it usually).

@tdejager
Copy link
Contributor

I believe pip (and we) just skip over packages with wrong metadata. Not sure if we should show this to the user by default (since they can't change it usually).

Yeah this is correct, both @baszalmstra and took that behavior from pip.

@ismail
Copy link
Author

ismail commented Jan 16, 2024

@wolfv Thank you! I guess we can just do an s/ERROR/Warning/ since it was quite confusing as it did install the package.

@tdejager
Copy link
Contributor

tdejager commented Jan 16, 2024

Yeah, that part does seem a bit strange to me, as it explicitly skips the requirement if it can't parse:

https://github.com/prefix-dev/rip/blob/6faf63a6e76b2981335f4cdd14bac2f4f59cc9b6/crates/rattler_installs_packages/src/types/core_metadata.rs#L88C1-L128C1

So I'm guessing the dependency still comes in somewhere down the line?

@tdejager
Copy link
Contributor

Ah, after talking to @wolfv I understand that it is a problem during backtracking, so not really for the package it selected in the end. I think we could make the log a Warning or Debug statement for now. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants