Example #1
0
  def __init__(self, name, sources=None, exclusives=None):
    Target.__init__(self, name, exclusives=exclusives)

    self.add_labels('sources')
    self.target_base = SourceRoot.find(self)
    self._unresolved_sources = sources or []
    self._resolved_sources = None
Example #2
0
 def __init__(self, name, url_builder, exclusives=None):
   """
   :param string name: The name of this target, which combined with this
     build file defines the target :class:`pants.base.address.Address`.
   :param url_builder: Function that accepts a page target and an optional wiki config dict.
   :returns: A tuple of (alias, fully qualified url).
   """
   Target.__init__(self, name, exclusives=exclusives)
   self.url_builder = url_builder
Example #3
0
 def __init__(self, name, username=None, password=None,
              exclusives=None):
   """
   :param string name: The name of these credentials.
   :param username: Either a constant username value or else a callable that can fetch one.
   :type username: string or callable
   :param password: Either a constant password value or else a callable that can fetch one.
   :type password: string or callable
   """
   Target.__init__(self, name, exclusives=exclusives)
   self._username = username if callable(username) else lambda: username
   self._password = password if callable(password) else lambda: password
Example #4
0
 def __init__(self, requirement, name=None, repository=None, version_filter=None, use_2to3=False,
              compatibility=None, exclusives=None):
   # TODO(wickman) Allow PythonRequirements to be specified using pip-style vcs or url identifiers,
   # e.g. git+https or just http://...
   self._requirement = Requirement.parse(requirement)
   self._repository = repository
   self._name = name or self._requirement.project_name
   self._use_2to3 = use_2to3
   self._version_filter = version_filter or (lambda py, pl: True)
   # TODO(wickman) Unify this with PythonTarget .compatibility
   self.compatibility = compatibility or ['']
   Target.__init__(self, self._name, exclusives=exclusives)
Example #5
0
  def __init__(self, name, dependencies, exclusives=None):
    """
    :param string name: The name of this module target, addressable via pants via the
      portion of the spec following the colon.
    :param dependencies: List of :class:`pants.base.target.Target` instances
      this target depends on.
    :type dependencies: list of targets
    """
    Target.__init__(self, name, exclusives=exclusives)
    self._injected_deps = []
    self._processed_dependencies = resolve(dependencies)

    self.add_labels('internal')
    self.dependency_addresses = OrderedSet()

    self._dependencies = OrderedSet()
    self._internal_dependencies = OrderedSet()
    self._jar_dependencies = OrderedSet()

    if dependencies:
      maybe_list(self._processed_dependencies,
                 expected_type=(ExternalDependency, AnonymousDeps, Target),
                 raise_type=partial(TargetDefinitionException, self))
Example #6
0
   def __init__(self, name, foo=None):
       """
 :param name: The name of this target.
 :param string foo: Another argument.
 """
       Target.__init__(self, name)
Example #7
0
 def __init__(self, name, foo=None):
   """
   :param name: The name of this target.
   :param string foo: Another argument.
   """
   Target.__init__(self, name)
Example #8
0
  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))
Example #9
0
 def __init__(self, name, dependencies=None, exclusives=None):
   Target.__init__(self, name, exclusives=exclusives)
   self.dependencies = OrderedSet(resolve(dependencies)) if dependencies else OrderedSet()