Skip to content

Commit

Permalink
PythonDistribution -> inherit Target instead of PythonTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Vital authored and Chris Livingston committed Jan 30, 2018
1 parent 7297096 commit 9bb228f
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions src/python/pants/backend/python/targets/python_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,56 @@
from pants.base.payload import Payload
from pants.base.payload_field import PrimitiveField

class PythonDistribution(PythonTarget):
class PythonDistribution(Target):
"""A Python distribution.
"""

default_sources_globs = '*.py'

def __init__(self,
address=None,
payload=None,
sources=None,
compatibility=None,
**kwargs):
"""
:param dependencies: The addresses of targets that this target depends on.
These dependencies may
be ``python_library``-like targets (``python_library``,
``python_thrift_library``, ``python_antlr_library`` and so forth) or
``python_requirement_library`` targets.
:type dependencies: list of strings
:param sources: Files to "include". Paths are relative to the
BUILD file's directory.
:type sources: ``Fileset`` or list of strings
:param resource_targets: The addresses of ``resources`` targets this target
depends on.
:param compatibility: either a string or list of strings that represents
interpreter compatibility for this target, using the Requirement-style
format, e.g. ``'CPython>=3', or just ['>=2.7','<3']`` for requirements
agnostic to interpreter class.
"""
self.address = address
payload = payload or Payload()
payload.add_fields({
'sources': self.create_sources_field(sources, address.spec_path, key_arg='sources'),
'compatibility': PrimitiveField(maybe_list(compatibility or ())),
})
super(PythonDistribution, self).__init__(address=address, payload=payload, **kwargs)
self.add_labels('python')

# Check that the compatibility requirements are well-formed.
for req in self.payload.compatibility:
try:
PythonIdentity.parse_requirement(req)
except ValueError as e:
raise TargetDefinitionException(self, str(e))


@classmethod
def alias(cls):
return 'python_distribution'

return 'python_dist'

def __init__(self, **kwargs):
payload = Payload()
Expand Down

0 comments on commit 9bb228f

Please sign in to comment.