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

Ensure that builds within the cache aren't considered Git repositories #1782

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

charliermarsh
Copy link
Member

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

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Relatedly, should we include an empty .gitignore in the checkouts bucket?

@charliermarsh
Copy link
Member Author

Yeah, that seems wise.

@charliermarsh charliermarsh merged commit f13d0ad into main Feb 20, 2024
7 checks passed
@charliermarsh charliermarsh deleted the charlie/git branch February 20, 2024 20:37
@charliermarsh
Copy link
Member Author

Perhaps worth mentioning that this does mean people can’t version the cache and check it into Git (I don’t think?).

@charliermarsh
Copy link
Member Author

I guess the “best” version of this would be to put the .git in the temporary directory when building, but then omit it when we persist the build to the cache.

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 this pull request may close these issues.

uv pip compile fails to build pylzma dependency
2 participants