Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only resolve requirements from PythonRequirementLibrary targets for s…
…etup_requires in python_dist() (pantsbuild#8442) # Problem I created https://github.com/cosmicexplorer/example-pants-python-dist today to showcase how to use a pants `python_dist()` target to wrap an existing setup.py-based project, namely https://github.com/facebookresearch/maskrcnn-benchmark. This didn't immediately work, because the build graph's `.resolve()` method for the address spec of a `PythonRequirementLibrary` created from the `python_requirements()` build file macro returns a `Files` target in addition to the requested `PythonRequirementLibrary` target. ### Solution - Only read requirements from `PythonRequirementLibrary` targets returned by `self.context.build_graph.resolve()`. ### Result After checking out this pants PR and cd-ing into a clone of https://github.com/cosmicexplorer/example-pants-python-dist, you can run: ```bash > /path/to/your/pants/checkout/of/this/PR/pants run example-usage-of-python-dist-lib/bin ... ['DEPRECATED_KEYS', 'IMMUTABLE', 'NEW_ALLOWED', 'RENAMED_KEYS', '__class__', '__contains__', '__delattr__', '__delitem__', '__deprecated_keys__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__immutable__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__new_allowed__', '__reduce__', '__reduce_ex__', '__renamed_keys__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_create_config_tree_from_dict', '_decode_cfg_value', '_immutable', '_load_cfg_from_file', '_load_cfg_from_yaml_str', '_load_cfg_py_source', 'clear', 'clone', 'copy', 'defrost', 'dump', 'freeze', 'fromkeys', 'get', 'is_frozen', 'is_new_allowed', 'items', 'key_is_deprecated', 'key_is_renamed', 'keys', 'load_cfg', 'merge_from_file', 'merge_from_list', 'merge_from_other_cfg', 'pop', 'popitem', 'raise_key_rename_error', 'register_deprecated_key', 'register_renamed_key', 'setdefault', 'update', 'values'] ```
- Loading branch information