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

Added support for custom strip_prefix args in toolchains #664

Merged
merged 3 commits into from
Mar 20, 2022

Conversation

UebelAndre
Copy link
Contributor

@UebelAndre UebelAndre commented Mar 19, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Not all toolchains are packaged the same. Even older releases of https://github.com/indygreg/python-build-standalone have different archive structures which are incompatible with how toolchains are currently setup.

Issue Number: N/A

What is the new behavior?

This change allows for a strip_prefix key to be added to python_register_toolchains.tool_versions so that users can use reasonably different archive layouts.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

"""

url = tool_versions[python_version]["url"]

if type(url) == type({}):
url = url[platform]

strip_prefix = tool_versions[python_version].get("strip_prefix", None)
if type(strip_prefix) == type({}):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would require introducing a dependency on bazel-skylib or vendoring this file which I think would be better done in an explicit cleanup PR. Does that sound reasonable?

Copy link
Collaborator

Choose a reason for hiding this comment

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

sure - but I'm pretty sure rules_python already requires users to have bazel-skylib installed? agree we shouldn't add a new dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not aware of that being a requirement. If that's the case, it'd be nice if there was a python_rules_dependencies macro that loaded all dependencies (adhering to bazel-contrib).

python/repositories.bzl Show resolved Hide resolved
@@ -34,6 +34,7 @@ TOOL_VERSIONS = {
"x86_64-apple-darwin": "8d06bec08db8cdd0f64f4f05ee892cf2fcbc58cfb1dd69da2caab78fac420238",
"x86_64-unknown-linux-gnu": "aec8c4c53373b90be7e2131093caa26063be6d9d826f599c935c0e1042af3355",
},
"strip_prefix": "python",
Copy link
Collaborator

Choose a reason for hiding this comment

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

curious, are these required here? or are you just being explicit by setting this to the default value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's kinda both. There's no default so without this the toolchain would not be structured correctly. So to continue to have these particular ones function correctly, I added the strip_prefixes. I kinda like having these here since I noticed the archive structure changed some time ago. Looking at https://github.com/indygreg/python-build-standalone/releases/tag/20200822, the toolchains are in a python/install directory. My hope in adding these here is that it'd draw attention to the fact that this might be needed to get toolchains working.

@alexeagle alexeagle merged commit 0f18997 into bazelbuild:main Mar 20, 2022
@UebelAndre UebelAndre deleted the prefix branch March 21, 2022 02:04
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.

2 participants