Skip to main content

Build AWS Lambda deployment packages (zip files) for Python projects

Project description

paketoi

Paketoi is a command-line tool for building AWS Lambda deployment packages (zip files) for Python projects.

The goal is to provide a single command to build the deployment package for simple projects using requirements.txt.

Assumptions

  • The dependencies for your project are specified in a requirements.txt file.
  • Any dependencies with native code have pre-built binary wheels for the target platform.

Installation

Paketoi is available on PyPI. The simplest way to install it globally is to use pipx:

pipx install paketoi

Usage

The tool is meant to be run in the directory that contains your project. The source code is assumed to reside in the working directory. The basic usage is:

paketoi -r <path to requirements.txt> <path to output file>

You can find all the command-line options with paketoi --help.

Command-line options

% paketoi --help
Usage: paketoi [OPTIONS] OUTPUT

  Build AWS Lambda deployment packages (zip files) for Python projects.

Options:
  -s, --source DIRECTORY          The source root of the project.
  -I, --include PATH              Files to be included, relative to the source
                                  root.
  -E, --exclude TEXT              Files to be excluded, relative to the source
                                  root.
  -r, --requirement TEXT          Path to requirements.txt.
  --runtime [3.8|3.9|3.10|3.11|3.12|3.13]
                                  Python version to target.
  --platform [x86_64|arm64]       Architecture to target.
  --default-excludes / --no-default-excludes
                                  Enable/disable the default exclusion list.
                                  (.git, .jj, .mypy_cache, .ruff_cache)
  --help                          Show this message and exit.

Python version and architecture

By default, dependencies are downloaded for Python 3.13 running on x86_64. You can change these options with --platform and --runtime options.

For example, to build a deployment package for Python 3.10 running on arm64, do this:

paketoi -r requirements.txt --runtime 3.10 --platform arm64 lambda.zip

Simple layout

.
├── lambda_function.py
└── requirements.txt

With the project layout like above, you can build a deployment package lambda.zip like this:

paketoi -r requirements.txt lambda.zip

src layout

.
├── requirements.txt
└── src
   └── lambda_function.py

When your lambda source is under the directory src, use -s src to set the source root.

paketoi -r requirements.txt -s src lambda.zip

Excluding files

.
├── requirements.txt
├── lambda_function.py
└── tests
   └── lambda_function_test.py

You can exclude files you do not need by using -E path. For example:

paketoi -r requirements.txt -E tests lambda.zip

Alternatives

Developing paketoi

This project uses Poetry as the package manager and just as the command runner. Project setup:

# Create a virtualenv and install all the dependencies
poetry install

# Run all the tests and checks
just check

# We use snapshot tests pytest-snapshot. If they need updating, run this:
just test-update

# Run the tool directly from the repo
poetry run paketoi

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

paketoi-0.1.2.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

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

paketoi-0.1.2-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file paketoi-0.1.2.tar.gz.

File metadata

  • Download URL: paketoi-0.1.2.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/23.6.0

File hashes

Hashes for paketoi-0.1.2.tar.gz
Algorithm Hash digest
SHA256 868557fae4c29d1044e00713066814b05d6fedca70309f8fe968bf2b132f9d08
MD5 23b8a9e6e8373b165cdf6caf3c027cf4
BLAKE2b-256 1a299f817a7f460edc08b3bed9f3fadcf3e7da492ca8f766389f990e0d435fc1

See more details on using hashes here.

File details

Details for the file paketoi-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: paketoi-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/23.6.0

File hashes

Hashes for paketoi-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9adc3a6875e263d8e179307063b9258a9a1d01befd4d64a0541831bb0056748d
MD5 8e9885c4f27301cd810b0534d7691aca
BLAKE2b-256 abaaef7f213626e7f8787077d830f60ebebb5366ea6a6b3d8c9e7110639fe949

See more details on using hashes here.

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