|
| 1 | +<!-- |
| 2 | +// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. |
| 3 | +SPDX-FileContributor: Samuel Gaist <[email protected]> |
| 4 | +
|
| 5 | +SPDX-License-Identifier: Apache-2.0 |
| 6 | +--> |
| 7 | + |
| 8 | +# Sub package for pip installation |
| 9 | + |
| 10 | +Original implementation from `paketo-buildpacks/pip-install` |
| 11 | + |
| 12 | +This sub package installs packages using pip and makes it available to the |
| 13 | +application. |
| 14 | + |
| 15 | +## Behavior |
| 16 | +This sub package participates if `requirements.txt` exists at the root the app. |
| 17 | + |
| 18 | +The buildpack will do the following: |
| 19 | +* At build time: |
| 20 | + - Installs the application packages to a layer made available to the app. |
| 21 | + - Prepends the layer site-packages onto `PYTHONPATH`. |
| 22 | + - If a vendor directory is available, will attempt to run `pip install` in an offline manner. |
| 23 | +* At run time: |
| 24 | + - Does nothing |
| 25 | + |
| 26 | +## Integration |
| 27 | + |
| 28 | +This sub package provides `site-packages` as a dependency. Downstream buildpacks |
| 29 | +can require the `site-packages` dependency by generating a [Build Plan TOML] |
| 30 | +(https://github.com/buildpacks/spec/blob/master/buildpack.md#build-plan-toml) |
| 31 | +file that looks like the following: |
| 32 | + |
| 33 | +```toml |
| 34 | +[[requires]] |
| 35 | + |
| 36 | + # The name of the dependency provided by the Pip Install Buildpack is |
| 37 | + # "site-packages". This value is considered part of the public API for the |
| 38 | + # buildpack and will not change without a plan for deprecation. |
| 39 | + name = "site-packages" |
| 40 | + |
| 41 | + # The Pip Install buildpack supports some non-required metadata options. |
| 42 | + [requires.metadata] |
| 43 | + |
| 44 | + # Setting the build flag to true will ensure that the site-packages |
| 45 | + # dependency is available on the $PYTHONPATH for subsequent |
| 46 | + # buildpacks during their build phase. If you are writing a buildpack that |
| 47 | + # needs site-packages during its build process, this flag should be |
| 48 | + # set to true. |
| 49 | + build = true |
| 50 | + |
| 51 | + # Setting the launch flag to true will ensure that the site-packages |
| 52 | + # dependency is available on the $PYTHONPATH for the running |
| 53 | + # application. If you are writing an application that needs site-packages |
| 54 | + # at runtime, this flag should be set to true. |
| 55 | + launch = true |
| 56 | +``` |
| 57 | + |
| 58 | +## Configuration |
| 59 | + |
| 60 | +### `BP_PIP_DEST_PATH` |
| 61 | + |
| 62 | +The `BP_PIP_DEST_PATH` variable allows you to specify a custom vendor directory. |
| 63 | +This should be a directory underneath the working directory. |
| 64 | +Will use `./vendor` if not provided. |
| 65 | + |
| 66 | +```shell |
| 67 | +BP_PIP_DEST_PATH=my/custom/vendor-dir |
| 68 | +``` |
| 69 | + |
| 70 | +### `BP_PIP_REQUIREMENT` |
| 71 | + |
| 72 | +The `BP_PIP_REQUIREMENT` variable allows you to specify a custom pip requirement path. |
| 73 | +This should be a file underneath the working directory. |
| 74 | +Will use `./requirements.txt` if not provided. |
| 75 | + |
| 76 | +```shell |
| 77 | +BP_PIP_REQUIREMENT=requirements-dev.txt |
| 78 | +``` |
| 79 | + |
| 80 | +### `BP_PIP_FIND_LINKS` |
| 81 | + |
| 82 | +The `BP_PIP_FIND_LINKS` variable allows you to specify one or more directories |
| 83 | +to pass to `--find-links`. This should be a local path or `file://` URL. |
| 84 | + |
| 85 | +```shell |
| 86 | +BP_PIP_FIND_LINKS=./vendor-dir |
| 87 | +``` |
| 88 | + |
| 89 | +### `PIP_<UPPER_LONG_NAME>` |
| 90 | + |
| 91 | +It is worth noting that the `PIP_<UPPER_LONG_NAME>` configuration is respected |
| 92 | +by this buildpack and can be used to tweak the build time CLI properties for |
| 93 | +Pip as documented in [Pip's |
| 94 | +configuration](https://pip.pypa.io/en/stable/topics/configuration/#environment-variables). |
0 commit comments