From 3497401c1281186ea9c37f134be39da0bba1a327 Mon Sep 17 00:00:00 2001 From: Travis Crawford Date: Fri, 16 May 2014 16:49:58 -0700 Subject: [PATCH] Fix setup.py install_requires post targets refactor. With the target refactor PythonRequirementLibrary is now used rather than PythonRequirement when generating setup.py install_requires. At present this field is not populated leading to missing requirements and unisntallable pants-generated sdist's. Testing Done: ./build-support/bin/ci.sh Confirmed setup.py install_requires is now populated. Reviewed at https://rbcommons.com/s/twitter/r/368/ --- src/python/pants/commands/setup_py.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/python/pants/commands/setup_py.py b/src/python/pants/commands/setup_py.py index 4c8b56fedb8..0015364069a 100644 --- a/src/python/pants/commands/setup_py.py +++ b/src/python/pants/commands/setup_py.py @@ -16,17 +16,15 @@ from twitter.common.python.compatibility import string, to_bytes from twitter.common.python.installer import InstallerBase, Packager -from pants.base.address import Address from pants.base.build_environment import get_buildroot from pants.base.config import Config -from pants.base.target import Target from pants.base.exceptions import TargetDefinitionException from pants.commands.command import Command from pants.python.antlr_builder import PythonAntlrBuilder from pants.python.thrift_builder import PythonThriftBuilder from pants.targets.python_antlr_library import PythonAntlrLibrary from pants.targets.python_binary import PythonBinary -from pants.targets.python_requirement import PythonRequirement +from pants.targets.python_requirement_library import PythonRequirementLibrary from pants.targets.python_target import PythonTarget from pants.targets.python_thrift_library import PythonThriftLibrary @@ -324,11 +322,9 @@ def write_setup(self, root_target, chroot): install_requires = set() for dep in self.minified_dependencies(root_target): - if isinstance(dep, PythonRequirement): - install_requires.add(str(dep.requirement)) - elif isinstance(dep, PythonTarget) and dep.provides: - install_requires.add(dep.provides.key) - setup_keywords['install_requires'] = list(install_requires) + if isinstance(dep, PythonRequirementLibrary): + [install_requires.add(str(req.requirement)) for req in dep.payload.requirements] + setup_keywords['install_requires'] = sorted(list(install_requires)) for binary_name, entry_point in self.iter_entry_points(root_target): if 'entry_points' not in setup_keywords: