Compiles Python packages on Amazon Linux to ensure their compatability when used with AWS Lambda.
Project description
Amazon Linux Python Package Builder (alppb)
alppb builds Python packages using the same version of Amazon Linux that the AWS Lambda service uses. Using alppb helps guarantee that any PyPi package your AWS Lambda app depends on will run properly.
Why is this a problem that needs to be solved? AWS Lambda requires you to package up your Python project along with all of its dependencies in order to run. If your AWS Lambda Python project has package(s) with C extension modules (or dependencies that do), you will need to build them on Amazon Linux for your app to work. alppb uses the AWS CodeBuild service (perpetual free tier includes 100 build minutes per month) to build the package(s) on Amazon Linux and download them to your local machine for you. Simply unzip the downloaded package(s) into your deployment bundle and upload to the AWS Lambda service.
How To Use alppb
pip install alppb
alppb -h
Build package requests in bucket foo
alppb requests foo
TODO
Pre 1.0.0
- Foundation - create a CodeBuild project with hardcoded build that puts an artifact in s3
- Fix artifact so its a zip of the contents (excluding parent dir)
- Download the module locally to dir alppb was run from
- Move codebuild stuff to a module
- Delete the artifact from s3 as part of cleanup
- Add creation of IAM role for CodeBuild instead of using hardcoded, pre-built role
- Add deletion of IAM role as part of cleanup
- Move aws-cli stuff to boto3
- Allow user specification of the desired module to be built using alppb
- Cleanup existing docstrings
- Remove base64 stuff in iam.py as it obscures whats happening
- Axe the examples dir
- Allow user specification of the bucket
1.0.0
- Exception handling
- Update and overwrite if resources already exist
- pre-req checking
- Valid PyPi package
- Bucket and CodeBuild need to be in same region
- Bucket exists (NoSuchBucket)
- Bucket has valid name (botocore.exceptions.ParamValidationError)
- Unit tests
- Integration tests
- Test each version of Python supported
- Verify they're using the actual right python versions as part of each test
- Inspect the zip and make sure it contains what's expected
- Package and Submit to PyPi
- Make CodeBuild Docker image details more clear and document
- Add verbosity levels
- Add Sphinx docs
- readthedocs.org
Planned
- One or more modules can be specified in one invocation of alppb
- Allow specification of a requirements.txt file to use as a list of all modules to build
- Specify download location of the artifact
- Create an s3 bucket when an arg is specified
- Allow user to optionally specify an IAM role
- Specify the Python version that should be used to build the package (choices come from supported AWS Lambda versions)
- Dockerize and submit to Dockerhub
FAQs
- Why AWS CodeBuild? Why not X instead?
AWS CodeBuild has a perpetual free tier and it's super easy to spin up, and teardown, a build job. Further, we can easily specify various Docker images to use for the build that match the AWS Lambda environment. I will likely add support for other build methods/services. If you have a suggestion, please open an issue or contact me on Twitter @irlrobot.
- What image is being used for CodeBuild? Can I inspect the image being used for the build?
There are three images, one for each version of Python supported by AWS Lambda:
- Python 2.7 - https://hub.docker.com/r/irlrobot/alppb-python27/
- Python 3.6 - https://hub.docker.com/r/irlrobot/alppb-python36/
- Python 3.7 - https://hub.docker.com/r/irlrobot/alppb-python37/
Each image is running Amazon Linux 1 version 2017.03.1.20170812 which is what AWS Lambda uses.
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
Built Distribution
File details
Details for the file alppb-0.4.2.tar.gz
.
File metadata
- Download URL: alppb-0.4.2.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5361b9d9e1bf2700ac0eaf47b1150ad97816644c41fc567465bf615908c496cf |
|
MD5 | ab15b1443ab5bf854296b6d5e8487773 |
|
BLAKE2b-256 | 7630cf23e347e4d80a44fa25b7913019c357336c594c4de27090f6068f4167f2 |
File details
Details for the file alppb-0.4.2-py2.py3-none-any.whl
.
File metadata
- Download URL: alppb-0.4.2-py2.py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d6f60bafeba26db7a345d60ae1767ffee7a0035e8e999ca0fa4db9333dc6635 |
|
MD5 | 5c6c07f6126bf10d502e857cb573dc7a |
|
BLAKE2b-256 | 59b558df4c2472983424bdc1b7a1582a71b4cbe86fe5c031bea0351efae52bd5 |