-
-
Notifications
You must be signed in to change notification settings - Fork 699
fix: add explicit data attribute to compile_pip_requirements and forward it to the generated py_binary
#3865
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| (compile_pip_requirements) Add the explicit `data` attribute and forward it to | ||
| the generated `py_binary`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ def pip_compile( | |
| visibility = ["//visibility:private"], | ||
| tags = None, | ||
| constraints = [], | ||
| data = [], | ||
| **kwargs): | ||
| """Generates targets for managing pip dependencies with pip-compile (piptools). | ||
|
|
||
|
|
@@ -81,6 +82,7 @@ def pip_compile( | |
| tags: tagging attribute common to all build rules, passed to both the _test and .update rules. | ||
| visibility: passed to both the _test and .update rules. | ||
| constraints: a list of files containing constraints to pass to pip-compile with `--constraint`. | ||
| data: A list of labels to include as part of the `data` attribute in the generated `py_binary`. | ||
| **kwargs: other bazel attributes passed to the "_test" rule. | ||
| """ | ||
| if len([x for x in [srcs, src, requirements_in] if x != None]) > 1: | ||
|
|
@@ -95,16 +97,18 @@ def pip_compile( | |
|
|
||
| requirements_txt = name + ".txt" if requirements_txt == None else requirements_txt | ||
|
|
||
| data = data or [] | ||
|
|
||
| # "Default" target produced by this macro | ||
| # Allow a compile_pip_requirements rule to include another one in the data | ||
| # for a requirements file that does `-r ../other/requirements.txt` | ||
| native.filegroup( | ||
| name = name, | ||
| srcs = kwargs.pop("data", []) + [requirements_txt], | ||
| srcs = data + [requirements_txt], | ||
| visibility = visibility, | ||
| ) | ||
|
|
||
| data = [name, requirements_txt] + srcs + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None] + constraints | ||
| data = data + [name, requirements_txt] + srcs + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None] + constraints | ||
|
aignas marked this conversation as resolved.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So to better understand how this was not working previously was because we were including the Out of curiosity, would the usecase have worked if the parameters did not use If my analysis is correct, please update the |
||
|
|
||
| # Use the Label constructor so this is expanded in the context of the file | ||
| # where it appears, which is to say, in @rules_python | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use
genqueryfor this target and not have the integration test at all?