• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/python/pants/backend/awslambda/python/rules.py
1
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from __future__ import annotations
×
5

UNCOV
6
import logging
×
UNCOV
7
from dataclasses import dataclass
×
8

UNCOV
9
from pants.backend.awslambda.python.target_types import (
×
10
    AWSLambdaArchitectureField,
11
    PythonAWSLambda,
12
    PythonAwsLambdaHandlerField,
13
    PythonAwsLambdaIncludeRequirements,
14
    PythonAwsLambdaIncludeSources,
15
    PythonAWSLambdaLayer,
16
    PythonAwsLambdaLayerDependenciesField,
17
    PythonAwsLambdaRuntime,
18
)
UNCOV
19
from pants.backend.python.util_rules.faas import (
×
20
    BuildPythonFaaSRequest,
21
    FaaSArchitecture,
22
    PythonFaaSCompletePlatforms,
23
    PythonFaaSLayoutField,
24
    PythonFaaSPex3VenvCreateExtraArgsField,
25
    PythonFaaSPexBuildExtraArgs,
26
    build_python_faas,
27
)
UNCOV
28
from pants.backend.python.util_rules.faas import rules as faas_rules
×
UNCOV
29
from pants.core.environments.target_types import EnvironmentField
×
UNCOV
30
from pants.core.goals.package import BuiltPackage, OutputPathField, PackageFieldSet
×
UNCOV
31
from pants.engine.rules import collect_rules, rule
×
UNCOV
32
from pants.engine.unions import UnionRule
×
UNCOV
33
from pants.util.logging import LogLevel
×
34

UNCOV
35
logger = logging.getLogger(__name__)
×
36

37

UNCOV
38
@dataclass(frozen=True)
×
UNCOV
39
class _BaseFieldSet(PackageFieldSet):
×
UNCOV
40
    include_requirements: PythonAwsLambdaIncludeRequirements
×
UNCOV
41
    runtime: PythonAwsLambdaRuntime
×
UNCOV
42
    architecture: AWSLambdaArchitectureField
×
UNCOV
43
    complete_platforms: PythonFaaSCompletePlatforms
×
UNCOV
44
    pex3_venv_create_extra_args: PythonFaaSPex3VenvCreateExtraArgsField
×
UNCOV
45
    pex_build_extra_args: PythonFaaSPexBuildExtraArgs
×
UNCOV
46
    layout: PythonFaaSLayoutField
×
UNCOV
47
    output_path: OutputPathField
×
UNCOV
48
    environment: EnvironmentField
×
49

50

UNCOV
51
@dataclass(frozen=True)
×
UNCOV
52
class PythonAwsLambdaFieldSet(_BaseFieldSet):
×
UNCOV
53
    required_fields = (PythonAwsLambdaHandlerField,)
×
54

UNCOV
55
    handler: PythonAwsLambdaHandlerField
×
56

57

UNCOV
58
@dataclass(frozen=True)
×
UNCOV
59
class PythonAwsLambdaLayerFieldSet(_BaseFieldSet):
×
UNCOV
60
    required_fields = (PythonAwsLambdaLayerDependenciesField,)
×
61

UNCOV
62
    dependencies: PythonAwsLambdaLayerDependenciesField
×
UNCOV
63
    include_sources: PythonAwsLambdaIncludeSources
×
64

65

UNCOV
66
@rule(desc="Create Python AWS Lambda Function", level=LogLevel.DEBUG)
×
UNCOV
67
async def package_python_aws_lambda_function(
×
68
    field_set: PythonAwsLambdaFieldSet,
69
) -> BuiltPackage:
UNCOV
70
    return await build_python_faas(
×
71
        BuildPythonFaaSRequest(
72
            address=field_set.address,
73
            target_name=PythonAWSLambda.alias,
74
            complete_platforms=field_set.complete_platforms,
75
            runtime=field_set.runtime,
76
            architecture=FaaSArchitecture(field_set.architecture.value),
77
            handler=field_set.handler,
78
            output_path=field_set.output_path,
79
            include_requirements=field_set.include_requirements.value,
80
            include_sources=True,
81
            pex3_venv_create_extra_args=field_set.pex3_venv_create_extra_args,
82
            pex_build_extra_args=field_set.pex_build_extra_args,
83
            layout=field_set.layout,
84
            reexported_handler_module=PythonAwsLambdaHandlerField.reexported_handler_module,
85
        )
86
    )
87

88

UNCOV
89
@rule(desc="Create Python AWS Lambda Layer", level=LogLevel.DEBUG)
×
UNCOV
90
async def package_python_aws_lambda_layer(
×
91
    field_set: PythonAwsLambdaLayerFieldSet,
92
) -> BuiltPackage:
UNCOV
93
    return await build_python_faas(
×
94
        BuildPythonFaaSRequest(
95
            address=field_set.address,
96
            target_name=PythonAWSLambdaLayer.alias,
97
            complete_platforms=field_set.complete_platforms,
98
            runtime=field_set.runtime,
99
            architecture=FaaSArchitecture(field_set.architecture.value),
100
            output_path=field_set.output_path,
101
            include_requirements=field_set.include_requirements.value,
102
            include_sources=field_set.include_sources.value,
103
            pex3_venv_create_extra_args=field_set.pex3_venv_create_extra_args,
104
            pex_build_extra_args=field_set.pex_build_extra_args,
105
            layout=field_set.layout,
106
            # See
107
            # https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path
108
            #
109
            # Runtime | Path
110
            # ...
111
            # Python  | `python`
112
            #         | `python/lib/python3.10/site-packages`
113
            # ...
114
            #
115
            # The one independent on the runtime-version is more convenient:
116
            prefix_in_artifact="python",
117
            # a layer doesn't have a handler, just pulls in things via `dependencies`
118
            handler=None,
119
            reexported_handler_module=None,
120
        )
121
    )
122

123

UNCOV
124
def rules():
×
UNCOV
125
    return [
×
126
        *collect_rules(),
127
        UnionRule(PackageFieldSet, PythonAwsLambdaFieldSet),
128
        UnionRule(PackageFieldSet, PythonAwsLambdaLayerFieldSet),
129
        *faas_rules(),
130
    ]
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc