Skip to content

Commit

Permalink
Link requirements targets to their source. (#6405)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jsirois authored and stuhood committed Aug 28, 2018
1 parent 58a6245 commit f8020c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 0 additions & 6 deletions 3rdparty/python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,3 @@ python_requirement_library(
python_requirement('s3-log-parse==0.1.1')
]
)

# NB: Needed only for tests: tests/python/pants_test/engine/legacy:graph.
files(
name='requirements_files',
sources=rglobs('**/requirements.txt'),
)
9 changes: 8 additions & 1 deletion src/python/pants/backend/python/python_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
name=requirements_file_target_name,
sources=[requirements_relpath])
requirements_dep = ':{}'.format(requirements_file_target_name)

for requirement in requirements:
req = self._parse_context.create_object('python_requirement', requirement,
repository=repository)
self._parse_context.create_object('python_requirement_library',
name=req.project_name,
requirements=[req])
requirements=[req],
dependencies=[requirements_dep])
1 change: 0 additions & 1 deletion tests/python/pants_test/engine/legacy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ python_tests(
sources = ['test_graph.py'],
dependencies = [
'3rdparty/python:mock',
'3rdparty/python:requirements_files',
'src/python/pants/bin',
'src/python/pants/build_graph',
'src/python/pants/engine/legacy:graph',
Expand Down

0 comments on commit f8020c6

Please sign in to comment.