def __init__(self, name, sources=(), resources=(), dependencies=(), provides=None, compatibility=None, exclusives=None): """ :param name: Name of library :param sources: A list of filenames representing the source code this library is compiled from. :type sources: list of strings :param resources: non-Python resources, e.g. templates, keys, other data (it is recommended that your application uses the pkgutil package to access these resources in a .zip-module friendly way.) :param dependencies: List of :class:`pants.base.target.Target` instances this target depends on. :type dependencies: list of targets :param provides: The :ref:`setup_py <bdict_setup_py>` (implemented by :class:`pants.targets.artifact.PythonArtifact`) to publish that represents this target outside the repo. :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. :param dict exclusives: An optional dict of exclusives tags. See CheckExclusives for details. """ PythonTarget.__init__(self, name, sources=sources, resources=resources, dependencies=dependencies, provides=provides, compatibility=compatibility, exclusives=exclusives, )
def __init__(self, name, source=None, dependencies=None, entry_point=None, inherit_path=False, # pex option zip_safe=True, # pex option always_write_cache=False, # pex option repositories=None, # pex option indices=None, # pex option ignore_errors=False, # pex option allow_pypi=False, # pex option platforms=(), compatibility=None, exclusives=None): """ :param name: target name :param source: the python source file that becomes this binary's __main__. If None specified, drops into an interpreter by default. :param dependencies: List of :class:`pants.base.target.Target` instances this target depends on. :type dependencies: list of targets :param entry_point: the default entry point for this binary. if None, drops into the entry point that is defined by source :param inherit_path: inherit the sys.path of the environment that this binary runs in :param zip_safe: whether or not this binary is safe to run in compacted (zip-file) form :param always_write_cache: whether or not the .deps cache of this PEX file should always be written to disk. :param repositories: a list of repositories to query for dependencies. :param indices: a list of indices to use for packages. :param platforms: extra platforms to target when building this binary. :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. :param dict exclusives: An optional dict of exclusives tags. See CheckExclusives for details. """ # TODO(John Sirois): Fixup TargetDefinitionException - it has awkward Target base-class # initialization requirements right now requiring this Target.__init__. Target.__init__(self, name, exclusives=exclusives) if source is None and entry_point is None: raise TargetDefinitionException(self, 'A python binary target must specify either source or entry_point.') PythonTarget.__init__(self, name, [] if source is None else [source], compatibility=compatibility, dependencies=dependencies, exclusives=exclusives, ) if not isinstance(platforms, (list, tuple)) and not isinstance(platforms, Compatibility.string): raise TargetDefinitionException(self, 'platforms must be a list, tuple or string.') self._entry_point = entry_point self._inherit_path = bool(inherit_path) self._zip_safe = bool(zip_safe) self._always_write_cache = bool(always_write_cache) self._repositories = maybe_list(repositories or []) self._indices = maybe_list(indices or []) self._ignore_errors = bool(ignore_errors) self._platforms = tuple(maybe_list(platforms or [])) if source and entry_point: entry_point_module = entry_point.split(':', 1)[0] source_entry_point = self._translate_to_entry_point(self.sources[0]) if entry_point_module != source_entry_point: raise TargetDefinitionException(self, 'Specified both source and entry_point but they do not agree: %s vs %s' % ( source_entry_point, entry_point_module))