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

fix: Use Bazel's built-in zstd support in _python_repository_impl. #1227

Closed
wants to merge 1 commit into from

Conversation

jiawen
Copy link

@jiawen jiawen commented May 15, 2023

Bazel has built-in support for zstd since 5.1. This simplifies the logic and makes python_repository work on systems where building from source fails.

@jiawen jiawen requested a review from f0rmiga as a code owner May 15, 2023 19:53
@google-cla
Copy link

google-cla bot commented May 15, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Bazel has built-in support for zstd [since 5.1](bazelbuild/bazel#15087).
This simplifies the logic and makes python_repository work on systems where building from source fails.
@jiawen
Copy link
Author

jiawen commented May 16, 2023

Thanks @f0rmiga! I'll obviously make CI pass before asking to merge.

@rickeylev
Copy link
Contributor

Can you please sync to head and resolve the merge conflicts?

CI also reports there are failures, something relating to setting file permissions for a directory that doesn't exist? They failed even after retrying, so they're likely legit.

@chrislovecnm
Copy link
Collaborator

@jiawen im going to mark this as a draft. When you have this passing CI please take it out of draft.

@chrislovecnm chrislovecnm marked this pull request as draft May 19, 2023 16:04
@jiawen
Copy link
Author

jiawen commented May 19, 2023

My apologies - my day job got in the way. Draft sounds good - looks like I have some fun chmod issues to resolve.

@jiawen
Copy link
Author

jiawen commented May 26, 2023

Argh, this PR uncovered some grungy indygreg packaging details. The existing code works because:

  • The .tar.gz files are all -install_only, so the contents are ["python/bin", "python/include", "python/lib", and "python/share"].
  • But the zst versions are "full". The contents are:
    • ["python/build/lib", "python/build/Modules", ...] (a couple of others)
    • ["python/install/bin", "python/install/include", "python/install/lib", and "python/install/share"]
    • (A few other files and dirs)

So the existing code happens to work because:

  • It uses rctx.download_and_extract in the .tar.gz case, which unpacks python/lib into the right place.
  • The zstd path uses tar --strip-components=2, which also unpacks the contents two levels deep into the right place. But interestingly, it relies on tar's behavior to merge the two lib directories together. It's obviously possible to do this with rctx.execute(["cp -R ...", ]) but this is somewhat irritating.

@rickeylev Any suggestions?

@aignas
Copy link
Collaborator

aignas commented Jun 5, 2023

FYI, the .tar.gz files were created due to indygreg/python-build-standalone#79 if I remember correctly.

@rickeylev
Copy link
Contributor

Perhaps the strip_prefix arg or rename_files arg of downloaded_and_extract? I don't really have ideas otherwise.

If a separate command has to be run after download_and_extract to merge the two directories, I'm not sure it'll be a net win. Maybe cp --link?

This ... makes python_repository work on systems where building from source fails.

I don't follow -- how does this PR fix building from source? This PR basically removes the need to have the zstd and tar tools locally available. What does that have to do with building from source?

Copy link

github-actions bot commented Dec 2, 2023

This Pull Request has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!

@github-actions github-actions bot added the Can Close? Will close in 30 days if there is no new activity label Dec 2, 2023
Copy link

github-actions bot commented Jan 1, 2024

This PR was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

@github-actions github-actions bot closed this Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? Will close in 30 days if there is no new activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants