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

Override a requirement with a Bazel target #385

Open
dhalperi opened this issue Nov 25, 2020 · 13 comments
Open

Override a requirement with a Bazel target #385

dhalperi opened this issue Nov 25, 2020 · 13 comments
Labels
Can Close? Will close in 30 days if there is no new activity type: feature request

Comments

@dhalperi
Copy link
Contributor

🚀 feature request

Relevant Rules

load("@rules_python//python:pip.bzl", "pip_install")

Description

We'd like to be able to override a requirement with a Bazel target. This is basically the rules_python equivalent of rules_jvm_external's override_targets directive.

Consider the case where we're using grpc and protobuf from Bazel, and an external python library depends on protobuf==3.13.0 (or whatever). I'd like to replace that dependency with "@com_google_protobuf//:protobuf_python" instead, so I'm not mixing pypi and Bazel versions of protobuf.

Describe the solution you'd like

I like the way that rules_jvm_external has done it.

Describe alternatives you've considered

ø

@github-actions
Copy link

github-actions bot commented Nov 5, 2021

This issue 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 Nov 5, 2021
@psigen
Copy link

psigen commented Nov 13, 2021

Bumping because I don't want this to be closed without anyone seeing it, it seems like a good idea 😓
Hopefully this keeps the stalebot away for a bit.

@github-actions github-actions bot removed the Can Close? Will close in 30 days if there is no new activity label Nov 13, 2021
@github-actions
Copy link

This issue 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 May 12, 2022
@dhalperi
Copy link
Contributor Author

Bumping because I don't want this to be closed without anyone seeing it, it seems like a good idea 😓
Hopefully this keeps the stalebot away for a bit.

@github-actions github-actions bot removed the Can Close? Will close in 30 days if there is no new activity label May 13, 2022
@philsc
Copy link
Contributor

philsc commented Oct 16, 2022

I pushed a branch to my fork here: philsc/rules_python@add-deps-injection...philsc:rules_python:add-target-override that should add this feature.

I'm proposing that this be done via an annotation:
philsc/rules_python@add-deps-injection...philsc:rules_python:add-target-override#diff-34dce464ac9dc63ca9a3f06b5950d01f57bf6a77fe9c5d39ed3160cec9c05628R46-R50

I can put it up as a PR once #853 is merged.

@github-actions
Copy link

This issue 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 Apr 14, 2023
@dhalperi
Copy link
Contributor Author

Bumping because I don't want this to be closed without anyone seeing it, it seems like a good idea 😓
Hopefully this keeps the stalebot away for a bit.

@github-actions github-actions bot removed the Can Close? Will close in 30 days if there is no new activity label Apr 15, 2023
@arrdem
Copy link
Contributor

arrdem commented Apr 20, 2023

This seems like a special case of the general gap between rules_go and rules_python wrt the patches= directive enabled by generating a static repository list.

@alexeagle
Copy link
Collaborator

I think this is handled in https://github.com/aspect-build/rules_py with upcoming work @mattem is open-sourcing that allows "virtual" dependencies, where the version of some import can be overridden by an application rather than always using the one provided transitively by a library target the application depends on.

Copy link

This issue 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 Mar 30, 2024
@aignas aignas removed the Can Close? Will close in 30 days if there is no new activity label Mar 31, 2024
@arrdem
Copy link
Contributor

arrdem commented Apr 3, 2024

We've wound up having to implement something like this. tensorflow has ah fragmented packaging, so we've wound up having to build a bunch of machinery so that py_library can recognize pseudo-labels generated by py_requirement and rewrite them into an appropriately chosen real rule label.

tensorflow is an especially nasty case of this because the name of the correct package to choose is contingent on the target platform and architecture, but since rules_python can only materialize 3rdparty repos for architectures matching the build host that means the correct choice of tensorflow is defined by host-specific workspace configuration which we already have to choose the "right" requirements.txt lock for the current platform.

Significantly we can't use select() to implement the same behavior by say creating an alias rule across underlying tensorflow labels because in most build configurations most of the arms of the select would point to lables in external workspaces that can't be fetched/materialized and thus break lots of different analysis usage.

Copy link

This issue 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 Sep 30, 2024
@dhalperi
Copy link
Contributor Author

dhalperi commented Sep 30, 2024 via email

alexeagle added a commit that referenced this issue Oct 1, 2024
The repo is actively maintained, but we've had a bunch of relevant issues be auto-closed by the bot. I haven't seen other active rulesets adopt this, so I don't think it makes sense to be the outlier.

Note, I introduced this configuration.

#385 as an example where users have to make comments to prevent things being marked stale.
github-merge-queue bot pushed a commit that referenced this issue Oct 1, 2024
The repo is actively maintained, but we've had a bunch of relevant
issues be auto-closed by the bot. I haven't seen other active rulesets
adopt this, so I don't think it makes sense to be the outlier.

Note, I introduced this configuration.

#385 as an example
where users have to make comments to prevent things being marked stale.
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 type: feature request
Projects
None yet
Development

No branches or pull requests

7 participants