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

Fail to read metadata from .dist-info: data did not match any variant of untagged enum DirectUrl #1744

Closed
messense opened this issue Feb 20, 2024 · 8 comments · Fixed by #1793
Assignees
Labels
bug Something isn't working

Comments

@messense
Copy link
Contributor

$ uv pip freeze
error: Failed to read metadata: from /home/ubuntu/workspace/example/.venv/lib/python3.10/site-packages/qPython-2.0.0.dist-info
  Caused by: data did not match any variant of untagged enum DirectUrl
$ cat /home/ubuntu/workspace/example/.venv/lib/python3.10/site-packages/qPython-2.0.0.dist-info/direct_url.json
{"url": "git@github.example.com:example/qPython.git", "vcs_info": {"vcs": "git", "requested_revision": "7190a34911a789bd8e44f6b1986c8e84815b62e2", "commit_id": "7190a34911a789bd8e44f6b1986c8e84815b62e2"}}

VcsUrl {
url: Url,
vcs_info: VcsInfo,
#[serde(skip_serializing_if = "Option::is_none")]
subdirectory: Option<PathBuf>,
},

Probably because the url crate can't parse git@github.example.com:example/qPython.git: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3a089088700e500364057509872b61f9

thread 'main' panicked at src/main.rs:4:72:
called Result::unwrap() on an Err value: RelativeUrlWithoutBase

uv version: 0.1.5

@konstin
Copy link
Member

konstin commented Feb 20, 2024

I've checked https://packaging.python.org/en/latest/specifications/direct-url-data-structure/ and PEP 610 neither defines what grammar the url field allows :/

What command did you use to install qPython?

@messense
Copy link
Contributor Author

It was installed by Poetry, I'm playing around with uv in a existing venv.

@charliermarsh charliermarsh added the bug Something isn't working label Feb 20, 2024
@charliermarsh
Copy link
Member

I can look at this (though mildly dreading it).

@konstin
Copy link
Member

konstin commented Feb 20, 2024

I'd expect the poetry maintainers would be willing to fix this, i wonder if any other tools are doing something similar. It would be helpful if we could agree in https://packaging.python.org/en/latest/specifications/direct-url-data-structure/ that url contains a url as defined by https://url.spec.whatwg.org/.

@sbidoul
Copy link

sbidoul commented Feb 20, 2024

It would be helpful if we could agree in https://packaging.python.org/en/latest/specifications/direct-url-data-structure/ that url contains a url as defined by https://url.spec.whatwg.org/.

Looks like an oversight in the spec, but that was the intent, yes.

@messense
Copy link
Contributor Author

Happy to report that pip install correctly uses ssh://git@... in direct_url.json.

@messense
Copy link
Contributor Author

messense commented Feb 21, 2024

I'd expect the poetry maintainers would be willing to fix this

Seems like poetry is just writing out the source url specified in pyproject.toml to direct_url.json:
https://github.com/python-poetry/poetry/blob/cff4d7d51c9ac0f9a8b9ac91652b6dc20e63e203/src/poetry/installation/executor.py#L910-L922

I had something like

[tool.poetry.dependencies]
qpython = { git = "git@github.example.com:example/qPython.git", rev = "7190a34911a789bd8e44f6b1986c8e84815b62e2" }

in pyproject.toml following https://python-poetry.org/docs/dependency-specification/#git-dependencies.

@charliermarsh
Copy link
Member

We should at least handle this gracefully though, I think...

@charliermarsh charliermarsh self-assigned this Feb 21, 2024
charliermarsh added a commit that referenced this issue Feb 21, 2024
## Summary

Allows the corresponding `pypi_types` struct to use any URL, since other
installers can put those into the environment, and Poetry seems to write
invalid URLs.

If we see a distribution with an invalid URL, we just treat it as a
registry distribution, which isn't ideal, but is better than (1)
erroring, and (2) changing `Url` to `String` everywhere internally. (I'm
torn on this second option.)

Closes #1744.

## Test Plan

- Added `flask = { git = "git@github.com:pallets/flask.git", rev =
"b90a4f1f4a370e92054b9cc9db0efcb864f87ebe" }` to
`scripts/editable-installs/poetry_editable/pyproject.toml`.
- Ran `poetry install`.
- Ran `cargo pip freeze`. Verified that it errored on `main`, but passed
here.
- Ran `cargo run pip install "flask==3.0.0"`. Verified that it
uninstalled the existing Flask, and installed a new version from the
registry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants