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

pantsbuild / pants / 18517631058

15 Oct 2025 04:18AM UTC coverage: 69.207% (-11.1%) from 80.267%
18517631058

Pull #22745

github

web-flow
Merge 642a76ca1 into 99919310e
Pull Request #22745: [windows] Add windows support in the stdio crate.

53815 of 77759 relevant lines covered (69.21%)

2.42 hits per line

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

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

4
from __future__ import annotations
×
5

6
import logging
×
7
from dataclasses import dataclass
×
8

9
from pants.backend.google_cloud_function.python.target_types import (
×
10
    PythonGoogleCloudFunction,
11
    PythonGoogleCloudFunctionHandlerField,
12
    PythonGoogleCloudFunctionRuntime,
13
    PythonGoogleCloudFunctionType,
14
)
15
from pants.backend.python.util_rules.faas import (
×
16
    BuildPythonFaaSRequest,
17
    FaaSArchitecture,
18
    PythonFaaSCompletePlatforms,
19
    PythonFaaSLayoutField,
20
    PythonFaaSPex3VenvCreateExtraArgsField,
21
    PythonFaaSPexBuildExtraArgs,
22
    build_python_faas,
23
)
24
from pants.backend.python.util_rules.faas import rules as faas_rules
×
25
from pants.core.environments.target_types import EnvironmentField
×
26
from pants.core.goals.package import BuiltPackage, OutputPathField, PackageFieldSet
×
27
from pants.engine.rules import collect_rules, rule
×
28
from pants.engine.unions import UnionRule
×
29
from pants.util.logging import LogLevel
×
30

31
logger = logging.getLogger(__name__)
×
32

33

34
@dataclass(frozen=True)
×
35
class PythonGoogleCloudFunctionFieldSet(PackageFieldSet):
×
36
    required_fields = (PythonGoogleCloudFunctionHandlerField,)
×
37

38
    handler: PythonGoogleCloudFunctionHandlerField
×
39
    runtime: PythonGoogleCloudFunctionRuntime
×
40
    complete_platforms: PythonFaaSCompletePlatforms
×
41
    pex3_venv_create_extra_args: PythonFaaSPex3VenvCreateExtraArgsField
×
42
    pex_build_extra_args: PythonFaaSPexBuildExtraArgs
×
43
    layout: PythonFaaSLayoutField
×
44
    type: PythonGoogleCloudFunctionType
×
45
    output_path: OutputPathField
×
46
    environment: EnvironmentField
×
47

48

49
@rule(desc="Create Python Google Cloud Function", level=LogLevel.DEBUG)
×
50
async def package_python_google_cloud_function(
×
51
    field_set: PythonGoogleCloudFunctionFieldSet,
52
) -> BuiltPackage:
53
    return await build_python_faas(
×
54
        BuildPythonFaaSRequest(
55
            address=field_set.address,
56
            target_name=PythonGoogleCloudFunction.alias,
57
            complete_platforms=field_set.complete_platforms,
58
            runtime=field_set.runtime,
59
            # GCF only supports x86_64 architecture for now.
60
            architecture=FaaSArchitecture.X86_64,
61
            handler=field_set.handler,
62
            pex3_venv_create_extra_args=field_set.pex3_venv_create_extra_args,
63
            pex_build_extra_args=field_set.pex_build_extra_args,
64
            layout=field_set.layout,
65
            output_path=field_set.output_path,
66
            include_requirements=True,
67
            include_sources=True,
68
            reexported_handler_module=PythonGoogleCloudFunctionHandlerField.reexported_handler_module,
69
            log_only_reexported_handler_func=True,
70
        )
71
    )
72

73

74
def rules():
×
75
    return [
×
76
        *collect_rules(),
77
        UnionRule(PackageFieldSet, PythonGoogleCloudFunctionFieldSet),
78
        *faas_rules(),
79
    ]
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