-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Link requirements targets to their source. #6405
Conversation
Previsouly the `python_requirements` macro would not link the `PythonRequirementLibrary` targets it generated from a requirements file to the requirement file itself, leading to invalidation bugs. We now do this by adding a dependency on the requirements file to each `PythonRequirementLibrary` generated. Fixes pantsbuild#6404
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.
Thanks!
An alternative implementation might be to add a default_sources_glob
and a sources
argument.
Adding a The
|
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.
The PythonRequirementLibrary is declared in a BUILD directly where the BUILD has a sibling requirements.txt. Now you get a bogus source dependency on requirments.txt for that PythonRequirementLibrary.
Got it. I was forgetting the relationship between the macro and the target type.
Thanks!
@@ -58,9 +58,16 @@ def __call__(self, requirements_relpath='requirements.txt'): | |||
raise ValueError('Only 1 --find-links url is supported per requirements file') | |||
repository = value | |||
|
|||
requirements_file_target_name = requirements_relpath | |||
self._parse_context.create_object('files', |
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.
Not sure how likely collisions are, but it would be good to make this name a bit more synthetic, and include the owning target's name as well... '__{}_files'.format(requirements_file_target_name)
?
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.
Saw this comment late. Right now the mainline case is a target named requirements.txt
(or foo.bob
if their requirements file is foo.bob
). Having that filename match a requirement name or hand-written target name seemed pretty unlikely to me. I can circle back with a follow-up PR if you think my unlikely guess underestimates things.
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.
Should be fine, unless we can imagine a case with multiple target owners of the same requirements files.
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.
That's not possible even prior to this change since the requirements would each be exported as targets named by their requirement key leading to a dup target for each of those.
Thanks for the quick turnaround! |
Previously the `python_requirements` macro would not link the `PythonRequirementLibrary` targets it generated from a requirements file to the requirement file itself, leading to invalidation bugs. We now do this by adding a dependency on the requirements file to each `PythonRequirementLibrary` generated. Fixes #6404
I've picked this to |
Previsouly the `python_requirements` macro would not link the `PythonRequirementLibrary` targets it generated from a requirements file to the requirement file itself, leading to invalidation bugs. We now do this by adding a dependency on the requirements file to each `PythonRequirementLibrary` generated. Fixes #6404
We don't want to invalidate sources based on arbitrary changes to requirements.txt, but we do need to depend on it so we know to recompute requirements. Previously this was achieved by synthesizing a files() target and adding a dep on it, in the python_requirements macro. However when we gather sources to operate on we have to include all files(), meaning we were invalidating the sources even on a whitespace change to requirements.txt. This change adds a new, internal, target type specially for the synthetic requirements.txt change, so that we can maintain a dependency, but rules can still filter out the actual file. Context: pantsbuild#6405
We don't want to invalidate sources based on arbitrary changes to requirements.txt, but we do need to depend on it so we know to recompute requirements. Previously this was achieved by synthesizing a files() target and adding a dep on it, in the python_requirements macro. However when we gather sources to operate on we have to include all files(), meaning we were invalidating the sources even on a whitespace change to requirements.txt. This change adds a new, internal, target type specially for the synthetic requirements.txt change, so that we can maintain a dependency, but rules can still filter out the actual file. Context: #6405
Previsouly the
python_requirements
macro would not link thePythonRequirementLibrary
targets it generated from a requirementsfile to the requirement file itself, leading to invalidation bugs. We
now do this by adding a dependency on the requirements file to each
PythonRequirementLibrary
generated.Fixes #6404