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

localstack / localstack / 20565403496

29 Dec 2025 05:11AM UTC coverage: 84.103% (-2.8%) from 86.921%
20565403496

Pull #13567

github

web-flow
Merge 4816837a5 into 2417384aa
Pull Request #13567: Update ASF APIs

67166 of 79862 relevant lines covered (84.1%)

0.84 hits per line

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

89.47
/localstack-core/localstack/services/lambda_/packages.py
1
"""Package installers for external Lambda dependencies."""
2

3
import os
1✔
4
import stat
1✔
5
from functools import cache
1✔
6
from pathlib import Path
1✔
7

8
from localstack import config
1✔
9
from localstack.packages import DownloadInstaller, InstallTarget, Package, PackageInstaller
1✔
10
from localstack.utils.platform import get_arch
1✔
11

12
"""Customized LocalStack version of the AWS Lambda Runtime Interface Emulator (RIE).
1✔
13
https://github.com/localstack/lambda-runtime-init/blob/localstack/README-LOCALSTACK.md
14
"""
15
LAMBDA_RUNTIME_DEFAULT_VERSION = "v0.1.37-pre"
1✔
16
LAMBDA_RUNTIME_VERSION = config.LAMBDA_INIT_RELEASE_VERSION or LAMBDA_RUNTIME_DEFAULT_VERSION
1✔
17
LAMBDA_RUNTIME_INIT_URL = "https://github.com/localstack/lambda-runtime-init/releases/download/{version}/aws-lambda-rie-{arch}"
1✔
18

19
"""Unmaintained Java utilities and JUnit integration for LocalStack released to Maven Central.
1✔
20
https://github.com/localstack/localstack-java-utils
21
We recommend the Testcontainers LocalStack Java module as an alternative:
22
https://java.testcontainers.org/modules/localstack/
23
"""
24
LOCALSTACK_MAVEN_VERSION = "0.2.21"
1✔
25
MAVEN_REPO_URL = "https://repo1.maven.org/maven2"
1✔
26
URL_LOCALSTACK_FAT_JAR = (
1✔
27
    "{mvn_repo}/cloud/localstack/localstack-utils/{ver}/localstack-utils-{ver}-fat.jar"
28
)
29

30

31
class LambdaRuntimePackage(Package):
1✔
32
    """Golang binary containing the lambda-runtime-init."""
33

34
    def __init__(self, default_version: str = LAMBDA_RUNTIME_VERSION):
1✔
35
        super().__init__(name="Lambda", default_version=default_version)
1✔
36

37
    def get_versions(self) -> list[str]:
1✔
38
        return [LAMBDA_RUNTIME_VERSION]
1✔
39

40
    def _get_installer(self, version: str) -> PackageInstaller:
1✔
41
        return LambdaRuntimePackageInstaller(name="lambda-runtime", version=version)
1✔
42

43

44
class LambdaRuntimePackageInstaller(DownloadInstaller):
1✔
45
    """Installer for the lambda-runtime-init Golang binary."""
46

47
    # TODO: Architecture should ideally be configurable in the installer for proper cross-architecture support.
48
    # We currently hope the native binary works within emulated containers.
49
    def _get_arch(self):
1✔
50
        arch = get_arch()
1✔
51
        return "x86_64" if arch == "amd64" else arch
1✔
52

53
    def _get_download_url(self) -> str:
1✔
54
        arch = self._get_arch()
×
55
        return LAMBDA_RUNTIME_INIT_URL.format(version=self.version, arch=arch)
×
56

57
    def _get_install_dir(self, target: InstallTarget) -> str:
1✔
58
        install_dir = super()._get_install_dir(target)
1✔
59
        arch = self._get_arch()
1✔
60
        return os.path.join(install_dir, arch)
1✔
61

62
    def _get_install_marker_path(self, install_dir: str) -> str:
1✔
63
        return os.path.join(install_dir, "var", "rapid", "init")
1✔
64

65
    def _install(self, target: InstallTarget) -> None:
1✔
66
        super()._install(target)
×
67
        install_location = self.get_executable_path()
×
68
        st = os.stat(install_location)
×
69
        os.chmod(install_location, mode=st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
×
70

71

72
# TODO: replace usage in LocalStack tests with locally built Java jar and remove this unmaintained dependency.
73
class LambdaJavaPackage(Package):
1✔
74
    def __init__(self):
1✔
75
        super().__init__("LambdaJavaLibs", "0.2.22")
1✔
76

77
    def get_versions(self) -> list[str]:
1✔
78
        return ["0.2.22", "0.2.21"]
1✔
79

80
    def _get_installer(self, version: str) -> PackageInstaller:
1✔
81
        return LambdaJavaPackageInstaller("lambda-java-libs", version)
1✔
82

83

84
class LambdaJavaPackageInstaller(DownloadInstaller):
1✔
85
    def _get_download_url(self) -> str:
1✔
86
        return URL_LOCALSTACK_FAT_JAR.format(ver=self.version, mvn_repo=MAVEN_REPO_URL)
1✔
87

88

89
lambda_runtime_package = LambdaRuntimePackage()
1✔
90
lambda_java_libs_package = LambdaJavaPackage()
1✔
91

92

93
# TODO: handle architecture-specific installer and caching because we currently assume that the lambda-runtime-init
94
#   Golang binary is cross-architecture compatible.
95
@cache
1✔
96
def get_runtime_client_path() -> Path:
1✔
97
    installer = lambda_runtime_package.get_installer()
1✔
98
    installer.install()
1✔
99
    return Path(installer.get_installed_dir())
1✔
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