|
| 1 | +<!-- |
| 2 | +// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. |
| 3 | +SPDX-FileContributor: Samuel Gaist <samuel.gaist@idiap.ch> |
| 4 | +
|
| 5 | +SPDX-License-Identifier: Apache-2.0 |
| 6 | +--> |
| 7 | + |
| 8 | +# Poetry Cloud Native Buildpack |
| 9 | +## `gcr.io/paketo-buildpacks/poetry` |
| 10 | + |
| 11 | +The Paketo Buildpack for Poetry is a Cloud Native Buildpack that installs [Poetry](https://python-poetry.org/) into a |
| 12 | +layer and places it on the `PATH`. |
| 13 | + |
| 14 | +The buildpack is published for consumption at `gcr.io/paketo-buildpacks/poetry` and |
| 15 | +`paketobuildpacks/poetry`. |
| 16 | + |
| 17 | +## Detection |
| 18 | + |
| 19 | +* Detects when `pyproject.toml` exists. |
| 20 | +* Provides `poetry`. |
| 21 | +* Always requires `cpython` and `pip`. |
| 22 | +* Optionally requires `poetry` when `BP_POETRY_VERSION` is set. |
| 23 | + |
| 24 | +## Build |
| 25 | +* Contributes the `poetry` binary to a layer |
| 26 | +* Prepends the `poetry` layer to the `PYTHONPATH` environment variable |
| 27 | +* Adds the newly installed `poetry` location to the `PATH` environment variable |
| 28 | + |
| 29 | +## Configuration |
| 30 | +| Environment Variable | Description | |
| 31 | +|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 32 | +| `$BP_POETRY_VERSION` | Configure the version of Poetry to install. Buildpack releases (and the Poetry versions for each release) can be found [here](https://github.com/paketo-buildpacks/poetry/releases). | |
| 33 | + |
| 34 | +## Integration |
| 35 | + |
| 36 | +The Poetry CNB provides Poetry as a dependency. Downstream buildpacks can require the Poetry |
| 37 | +dependency by generating a [Build Plan |
| 38 | +TOML](https://github.com/buildpacks/spec/blob/master/buildpack.md#build-plan-toml) |
| 39 | +file that looks like the following: |
| 40 | + |
| 41 | +```toml |
| 42 | +[[requires]] |
| 43 | + |
| 44 | + # The name of the Poetry dependency is "poetry". This value is considered |
| 45 | + # part of the public API for the buildpack and will not change without a plan |
| 46 | + # for deprecation. |
| 47 | + name = "poetry" |
| 48 | + |
| 49 | + # The Poetry buildpack supports some non-required metadata options. |
| 50 | + [requires.metadata] |
| 51 | + |
| 52 | + # Optional. |
| 53 | + # When not specified, the buildpack will select the latest supported version from buildpack.toml |
| 54 | + # This buildpack only supports exact version numbers. |
| 55 | + version = "21.0.1" |
| 56 | + |
| 57 | + # Set to true to ensure that `poetry` is avilable on both `$PATH` and `$PYTHONPATH` for subsequent buildpacks. |
| 58 | + build = true |
| 59 | + |
| 60 | + # Set to true to ensure that `poetry` is avilable on both `$PATH` and `$PYTHONPATH` for the launch container. |
| 61 | + launch = true |
| 62 | +``` |
| 63 | + |
| 64 | +## Usage |
| 65 | + |
| 66 | +To package this buildpack for consumption: |
| 67 | +``` |
| 68 | +$ ./scripts/package.sh --version x.x.x |
| 69 | +``` |
| 70 | +This will create a `buildpackage.cnb` file under the build directory which you |
| 71 | +can use to build your app as follows: |
| 72 | + |
| 73 | +```shell |
| 74 | +pack build <app-name> \ |
| 75 | + --path <path-to-app> \ |
| 76 | + --buildpack build/buildpackage.cnb \ |
| 77 | + --buildpack <other-buildpacks..> |
| 78 | +``` |
| 79 | + |
| 80 | +To run the unit and integration tests for this buildpack: |
| 81 | +```shell |
| 82 | +$ ./scripts/unit.sh && ./scripts/integration.sh |
| 83 | +``` |
| 84 | + |
| 85 | +## Known issues and limitations |
| 86 | + |
| 87 | +* This buildpack does not work in an offline/air-gapped environment; it |
| 88 | + requires internet access to install `poetry`. The impact of this limitation |
| 89 | + is mitigated by the fact that `poetry` itself does not support vendoring of |
| 90 | + dependencies, and so cannot function in an offline/air-gapped environment. |
0 commit comments