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

[bazel,python] update rules_python and vendor in requirements.bzl #26090

Conversation

timothytrippel
Copy link
Contributor

Our current version of rules_python autogenerates the requirements.bzl file from a requirements.txt lock file. However, this is awkward if this project is ever a dependency of another downstream bazel project, as shown here: bazelbuild/rules_python#608

To circumvent this issue, rules_python provides a mechanism to vendor in the requirements.bzl file into the repo, which this commit does.

Additionally, this updates the rules_python version to match the master branch, and also updates the python-requirements.txt lock file.

This is part 1 of a series of changes that will re-enable airgapped builds with python dependencies.

@timothytrippel timothytrippel requested review from eshapira and removed request for a team, mundaym and msfschaffner January 31, 2025 23:36
This updates rules_python to 0.39.0 to match the version on the master
branch. See lowRISC#24781.

Signed-off-by: Tim Trippel <[email protected]>
@timothytrippel timothytrippel force-pushed the update-rules-python branch 2 times, most recently from 9d97e46 to b2c2529 Compare January 31, 2025 23:59
Comment on lines +24 to +36
cmd = " | ".join([
"cat $<",
# Substitute the name of the hub to ensure that the dependencies do
# not require the hub repo initialized in the WORKSPACE.
"sed -e 's/ot_python_deps/ot_python_deps_vendored/g'",
# Change the labels from using the hub repo to using the spoke repos
# directly.
"sed -e 's|//\\([^:]*\\):pkg|_\\1//:pkg|g'",
"sed -e 's|//\\([^:]*\\):whl|_\\1//:whl|g'",
"sed -e 's|//\\([^:]*\\):data|_\\1//:data|g'",
# Change the convenience macros to use the same naming.
"sed -e 's|//{}:{}|_{}//:{}|g' >$@",
]),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a cool way of building this pipeline while being able to intersperse comments.

FYI, I think you could do this with a single sed invocation if you wanted to:

sed \
    -e  's|...|...|g' \
    -e  's|...|...|g' \
    -e  's|...|...|g' \
    $< >$@

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good idea. Let me update this in a follow up.

Our current version of rules_python autogenerates the `requirements.bzl`
file from a `requirements.txt` lock file. However, this is awkward if
this project is ever a dependency of another downstream bazel project,
as shown here: bazelbuild/rules_python#608

To circumvent this issue, rules_python provides a mechanism to vendor in
the requirements.bzl file into the repo, which this commit does.

Signed-off-by: Tim Trippel <[email protected]>
@timothytrippel
Copy link
Contributor Author

submitted as part of #26091

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