def __init__(self, name, sources=None, resources=None, dependencies=None, thrift_library='0.7'): """ name = Name of library source = thrift source file 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.) dependencies = other PythonLibraries, Eggs or internal Pants targets """ assert thrift_library in PythonThriftLibrary._VALID_LIBRARIES, \ 'Specified thrift library %s, but only %s are valid' % ( thrift_library, ' & '.join(PythonThriftLibrary._VALID_LIBRARIES)) def get_all_deps(): all_deps = OrderedSet() all_deps.update( Pants('3rdparty/python:thrift-%s' % thrift_library).resolve()) if dependencies: all_deps.update(dependencies) return all_deps PythonTarget.__init__(self, name, sources, resources, get_all_deps())
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:`twitter.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:`twitter.pants.targets.artifact.PythonArtifact`) to publish that represents this target outside the repo. :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, module, antlr_version = '3.1.3', sources = None, resources = None, dependencies = None): """ name = Name of library package = Python package to generate the parser in (there is no directive for this in ANTLR) sources = antlr source files 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.) dependencies = other PythonLibraries, Eggs or internal Pants targets """ def get_all_deps(): all_deps = OrderedSet() all_deps.update(Pants('3rdparty/python:antlr-%s' % antlr_version).resolve()) if dependencies: all_deps.update(dependencies) return all_deps PythonTarget.__init__(self, name, sources, resources, get_all_deps()) self.module = module self.antlr_version = antlr_version
def __init__(self, name, sources = None, resources = None, dependencies = None, thrift_library = '0.7'): """ name = Name of library source = thrift source file 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.) dependencies = other PythonLibraries, Eggs or internal Pants targets """ assert thrift_library in PythonThriftLibrary._VALID_LIBRARIES, \ 'Specified thrift library %s, but only %s are valid' % ( thrift_library, ' & '.join(PythonThriftLibrary._VALID_LIBRARIES)) def get_all_deps(): all_deps = OrderedSet() all_deps.update(Pants('3rdparty/python:thrift-%s' % thrift_library).resolve()) if dependencies: all_deps.update(dependencies) return all_deps PythonTarget.__init__(self, name, sources, resources, get_all_deps())
def __init__(self, name, sources=(), resources=(), dependencies=(), provides=None, module="", exclusives=None): """ name = Name of library sources = Python source files 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.) dependencies = other PythonLibraries, Eggs or internal Pants targets module = everything beneath module is relative to this module name, None if root namespace provides = A Python artifact that this library provides """ PythonTarget.__init__(self, name, sources, resources, dependencies, provides, exclusives=exclusives) self.module = module
def __init__(self, name, module, antlr_version = '3.1.3', sources = None, resources = None, dependencies = None, exclusives=None): """ name = Name of library package = Python package to generate the parser in (there is no directive for this in ANTLR) sources = antlr source files 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.) dependencies = other PythonLibraries, Eggs or internal Pants targets exclusives: An optional map of exclusives tags. See CheckExclusives for details. """ def get_all_deps(): all_deps = OrderedSet() all_deps.update(Pants('3rdparty/python:antlr-%s' % antlr_version).resolve()) if dependencies: all_deps.update(dependencies) return all_deps PythonTarget.__init__(self, name, sources, resources, get_all_deps(), exclusives=exclusives or {}) self.module = module self.antlr_version = antlr_version
def __init__(self, name, source, dependencies=None): """ name: target name source: the python source file that becomes this binary's __main__ dependencies: a list of other PythonLibrary or Pants targets this binary depends upon """ PythonTarget.__init__(self, name, [source], dependencies=dependencies)
def __init__(self, name, module, antlr_version = '3.1.3', sources = None, resources = None, dependencies = None, exclusives=None): """ :param name: Name of library :param module: everything beneath module is relative to this module name, None if root namespace :param antlr_version: :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:`twitter.pants.base.target.Target` instances this target depends on. :type dependencies: list of targets :param dict exclusives: An optional dict of exclusives tags. See CheckExclusives for details. """ def get_all_deps(): all_deps = OrderedSet() all_deps.update(Pants('3rdparty/python:antlr-%s' % antlr_version).resolve()) if dependencies: all_deps.update(dependencies) return all_deps PythonTarget.__init__(self, name, sources, resources, get_all_deps(), exclusives=exclusives) self.module = module self.antlr_version = antlr_version
def test_validation(self): with ParseContext.temp('PythonTargetTest/test_validation'): # Adding a JVM Artifact as a provides on a PythonTarget doesn't make a lot of sense. This test # sets up that very scenario, and verifies that pants throws a TargetDefinitionException. self.assertRaises(TargetDefinitionException, PythonTarget, name="one", sources=[], provides=Artifact(org='com.twitter', name='one-jar', repo=Repository( name='internal', url=None, push_db=None, exclusives=None))) name = "test-with-PythonArtifact" pa = PythonArtifact(name='foo', version='1.0', description='foo') # This test verifies that adding a 'setup_py' provides to a PythonTarget is okay. self.assertEquals( PythonTarget(name=name, provides=pa, sources=[]).name, name) name = "test-with-none" # This test verifies that having no provides is okay. self.assertEquals( PythonTarget(name=name, provides=None, sources=[]).name, name)
def __init__(self, requirement, name=None): self._requirement = Requirement.parse(requirement) self._name = name or self._requirement.project_name PythonTarget.__init__(self, name = self._name, sources = None, dependencies = None)
def __init__(self, name, sources=(), resources=(), dependencies=(), module=""): """ name = Name of library sources = Python source files 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.) dependencies = other PythonLibraries, Eggs or internal Pants targets module = everything beneath module is relative to this module name, None if root namespace """ PythonTarget.__init__(self, name, sources, resources, dependencies) self.module = module
def __init__(self, name, sources=(), resources=(), dependencies=(), provides=None, module="", exclusives=None): """ name = Name of library sources = Python source files 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.) dependencies = other PythonLibraries, Eggs or internal Pants targets module = everything beneath module is relative to this module name, None if root namespace provides = A Python artifact that this library provides exclusives: An optional map of exclusives tags. See CheckExclusives for details. """ PythonTarget.__init__(self, name, sources, resources, dependencies, provides, exclusives=exclusives) self.module = module
def __init__( self, name, sources, resources=None, dependencies=None, timeout=Amount(2, Time.MINUTES), soft_dependencies=False ): """ name / sources / resources / dependencies: See PythonLibrary target timeout: Amount of time before this test should be considered timed-out [Default: 2 minutes] soft_dependencies: Whether or not we should ignore dependency resolution errors for this test. [Default: False] """ self._timeout = timeout self._soft_dependencies = bool(soft_dependencies) PythonTarget.__init__(self, name, sources, resources, dependencies)
def __init__(self, name, sources, resources=None, dependencies=None, timeout=Amount(2, Time.MINUTES), soft_dependencies=False): """ name / sources / resources / dependencies: See PythonLibrary target timeout: Amount of time before this test should be considered timed-out [Default: 2 minutes] soft_dependencies: Whether or not we should ignore dependency resolution errors for this test. [Default: False] """ self._timeout = timeout self._soft_dependencies = bool(soft_dependencies) PythonTarget.__init__(self, name, sources, resources, dependencies) self.add_label('python') self.add_label('tests')
def __init__(self, name, sources, resources=None, dependencies=None, timeout=Amount(2, Time.MINUTES), coverage=None, soft_dependencies=False): """ name / sources / resources / dependencies: See PythonLibrary target timeout: Amount of time before this test should be considered timed-out [Default: 2 minutes] soft_dependencies: Whether or not we should ignore dependency resolution errors for this test. [Default: False] coverage: the module(s) whose coverage should be generated, e.g. 'twitter.common.log' or ['twitter.common.log', 'twitter.common.http'] """ self._timeout = timeout self._soft_dependencies = bool(soft_dependencies) self._coverage = maybe_list(coverage) if coverage is not None else [] PythonTarget.__init__(self, name, sources, resources, dependencies) self.add_labels('python', 'tests')
def __init__(self, name, dependencies=None): PythonTarget.__init__(self, name, (), (), dependencies)
def __init__(self, name, source=None, dependencies=None, entry_point=None, inherit_path=False, zip_safe=True, repositories=None, indices=None, ignore_errors=False, allow_pypi=False, platforms=(Platform.current(), ), interpreters=(sys.version[:3], )): """ name: target name source: the python source file that becomes this binary's __main__ [optional] if none specified, drops into an interpreter by default dependencies: a list of other PythonLibrary or Pants targets this binary depends upon entry_point: the default entry point for this binary (by default drops into the entry point defined by @source) inherit_path: inherit the sys.path of the environment that this binary runs in zip_safe: whether or not this binary is safe to run in compacted (zip-file) form repositories: a list of repositories to query for dependencies indices: a list of indices to use for packages allow_pypi: whether or not this binary should be allowed to hit pypi for dependency management platforms: the platforms to target when building this binary. by default the current platform. interpreters: the interpreter versions to target when building this binary. by default the current interpreter version (specify in the form: '2.6', '2.7', '3.2' etc.) """ if source is None and dependencies is None: raise TargetDefinitionException( 'ERROR: no source or dependencies declared for target %s' % name) if source and entry_point: raise TargetDefinitionException( 'Can only declare an entry_point if no source binary is specified.' ) if not isinstance(platforms, (list, tuple)) or not isinstance( interpreters, (list, tuple)): raise TargetDefinitionException( 'platforms and interpreters must be lists or tuples.') self._entry_point = entry_point self._inherit_path = bool(inherit_path) self._zip_safe = bool(zip_safe) self._platforms = platforms self._interpreters = interpreters self._repositories = repositories or [] self._indices = indices or [] self._allow_pypi = bool(allow_pypi) self._ignore_errors = bool(ignore_errors) PythonTarget.__init__(self, name, [] if source is None else [source], dependencies=dependencies)
def __init__(self, name, source=None, dependencies=None, entry_point=None, inherit_path=False, zip_safe=True, repositories=None, indices=None, ignore_errors=False, allow_pypi=False, platforms=(Platform.current(),), interpreters=(sys.version[:3],)): """ name: target name source: the python source file that becomes this binary's __main__ [optional] if none specified, drops into an interpreter by default dependencies: a list of other PythonLibrary or Pants targets this binary depends upon entry_point: the default entry point for this binary (by default drops into the entry point defined by @source) inherit_path: inherit the sys.path of the environment that this binary runs in zip_safe: whether or not this binary is safe to run in compacted (zip-file) form repositories: a list of repositories to query for dependencies indices: a list of indices to use for packages allow_pypi: whether or not this binary should be allowed to hit pypi for dependency management platforms: the platforms to target when building this binary. by default the current platform. interpreters: the interpreter versions to target when building this binary. by default the current interpreter version (specify in the form: '2.6', '2.7', '3.2' etc.) """ if source is None and dependencies is None: raise TargetDefinitionException( 'ERROR: no source or dependencies declared for target %s' % name) if source and entry_point: raise TargetDefinitionException( 'Can only declare an entry_point if no source binary is specified.') if not isinstance(platforms, (list, tuple)) or not isinstance(interpreters, (list, tuple)): raise TargetDefinitionException('platforms and interpreters must be lists or tuples.') self._entry_point = entry_point self._inherit_path = bool(inherit_path) self._zip_safe = bool(zip_safe) self._platforms = platforms self._interpreters = interpreters self._repositories = repositories or [] self._indices = indices or [] self._allow_pypi = bool(allow_pypi) self._ignore_errors = bool(ignore_errors) PythonTarget.__init__(self, name, [] if source is None else [source], dependencies=dependencies)
def __init__(self, name, sources, resources=None, dependencies=None): PythonTarget.__init__(self, name, sources, resources, dependencies)