def __init__(self, name, dependencies, is_meta): Target.__init__(self, name, is_meta) self._injected_deps = [] self.processed_dependencies = resolve(dependencies) self.add_label('internal') self.dependency_addresses = OrderedSet() self.dependencies = OrderedSet() self.internal_dependencies = OrderedSet() self.jar_dependencies = OrderedSet() # TODO(John Sirois): if meta targets were truly built outside parse contexts - we could instead # just use the more general check: if parsing: delay(doit) else: doit() # Fix how target _ids are built / addresses to not require a BUILD file - ie: support anonymous, # non-addressable targets - which is what meta-targets really are once created. if is_meta: # Meta targets are built outside any parse context - so update dependencies immediately self.update_dependencies(self.processed_dependencies) else: # Defer dependency resolution after parsing the current BUILD file to allow for forward # references self._post_construct(self.update_dependencies, self.processed_dependencies) self._post_construct(self.inject_dependencies)
def __init__(self, requirement, dynamic=False, repository=None, name=None, version_filter=None): self._requirement = Requirement.parse(requirement) self._name = name or self._requirement.project_name self._dynamic = dynamic self._repository = repository self._version_filter = version_filter or (lambda: True) Target.__init__(self, self._name, False)
def __init__(self, name, sources=None): Target.__init__(self, name) self.add_labels('sources') self.target_base = SourceRoot.find(self) self.sources = None self._sources = sources or []
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.sources = None self._sources = sources or []
def __init__(self, name, dependencies, exclusives=None): """name: The name of this module target, addressable via pants via the portion of the spec following the colon dependencies: one or more JarDependencies this JarLibrary bundles or Pants pointing to other JarLibraries or JavaTargets exclusives: An optional map of exclusives tags. See CheckExclusives for details. """ Target.__init__(self, name, exclusives=exclusives) if dependencies is None: raise TargetDefinitionException( self, "A dependencies list must be supplied even if empty.") self.add_labels('jars') self.dependencies = resolve(dependencies) self.dependency_addresses = set() for dependency in self.dependencies: if hasattr(dependency, 'address'): self.dependency_addresses.add(dependency.address) # If the dependency is one that supports exclusives, the JarLibrary's # exclusives should be added to it. if hasattr(dependency, 'declared_exclusives'): for k in self.declared_exclusives: dependency.declared_exclusives[ k] |= self.declared_exclusives[k]
def __init__(self, name, dependencies, is_meta): Target.__init__(self, name, is_meta) self.resolved_dependencies = OrderedSet() self.internal_dependencies = OrderedSet() self.jar_dependencies = OrderedSet() self.update_dependencies(dependencies)
def __init__(self, requirement, dynamic=False, repository=None, name=None, version_filter=None, exclusives=None): self._requirement = Requirement.parse(requirement) self._name = name or self._requirement.project_name self._dynamic = dynamic self._repository = repository self._version_filter = version_filter or (lambda: True) Target.__init__(self, self._name, exclusives=exclusives)
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:`twitter.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
def __init__(self, name, username=None, password=None): """ :name The name of these credentials :username Either a constant username value or else a callable that can fetch one :password Either a constant password value or else a callable that can fetch one """ Target.__init__(self, name) self._username = username if callable(username) else lambda: username self._password = password if callable(password) else lambda: password
def __init__(self, name, username=None, password=None): """ :name The name of these credentials :username Either a constant username value or else a callable that can fetch one :password Either a constant password value or else a callable that can fetch one """ Target.__init__(self, name, False) self._username = username if callable(username) else lambda: username self._password = password if callable(password) else lambda: password
def __init__(self, name, url, push_db): """name: an identifier for the repo url: the url used to access the repo and retrieve artifacts or artifact metadata push_db: the data file associated with this repo that records artifact push history""" Target.__init__(self, name, False) self.name = name self.url = url self.push_db = push_db
def __init__(self, name, url, push_db, exclusives=None): """name: an identifier for the repo url: the url used to access the repo and retrieve artifacts or artifact metadata push_db: the data file associated with this repo that records artifact push history""" Target.__init__(self, name, exclusives=exclusives) self.name = name self.url = url self.push_db = push_db
def __init__(self, name, dependencies): """name: The name of this module target, addressable via pants via the portion of the spec following the colon dependencies: one or more JarDependencies this JarLibrary bundles or Pants pointing to other JarLibraries or JavaTargets""" assert len(dependencies) > 0, "At least one dependency must be specified" Target.__init__(self, name, False) self.dependencies = dependencies
def __init__(self, name, dependencies): """name: The name of this module target, addressable via pants via the portion of the spec following the colon dependencies: one or more JarDependencies this JarLibrary bundles or Pants pointing to other JarLibraries or JavaTargets""" assert len( dependencies) > 0, "At least one dependency must be specified" Target.__init__(self, name, False) self.add_label('jars') self.dependencies = dependencies
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)
def __init__(self, name, dependencies): """name: The name of this module target, addressable via pants via the portion of the spec following the colon dependencies: one or more JarDependencies this JarLibrary bundles or Pants pointing to other JarLibraries or JavaTargets""" assert len(dependencies) > 0, "At least one dependency must be specified" Target.__init__(self, name, False) self.add_label('jars') self.dependencies = resolve(dependencies) self.dependency_addresses = set() for dependency in self.dependencies: if hasattr(dependency, 'address'): self.dependency_addresses.add(dependency.address)
def __init__(self, spec): # it's critical the spec is parsed 1st, the results are needed elsewhere in constructor flow parse_context = ParseContext.locate() def parse_address(): if spec.startswith(':'): # the :[target] could be in a sibling BUILD - so parse using the canonical address pathish = "%s:%s" % (parse_context.buildfile.canonical_relpath, spec[1:]) return Address.parse(parse_context.buildfile.root_dir, pathish, False) else: return Address.parse(parse_context.buildfile.root_dir, spec, False) self.address = parse_address() Target.__init__(self, self.address.target_name, False)
def __init__(self, spec): # it's critical the spec is parsed 1st, the results are needed elsewhere in constructor flow parse_context = ParseContext.locate() def parse_address(): if spec.startswith(':'): # the :[target] could be in a sibling BUILD - so parse using the canonical address pathish = "%s:%s" % (parse_context.buildfile.canonical_relpath, spec[1:]) return Address.parse(parse_context.buildfile.root_dir, pathish, False) else: return Address.parse(parse_context.buildfile.root_dir, spec, False) self.address = parse_address() # We must disable the re-init check, because our funky __getattr__ breaks it. # We're not involved in any multiple inheritance, so it's OK to disable it here. Target.__init__(self, self.address.target_name, False, reinit_check=False)
def __init__(self, name, dependencies): """name: The name of this module target, addressable via pants via the portion of the spec following the colon dependencies: one or more JarDependencies this JarLibrary bundles or Pants pointing to other JarLibraries or JavaTargets """ Target.__init__(self, name) if dependencies is None: raise TargetDefinitionException(self, "A dependencies list must be supplied even if empty.") self.add_labels('jars') self.dependencies = resolve(dependencies) self.dependency_addresses = set() for dependency in self.dependencies: if hasattr(dependency, 'address'): self.dependency_addresses.add(dependency.address)
def __init__(self, name, dependencies): """name: The name of this module target, addressable via pants via the portion of the spec following the colon dependencies: one or more JarDependencies this JarLibrary bundles or Pants pointing to other JarLibraries or JavaTargets """ Target.__init__(self, name) if dependencies is None: raise TargetDefinitionException( self, "A dependencies list must be supplied even if empty.") self.add_labels('jars') self.dependencies = resolve(dependencies) self.dependency_addresses = set() for dependency in self.dependencies: if hasattr(dependency, 'address'): self.dependency_addresses.add(dependency.address)
def __init__(self, spec): # it's critical the spec is parsed 1st, the results are needed elsewhere in constructor flow parse_context = ParseContext.locate() def parse_address(): if spec.startswith(':'): # the :[target] could be in a sibling BUILD - so parse using the canonical address pathish = "%s:%s" % (parse_context.buildfile.canonical_relpath, spec[1:]) return Address.parse(parse_context.buildfile.root_dir, pathish, False) else: return Address.parse(parse_context.buildfile.root_dir, spec, False) self.address = parse_address() # We must disable the re-init check, because our funky __getattr__ breaks it. # We're not involved in any multiple inheritance, so it's OK to disable it here. Target.__init__(self, self.address.target_name, reinit_check=False)
def __init__(self, name, dependencies, exclusives=None): 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() # TODO(John Sirois): just use the more general check: if parsing: delay(doit) else: doit() # Fix how target _ids are built / addresses to not require a BUILD file - ie: support anonymous, # non-addressable targets - which is what meta-targets really are once created. # Defer dependency resolution after parsing the current BUILD file to allow for forward # references self._post_construct(self.update_dependencies, self.processed_dependencies) self._post_construct(self.inject_dependencies)
def __init__(self, name, binary, bundles, basename=None): Target.__init__(self, name, is_meta=False) if not binary: raise TargetDefinitionException(self, 'binary is required') binaries = list(util.resolve(binary).resolve()) if len(binaries) != 1 or not isinstance(binaries[0], JvmBinary): raise TargetDefinitionException( self, 'must supply exactly 1 JvmBinary, got %s' % binary) self.binary = binaries[0] if not bundles: raise TargetDefinitionException(self, 'bundles must be specified') def is_resolvable(item): return hasattr(item, 'resolve') def is_bundle(bundle): return isinstance(bundle, Bundle) def resolve(item): return list(item.resolve()) if is_resolvable(item) else [None] if is_resolvable(bundles): bundles = resolve(bundles) self.bundles = [] try: for item in iter(bundles): for bundle in resolve(item): if not is_bundle(bundle): raise TypeError() self.bundles.append(bundle) except TypeError: raise TargetDefinitionException( self, 'bundles must be one or more Bundle objects, ' 'got %s' % bundles) self.basename = basename or name
def __init__(self, name, dependencies, exclusives=None): """name: The name of this module target, addressable via pants via the portion of the spec following the colon dependencies: one or more JarDependencies this JarLibrary bundles or Pants pointing to other JarLibraries or JavaTargets exclusives: An optional map of exclusives tags. See CheckExclusives for details. """ Target.__init__(self, name, exclusives=exclusives) if dependencies is None: raise TargetDefinitionException(self, "A dependencies list must be supplied even if empty.") self.add_labels('jars') self.dependencies = resolve(dependencies) self.dependency_addresses = set() for dependency in self.dependencies: if hasattr(dependency, 'address'): self.dependency_addresses.add(dependency.address) # If the dependency is one that supports exclusives, the JarLibrary's # exclusives should be added to it. if hasattr(dependency, 'declared_exclusives'): for k in self.declared_exclusives: dependency.declared_exclusives[k] |= self.declared_exclusives[k]
def __init__(self, name, binary, bundles, basename=None): Target.__init__(self, name, is_meta=False) if not binary: raise TargetDefinitionException(self, 'binary is required') binaries = list(util.resolve(binary).resolve()) if len(binaries) != 1 or not isinstance(binaries[0], JvmBinary): raise TargetDefinitionException(self, 'must supply exactly 1 JvmBinary, got %s' % binary) self.binary = binaries[0] if not bundles: raise TargetDefinitionException(self, 'bundles must be specified') def is_resolvable(item): return hasattr(item, 'resolve') def is_bundle(bundle): return isinstance(bundle, Bundle) def resolve(item): return list(item.resolve()) if is_resolvable(item) else [None] if is_resolvable(bundles): bundles = resolve(bundles) self.bundles = [] try: for item in iter(bundles): for bundle in resolve(item): if not is_bundle(bundle): raise TypeError() self.bundles.append(bundle) except TypeError: raise TargetDefinitionException(self, 'bundles must be one or more Bundle objects, ' 'got %s' % bundles) self.basename = basename or name
def __init__(self, target_base, name, is_meta = False): Target.__init__(self, name, is_meta) self.target_base = target_base
def __init__(self, name, url_builder, exclusives=None): """:url_builder a function that accepts a page target and an optional wiki :config dict and returns a tuple of (alias, fully qualified url).""" Target.__init__(self, name, exclusives=exclusives) self.url_builder = url_builder
def __init__(self, name, url_builder): """:url_builder a function that accepts a page target and an optional wiki :config dict and returns a tuple of (alias, fully qualified url).""" Target.__init__(self, name) self.url_builder = url_builder
def __init__(self, name, url_builder, exclusives=None): """:url_builder a function that accepts a page target and an optional wiki :config dict and returns a tuple of (alias, fully qualified url).""" Target.__init__(self, name, is_meta=False, exclusives=exclusives) self.url_builder = url_builder
def __init__(self, name, is_meta=False): Target.__init__(self, name, is_meta) self.add_label('sources') self.target_base = SourceRoot.find(self)
def __init__(self, name, dependencies=None, exclusives=None): Target.__init__(self, name, exclusives=exclusives) self.dependencies = OrderedSet(resolve(dependencies)) if dependencies else OrderedSet()
def __init__(self, name, is_meta=False): Target.__init__(self, name, is_meta) self.target_base = SourceRoot.find(self)
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:`twitter.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))
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:`twitter.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), )
def __init__(self, name, url_builder): """:url_builder a function that accepts a page target and an optional wiki :config dict and returns a tuple of (alias, fully qualified url).""" Target.__init__(self, name, is_meta=False) self.url_builder = url_builder
def __init__(self, target_base, name, is_meta = False): Target.__init__(self, name, is_meta) # TODO(John Sirois): rationalize constructor parameter and find_target_base self.target_base = target_base if target_base else self.find_target_base()