You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Python package manager Poetry is now supported for installing app
dependencies:
https://python-poetry.org
To use Poetry apps must have a `poetry.lock` lockfile, which can be
created by running `poetry lock` locally, after adding Poetry config to
`pyproject.toml` (which can be done either manually or by using
`poetry init`). Apps must only have one package manager file (either
`requirements.txt` or `poetry.lock`, but not both) otherwise the
buildpack will abort the build with an error (which will help prevent
some of the types of support tickets we see in the classic buildpack).
Poetry is installed into a build-only layer, so is not available at
run-time to reduce image size. The app dependencies are installed into
a virtual environment (the same as for pip, after #257), which is on
`PATH` so does not need explicit activation when using the app image.
As such, use of `poetry run` or `poetry shell` is not required at
run-time to use dependencies in the environment.
When using Poetry, pip is not explicitly installed, since Poetry
includes its own bundled copy that it will use instead (for the small
number of Poetry operations for which it still calls out to pip, such
as package uninstalls).
Both the Poetry and app dependencies layers are cached, however, the
Poetry download/wheel cache is not cached, since using it is slower than
caching the dependencies layer (for more details see the comments on
`poetry_dependencies::install_dependencies`).
The `poetry install --sync` command is run using `--only main` so as to
only install the main dependencies group and not any other groups (such
as test/dev/... groups).
Relevant Poetry docs:
- https://python-poetry.org/docs/cli/#install
- https://python-poetry.org/docs/configuration/
- https://python-poetry.org/docs/managing-dependencies/#dependency-groups
Work that will be handled later:
- Support for selecting Python version via `tool.poetry.dependencies.python`:
#260
- Build output and error messages polish/CX review (this will be
performed when switching the buildpack to the new logging style).
- More detailed user-facing docs:
#11Closes#7.
GUS-W-9607867.
GUS-W-9608286.
GUS-W-9608295.
A `requirements.txt` file must be present at the root of your application's repository.
34
+
A `requirements.txt`or `poetry.lock`file must be present in the root (top-level) directory of your app's source code.
35
35
36
36
## Configuration
37
37
38
38
### Python Version
39
39
40
40
By default, the buildpack will install the latest version of Python 3.12.
41
41
42
-
To install a different version, add a `runtime.txt` file to your app’s root directory that declares the exact version number to use:
42
+
To install a different version, add a `runtime.txt` file to your app's root directory that declares the exact version number to use:
43
43
44
44
```term
45
45
$ cat runtime.txt
46
46
python-3.12.5
47
47
```
48
48
49
-
In the future this buildpack will also support specifying the Python version via a `.python-version` file (see [#6](https://github.com/heroku/buildpacks-python/issues/6)).
49
+
In the future this buildpack will also support specifying the Python version using:
50
+
51
+
- A `.python-version` file: [#6](https://github.com/heroku/buildpacks-python/issues/6)
52
+
-`tool.poetry.dependencies.python` in `pyproject.toml`: [#260](https://github.com/heroku/buildpacks-python/issues/260)
0 commit comments