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

uv pip compile fails to build pylzma dependency #1768

Closed
carno opened this issue Feb 20, 2024 · 3 comments · Fixed by #1782
Closed

uv pip compile fails to build pylzma dependency #1768

carno opened this issue Feb 20, 2024 · 3 comments · Fixed by #1782
Assignees
Labels
bug Something isn't working

Comments

@carno
Copy link

carno commented Feb 20, 2024

As far as I understand this is more of a pylzma issue, but as it works with pip-compile I will leave it here in case it's something worth a workaround aka "correction for a common mistake" as mentioned in #1528 (comment)

If I'm not mistaken, the culprit is in how pylzma generates it's version when being built locally: https://github.com/fancycode/pylzma/blob/master/version.py

As I run uv pip compile in Docker, in a gitlab runner, it adds hash of my repository to the version string (at least the part after -g matches that)…

$ uv --version
uv 0.1.5
$ uv pip compile --output-file=- images/common/requirements.in
error: Failed to download and build: pylzma==0.5.0
  Caused by: Failed to build: pylzma==0.5.0
  Caused by: Build backend failed to determine extra requires with `build_wheel()`:
--- stdout:
--- stderr:
Traceback (most recent call last):
  File "<string>", line 10, in <module>
  File "/builds/redacted/.cache/uv/.tmpHEBm3b/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=['wheel'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/redacted/.cache/uv/.tmpHEBm3b/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
    self.run_setup()
  File "/builds/redacted/.cache/uv/.tmpHEBm3b/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 480, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/builds/redacted/.cache/uv/.tmpHEBm3b/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
    exec(code, locals())
  File "<string>", line 189, in <module>
  File "/builds/redacted/.cache/uv/.tmpHEBm3b/.venv/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/redacted/.cache/uv/.tmpHEBm3b/.venv/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 147, in setup
    _setup_distribution = dist = klass(attrs)
                                 ^^^^^^^^^^^^
  File "/builds/redacted/.cache/uv/.tmpHEBm3b/.venv/lib/python3.11/site-packages/setuptools/dist.py", line 314, in __init__
    self.metadata.version = self._normalize_version(self.metadata.version)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/redacted/.cache/uv/.tmpHEBm3b/.venv/lib/python3.11/site-packages/setuptools/dist.py", line 350, in _normalize_version
    normalized = str(Version(version))
                     ^^^^^^^^^^^^^^^^
  File "/builds/redacted/.cache/uv/.tmpHEBm3b/.venv/lib/python3.11/site-packages/setuptools/_vendor/packaging/version.py", line 198, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: '15.0.0-744-gb2d6'
@charliermarsh
Copy link
Member

My guess is that pip does the build in a temporary directory outside of the project hierarchy, whereas we're doing it within a temporary directory in the .venv?

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

I consider this a bug though. I've seen it in other packages too.

@charliermarsh
Copy link
Member

Fixed in #1782.

charliermarsh added a commit that referenced this issue Feb 20, 2024
#1782)

## Summary

Some packages encode logic to embed the current commit SHA in the
version tag, when built within a Git repo. This typically results in an
invalid (non-compliant) version. Here's an example from `pylzma`:
https://github.com/fancycode/pylzma/blob/ccb0e7cff3f6ecd5d38e73e9ca35502d7d670176/version.py#L45.

This PR adds a phony, empty `.git` to the cache root, to ensure that any
`git` commands fail.

Closes #1768.

## Test Plan

- Create a tag on the current commit, like `v0.5.0`.
- Build `pylzma`, using a cache _within_ the repo:

```
rm -rf foo
cargo run venv
cargo run pip install "pylzma @ https://files.pythonhosted.org/packages/03/d8/10ef072c3cd4301a65a1b762b09eefa02baf8da23b9ea77ebe9546499975/pylzma-0.5.0.tar.gz" --verbose  --cache-dir bar
```
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.

2 participants