An experimental cloud-native Buildpack (CNB) for Python on the Heroku stack.
Heroku's current Python buildpack has not been upgraded to CNB and instead uses a shim to work in that environment. Heroku is upgrading all their stacks, but I got tired of waiting and wanted to learn more about buildpacks in the process.
This used the excellent Node.js cloud-native Buildpack as a starting point and adjusted to work with Python.
- Support all major Python package managers out-of-the-box
- Allow other package managers to work via PEP-517
- Handle all configuration in
pyproject.toml
, dropping support forruntime.txt
and some of the magic (Django collectstatic) that's in the current buildpack.
- ✅
poetry
- ✅
pdm
- ⛔️
pipenv
- ⛔️ PEP-517 builds
- ⛔️
requirements.txt
The following keys are supported in pyproject.toml
:
tools.heroku
prebuild
command to run before installpostbuild
command to run after installengines
python
version of Python to install, defaults to3.9.*
poetry
version of poetry to install, defaults to1.*
pdm
version of pdm to install, defaults to1.*
pip
version of pip to install, defaults to latest
- Make
setuptools
version configurable likepip
pipenv
buildpackrequirements.txt
buildpackPEP-517
buildpack (pip install .
whenpyproject.toml
exists)- Use
resolve-version
to bust cache when newer versions of pdm or poetry released - Use
project.requires-python
inpyproject.toml
to determine Python version - Don't hardcode stack for Python download
- Handle max versions of pip/setuptools for older Pythons
- Tests