Poetry plugin to install dependencies to a target directory and create zip files for deploying to AWS Lambda
Project description
Poetry Zippy Plugin
A Poetry plugin that installs packages to a target directory and creates deployment packages, particularly useful for AWS Lambda functions and other deployment scenarios.
Installation
poetry self add poetry-zippy-plugin
Usage
# Install all dependencies to a specific directory
poetry zippy --target ./lambda_dependencies
# Install dependencies and copy source code in one command
poetry zippy --target ./lambda_dependencies --source ./my_lambda_function
# Exclude specific file patterns when copying source
poetry zippy --target ./lambda_dependencies --source ./my_lambda_function --exclude "*.tmp,test/*"
# Create a ZIP file from the target directory
poetry zippy --target ./lambda_dependencies --source ./my_lambda_function --zip ./deployment.zip
# Create a ZIP file directly without keeping a target directory
poetry zippy --source ./my_lambda_function --zip ./deployment.zip
# Install with specific dependency groups
poetry zippy --target ./lambda_dependencies --only prod
# or
poetry zippy --target ./lambda_dependencies --with dev
# or exclude specific groups
poetry zippy --target ./lambda_dependencies --without test
Options
--target,-t: The target directory where dependencies will be installed (required unless --zip is used)--source,-s: The source directory to copy into the target directory--exclude,-e: Comma-separated patterns to exclude when copying source files--zip,-z: Path to the ZIP file to create from the target directory--only: The only dependency groups to include (comma-separated)--with: The optional dependency groups to include (comma-separated)--without: The dependency groups to skip (comma-separated)--platform: Only use wheels compatible with this platform tag (e.g., manylinux2014_x86_64)--implementation: Only use wheels compatible with this Python implementation (e.g., cp)--python-version: The Python interpreter version to use for wheel and 'Requires-Python' compatibility checks--pip: Additional arguments to pass directly to pip install
Note: The plugin automatically excludes common Python cache directories and files like __pycache__/, *.pyc, *.pyo, *.pyd, .git/, .pytest_cache/, and .coverage.
AWS Lambda Deployment Example
This plugin is particularly useful for preparing AWS Lambda function deployments. Here's an example workflow:
- Set up your Poetry project with your Lambda function code
- Install dependencies, copy your code, and create a deployment ZIP in one command:
# Create a final ZIP with a clean target directory poetry zippy --target ./lambda_package --source ./my_lambda_function --only prod --zip ./lambda_deployment.zip # Or create the ZIP directly without keeping a target directory poetry zippy --source ./my_lambda_function --only prod --zip ./lambda_deployment.zip # Specify platform and Python version for Lambda compatibility poetry zippy --target ./lambda_package --source ./my_lambda_function --platform manylinux2014_x86_64 --python-version 3.9 --zip ./lambda_deployment.zip # Pass additional pip arguments poetry zippy --target ./lambda_package --source ./my_lambda_function --pip "--no-binary :all: --no-cache-dir" --zip ./lambda_deployment.zip
- Deploy the ZIP file to AWS Lambda:
aws lambda update-function-code --function-name MyFunction --zip-file fileb://lambda_deployment.zip
How It Works
The plugin performs the following steps:
- Resolves dependencies using Poetry's lock file
- Installs each package to the target directory using pip
- Copies source files (if specified) while respecting exclude patterns
- Creates a ZIP file (if requested) containing all installed packages and source files
- Cleans up temporary directories (if used)
The plugin ensures that all dependencies are installed in a way that's compatible with AWS Lambda's requirements, including handling platform-specific wheels and Python version compatibility.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file poetry_zippy_plugin-0.1.0.tar.gz.
File metadata
- Download URL: poetry_zippy_plugin-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.16 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d90d9b202b1a0f5b34070d302b6a40ca85b5288904dc735e89e79a914191c569
|
|
| MD5 |
648da137fe3265b59d9bbb8d3031b12c
|
|
| BLAKE2b-256 |
6576c98a7c9d49bc9a047fb6041448a3999f2902e82dc0c13219a0837e7f1190
|
File details
Details for the file poetry_zippy_plugin-0.1.0-py3-none-any.whl.
File metadata
- Download URL: poetry_zippy_plugin-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.16 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a8edd6d9b2fc25d541891ee5462cf973c9365900b12283e4ec5c9a6051b5853
|
|
| MD5 |
6652d6f177ee1a583ce38117ab3b0564
|
|
| BLAKE2b-256 |
8b720fcd0fb0cdcfa105429f4c10ea21a3d1042b607341459dba4a5073ff4313
|