<#6187 Add a platform constraints parameter to pyt...
# github-notifications
c
#6187 Add a platform constraints parameter to python_{library, dist, requirement_library} targets Issue created by CMLivingston Add support for the following use cases: 1. I have a python_requirement that is Linux-only and want to include it in a library that I maintain. It would be better for a clear error message indicating incompatible platforms than an opaque resolver error that requires the user to have knowledge of the python-repos in play and hidden details of the library/requirement's platform compatibility. Furthermore, the linter will fail currently if one tries to build a binary on osx due the the lint goal's dependency on pyprep (due to changes introduced in #5765), and this will cause lint runs to fail. The new feature I am proposing in this ticket will fix this in the interim while the long term solution for linting is under development (#5884). 2. I maintain a python_dist that contains platform-specific code and hence dependees can only build, test and run for the "current" platform. I would like to de-cruft the python_binary targets by not requiring authors to specify
platforms=("current")
, and take the responsibility off of the user for knowing to include this, potentially saving time and headache while debugging. This is useful because unlike (1), a python_dist does not need to be constrained to any platform in particular, and incompatibilities due to "this os only" requirements should be caught per the use case described in (1). I propose a new parameter for python{library, dist, requirement_library} targets (so essentially on the
PythonTarget
object): a
platform_constraints
parameter that accepts platforms strings in the exact same manner as
platforms
on the binary target. The running tasks would merge these constraints with the constraints found elsewhere and error out with a useful message if incompatibilities exist. pantsbuild/pants