2 releases
Uses new Rust 2024
| 0.0.2 | Sep 7, 2025 |
|---|---|
| 0.0.1 | Sep 7, 2025 |
#2 in #installer
Used in pybuild
34KB
709 lines
pybuild-install
Install command is meant to provide a stopgap solution and is best suited to be handled by other tools. However, fitting those tools easily and natively into the workflows of tools/frameworks for packaging AWS Lambda functions is challenging for users:
Compare & Contrast with NodeJS
- In NodeJS with the
esbuildtool - due to the ability to tree-shake any excess code, users can install dependencies once in a central location.esbuilddoes not concern itself with installing dependencies. - In NodeJS, it seems less common to have to install dependencies in a "Lambda-like" environment. This greatly simplifies the process of package management to standard tools like NPM, Yarn, etc.
- This leaves the typical CI/CD pipeline for NodeJS artifacts that are bundled to look like:
- Checkout source code
- Install dependencies using standard tooling (NPM, Yarn, etc.) within the CI environment
- Build/bundle artifact using
esbuild(this step can be spread out and parallelized for multiple artifacts) - Deploy artifacts
- If we contrast this with a Python project
- Checkout source code
TODOs
- ✅ For pipenv and poetry, how to export only production dependencies?
- For
pipenv, this seems to be the default https://github.com/pypa/pipenv/issues/245 - For
poetry, this also seems to be the default when inspectingpoetry export -h
- For
-
installThis is just a simple wrapper that shells out commands to the cli to ergonomically handle where deps are installed for bundling-
✅ --package-manager, -p: one of
pip,poetry, orpipfile-
pipwill use dependencies listed inrequirements.txtpip install -r requirements.txt --target ./.pybuild/site-packages -
pipenvpipenv run pip install -r <(pipenv lock -r) --target ./.pybuild/site-packages -
poetrypoetry export -f requirements.txt --without-hashes > requirements.txt & \ poetry run pip install -r requirements.txt -t ./.pybuild/site-packages
-
-
✅ --extra-args, -e: extra arguments to pass to package manager install command
-
✅ --target, -t: Install packages into
. By default this will not replace existing files/folders in . Use--extra-args='--upgrade'to replace existing packages in with new versions.- By default we will use
.pybuild/site-packagessince this is wherepybuild bundle ...will look - Clearly document that if users change
--targettha they will also want to change--packagesto match when bundling
- By default we will use
-
✅ --upgrade, -u: Upgrade all specified packages to the newest available version
-
--requirements-file, r: path to requirements file (requirements.txt, Pipfile, pyproject.toml, etc.)
-
- ✅ --log-level, -l: log level
- ✅ --version, -v: version
Enhancements
- Add ability for users to
--install-in-dockerto ensure libraries are compatible for various runtime environments like AWS Lambda - Allow users to select which container image to use for
--install-in-dockerusing--container-image - Add flag
--python-versionto aid in selecting default container image and archive path, etc.
Package Install Location Challenges
Pip
Pipenv
Poetry
Dependencies
~7–11MB
~195K SLoC