Fix resource handling for the python backend.

Review Request #2817 - Created Sept. 14, 2015 and submitted

Information
John Sirois
pants
jsirois/python_resource_targets/fix
309, 1841, 2191
4565fd8...
Reviewers
pants-reviews
benjyw, dturner-tw, kwlzn, molsen, patricklaw, tejal, zundel

Previously resource handling was broken in a few ways:
1. Resources targets in the same build file could not be addressed
via PythonTarget.resources because relative_to was not passed to
the build_graph.
2. Since resource targets were not modelled as dependencies, they
could not be found via the PythonTarget.resources property since
they never were loaded into the build graph.
3. SetupPy only honored resources set via the PythonTarget
resources constructor parameter.

This change fixes resources to be modelled as dependencies like they
are for JvmTarget, solving 2 above, and fixes resources target
resolution to use relative_to solving 1 above. SetupPy now reads
resources from the fixed PythonTarget.resources property and gathers
resource sources like it does for all other dependencies fixing 3
above.

All existing python targets are updated to use target_resources
instead of resources as dogfood and a unit test is added to ensure
both modes of expressing resources work.

src/python/pants/backend/core/tasks/BUILD | 41 +++++++++++++++++---
src/python/pants/backend/jvm/BUILD | 10 ++++-
src/python/pants/backend/jvm/tasks/BUILD | 9 ++++-
src/python/pants/backend/project_info/tasks/BUILD | 27 ++++++++++++--
src/python/pants/backend/python/BUILD | 8 ++--
src/python/pants/backend/python/python_chroot.py | 4 +-
src/python/pants/backend/python/targets/BUILD | 5 +++
src/python/pants/backend/python/targets/python_target.py | 41 ++++++++++++--------
src/python/pants/backend/python/tasks/BUILD | 13 ++++++-
src/python/pants/backend/python/tasks/setup_py.py | 14 +++++--
src/python/pants/java/distribution/BUILD | 15 ++++++--
src/python/pants/reporting/BUILD | 23 ++++++++----
tests/python/pants_test/backend/jvm/tasks/jvm_compile/BUILD | 7 ++--
tests/python/pants_test/backend/jvm/tasks/jvm_compile/test_resource_mapping.py | 21 ++++++-----
tests/python/pants_test/backend/python/tasks/BUILD | 6 +++
tests/python/pants_test/backend/python/tasks/test_setup_py.py | 101 +++++++++++++++++++++++++++++++++++++++++---------
tests/python/pants_test/targets/BUILD | 6 +--
tests/python/pants_test/targets/test_python_target.py | 53 +++++++++++++++++---------
18 files changed, 304 insertions(+), 100 deletions(-)

CI went green here:
  https://travis-ci.org/pantsbuild/pants/builds/80315273
John Sirois
Stu Hood
John Sirois
Kris Wilson
John Sirois
Review request changed

Status: Closed (submitted)

Loading...