Exemple #1
0
  def create(cls, parse_context, **kwargs):
    resources = kwargs.get('resources', None) or []
    if resources:
      deprecated_conditional(
        lambda: True,
        '1.5.0.dev0',
        'The `resources=` Python target argument', 'Depend on resources targets instead.'
      )
      resources_kwargs = dict(
        name=cls._suffix_for_synthetic_spec(kwargs.get('name', 'unknown')),
        sources=resources,
        type_alias=Resources.alias()
      )
      resource_target = parse_context.create_object(Resources.alias(), **resources_kwargs)
      if isinstance(resource_target, TargetAddressable):
        name = resource_target.addressed_name
      else:
        name = resource_target.name
      resource_target_spec = '//{}:{}'.format(parse_context.rel_path, name)
      kwargs['dependencies'] = kwargs.get('dependencies', []) + [resource_target_spec]

    parse_context.create_object(cls, type_alias=cls.alias(), **kwargs)
Exemple #2
0
    def create(cls, parse_context, **kwargs):
        resources = kwargs.get('resources', None) or []
        if resources:
            deprecated_conditional(lambda: True, '1.5.0.dev0',
                                   'The `resources=` Python target argument',
                                   'Depend on resources targets instead.')
            resources_kwargs = dict(name=cls._suffix_for_synthetic_spec(
                kwargs.get('name', 'unknown')),
                                    sources=resources,
                                    type_alias=Resources.alias())
            resource_target = parse_context.create_object(
                Resources.alias(), **resources_kwargs)
            if isinstance(resource_target, TargetAddressable):
                name = resource_target.addressed_name
            else:
                name = resource_target.name
            resource_target_spec = '//{}:{}'.format(parse_context.rel_path,
                                                    name)
            kwargs['dependencies'] = kwargs.get('dependencies',
                                                []) + [resource_target_spec]

        parse_context.create_object(cls, type_alias=cls.alias(), **kwargs)
Exemple #3
0
def build_file_aliases():
    return BuildFileAliases(targets={
        PythonBinary.alias(): PythonBinary,
        PythonLibrary.alias(): PythonLibrary,
        PythonTests.alias(): PythonTests,
        PythonDistribution.alias(): PythonDistribution,
        'python_requirement_library': PythonRequirementLibrary,
        Resources.alias(): Resources,
    },
                            objects={
                                'python_requirement': PythonRequirement,
                                'python_artifact': PythonArtifact,
                                'setup_py': PythonArtifact,
                            },
                            context_aware_object_factories={
                                'python_requirements': PythonRequirements,
                                'pants_requirement': PantsRequirement,
                            })
Exemple #4
0
def build_file_aliases():
  return BuildFileAliases(
    targets={
      PythonBinary.alias(): TargetMacro.Factory.wrap(PythonBinary.create, PythonBinary),
      PythonLibrary.alias(): TargetMacro.Factory.wrap(PythonLibrary.create, PythonLibrary),
      PythonTests.alias(): TargetMacro.Factory.wrap(PythonTests.create, PythonTests),
      'python_requirement_library': PythonRequirementLibrary,
      Resources.alias(): Resources,
    },
    objects={
      'python_requirement': PythonRequirement,
      'python_artifact': PythonArtifact,
      'setup_py': PythonArtifact,
    },
    context_aware_object_factories={
      'python_requirements': PythonRequirements,
      'pants_requirement': PantsRequirement,
    }
  )
Exemple #5
0
def build_file_aliases():
  return BuildFileAliases(
    targets={
      PythonBinary.alias(): PythonBinary,
      PythonLibrary.alias(): PythonLibrary,
      PythonTests.alias(): PythonTests,
      PythonDistribution.alias(): PythonDistribution,
      'python_requirement_library': PythonRequirementLibrary,
      Resources.alias(): Resources,
    },
    objects={
      'python_requirement': PythonRequirement,
      'python_artifact': PythonArtifact,
      'setup_py': PythonArtifact,
    },
    context_aware_object_factories={
      'python_requirements': PythonRequirements,
      'pants_requirement': PantsRequirement,
    }
  )
Exemple #6
0
def build_file_aliases():
    return BuildFileAliases(
        targets={
            PythonApp.alias(): PythonApp,
            PythonBinary.alias(): PythonBinary,
            PythonLibrary.alias(): PythonLibrary,
            PythonTests.alias(): PythonTests,
            PythonDistribution.alias(): PythonDistribution,
            "python_requirement_library": PythonRequirementLibrary,
            Resources.alias(): Resources,
            UnpackedWheels.alias(): UnpackedWheels,
        },
        objects={
            "python_requirement": PythonRequirement,
            "python_artifact": PythonArtifact,
            "setup_py": PythonArtifact,
        },
        context_aware_object_factories={
            "python_requirements": PythonRequirements,
            PantsRequirement.alias: PantsRequirement,
        },
    )
Exemple #7
0
def build_file_aliases():
    return BuildFileAliases(targets={
        PythonBinary.alias():
        TargetMacro.Factory.wrap(PythonBinary.create, PythonBinary),
        PythonLibrary.alias():
        TargetMacro.Factory.wrap(PythonLibrary.create, PythonLibrary),
        PythonTests.alias():
        TargetMacro.Factory.wrap(PythonTests.create, PythonTests),
        'python_requirement_library':
        PythonRequirementLibrary,
        Resources.alias():
        Resources,
    },
                            objects={
                                'python_requirement': PythonRequirement,
                                'python_artifact': PythonArtifact,
                                'setup_py': PythonArtifact,
                            },
                            context_aware_object_factories={
                                'python_requirements': PythonRequirements,
                                'pants_requirement': PantsRequirement,
                            })