Skip to main content

The plugin for poetry that allows you to build zip packages suited for serverless deployment like AWS Lambda, Google App Engine, Azure App Service, and more...

Project description

Poetry Plugin Lambda Build v2

Fixes the GroupNotFound module not found error when using the plugin with poetry v2

From Forked repo:

Poetry Plugin Lambda Build

The plugin for poetry that allows you to build zip packages suited for serverless deployment like AWS Lambda, Google App Engine, Azure App Service, and more...

Additionally it provides docker container support for build inside container

Test

Installation

poetry self add poetry-plugin-lambda-build

Execution

Configure pyproject.toml with the following configuration. This is example for AWS Lambda configuration

[tool.poetry-plugin-lambda-build]
docker-image = "public.ecr.aws/sam/build-python3.11:latest-x86_64"
docker-network = "host"
layer-artifact-path = "artifacts/layer.zip"
layer-install-dir = "python"
function-artifact-path = "artifacts/function.zip"

Running ...

poetry build-lambda

will build function and layer packages for AWS Lambda deployment inside public.ecr.aws/sam/build-python3.11:latest-x86_64 container.

artifacts
├── function.zip
└── layer.zip

Running ...

poetry build-lambda docker-image="public.ecr.aws/sam/build-python3.12:latest-x86_64"

will override docker-image value in config

Configuration Examples

AWS Lambda - all in one - dependencies and function in the same zip package - Default

[tool.poetry-plugin-lambda-build]
package-artifact-path = "package.zip"

AWS Lambda - all in one - layer package

[tool.poetry-plugin-lambda-build]
package-install-dir = "python"
package-artifact-path = "layer.zip"

AWS Lambda - separated - separate layer package and function package

[tool.poetry-plugin-lambda-build]
layer-artifact-path = "layer.zip"
layer-install-dir = "python"
function-artifact-path = "function.zip"

AWS Lambda - separated - separate layer package and function package build in docker container

[tool.poetry-plugin-lambda-build]
docker-image = "public.ecr.aws/sam/build-python3.11:latest-x86_64"
docker-network = "host"
layer-artifact-path = "layer.zip"
layer-install-dir = "python"
function-artifact-path = "function.zip"

Help

poetry build-lambda help
Description:
  Execute to build lambda lambda artifacts

Usage:
  build-lambda [options] [--] [<docker-image> [<docker-entrypoint> [<docker-environment> [<docker-dns> [<docker-network> [<docker-network-mode> [<docker-platform> [<package-artifact-path> [<package-install-dir> [<function-artifact-path> [<function-install-dir> [<layer-artifact-path> [<layer-install-dir> [<only> [<without> [<with> [<zip-compresslevel> [<zip-compression> [<pre-install-script>]]]]]]]]]]]]]]]]]]]

Arguments:
  docker-image               The image to run
  docker-entrypoint          The entrypoint for the container (comma separated string) [default: "/bin/bash"]
  docker-environment         Environment variables to set inside the container (comma separated string) ex. VAR_1=VALUE_1,VAR_2=VALUE_2
  docker-dns                 Set custom DNS servers (comma separated string)
  docker-network             The name of the network this container will be connected to at creation time [default: "host"]
  docker-network-mode        Network-mode
  docker-platform            Platform in the format os[/arch[/variant]]. Only used if the method needs to pull the requested image.
  package-artifact-path      Output package path (default: package.zip). Set the '.zip' extension to wrap the artifact into a zip package otherwise, output will be created in the directory. [default: "package.zip"]
  package-install-dir        Installation directory inside artifact for single package [default: ""]
  function-artifact-path     Output function package path. Set the '.zip' extension to wrap the artifact into a zip package otherwise, output will be created in the directory.
  function-install-dir       Installation directory inside artifact for function package [default: ""]
  layer-artifact-path        Output layer package path. Set the '.zip' extension to wrap the artifact into a zip package otherwise, output will be created in the directory.
  layer-install-dir          Installation directory inside artifact for layer package [default: ""]
  only                       The only dependency groups to include
  without                    The dependency groups to ignore
  with                       The optional dependency groups to include
  zip-compresslevel          None (default for the given compression type) or an integer specifying the level to pass to the compressor. When using ZIP_STORED or ZIP_LZMA this keyword has no effect. When using ZIP_DEFLATED integers 0 through 9 are accepted. When using ZIP_BZIP2 integers 1 through 9 are accepted.
  zip-compression            ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib), ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma) [default: "ZIP_STORED"]
  pre-install-script         The script that is executed before installation.

Options:
      --no-checksum              Enable to suppress checksum checking
      --docker-network-disabled  Disable networking
  -h, --help                 Display help for the given command. When no command is given display help for the list command.
  -q, --quiet                Do not output any message.
  -V, --version              Display this application version.
      --ansi                 Force ANSI output.
      --no-ansi              Disable ANSI output.
  -n, --no-interaction       Do not ask any interactive question.
      --no-plugins           Disables plugins.
      --no-cache             Disables Poetry source caches.
  -C, --directory=DIRECTORY  The working directory for the Poetry command (defaults to the current working directory).
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.

Tips

Mac users with Docker Desktops

Make sure to configure DOCKER_HOST properly

export DOCKER_HOST=unix:///Users/$USER/.docker/run/docker.sock

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poetry_plugin_lambda_build_v2-2.0.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

poetry_plugin_lambda_build_v2-2.0.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file poetry_plugin_lambda_build_v2-2.0.0.tar.gz.

File metadata

File hashes

Hashes for poetry_plugin_lambda_build_v2-2.0.0.tar.gz
Algorithm Hash digest
SHA256 e170111eac03ad154f3feb7fbefe9a28d589bcf074ab83619f5a1ee86f874874
MD5 eb189a84e1d31378cfb0f42d15522ac4
BLAKE2b-256 faf2ca565dd6509b2a0a9e6b81c0bc4858a160104a5a4d651099ef52ba3afc51

See more details on using hashes here.

Provenance

The following attestation bundles were made for poetry_plugin_lambda_build_v2-2.0.0.tar.gz:

Publisher: release.yml on philtremblay/poetry-plugin-lambda-build-v2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file poetry_plugin_lambda_build_v2-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for poetry_plugin_lambda_build_v2-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 908e5dd0b826ab58918d9bcde903b1bd31a8dbe5eb5568fe23c775438ced3c29
MD5 575995b2514adcff2e05a721c8d118ce
BLAKE2b-256 c58ffd771e097bb584c02b71c7fba6635fe763e4beb75fc6f10b27a5ecfc45e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for poetry_plugin_lambda_build_v2-2.0.0-py3-none-any.whl:

Publisher: release.yml on philtremblay/poetry-plugin-lambda-build-v2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page