Skip to content

Commit 4234344

Browse files
authored
Initial rfc for pip install buildpack (#2)
1 parent b3ed1c9 commit 4234344

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Pip Install Architecture
2+
3+
## Proposal
4+
The Pip Install buildpack will use the package installer
5+
[pip](https://pypi.org/project/pip) to install dependencies from a
6+
`requirements.txt` file into a layer that will be managed by the buildpack.
7+
8+
## Motivation
9+
In keeping with the overarching [Python Buildpack Rearchitecture
10+
RFC](https://github.com/paketo-community/pip/blob/main/rfcs/0001-pip-rearchitecture.md),
11+
the Pip Install Buildpack should perform one task, which is installing from
12+
requirements files. This is part of the effort in Paketo Buildpacks to reduce
13+
the responsibilities of each buildpack to make them easier to understand and
14+
maintain.
15+
16+
## Implementation
17+
### API
18+
- pip-install
19+
- `requires`: `cpython` and `pip` during build
20+
- `provides`: `site-packages`
21+
22+
### Detect
23+
The pip-install buildpack should only detect if there is a `requirements.txt`
24+
file at the root of the app.
25+
26+
### Build
27+
There will be two layers, `packages` layer and `cache` layer.
28+
The packages layer will contain the result of the pip install command.
29+
The cache layer will hold the pip [cache](https://pip.pypa.io/en/stable/reference/pip_install/#caching).
30+
31+
During the build process, it will utilize the `pip` tool provided by the `pip`
32+
requirement (e.g. provided by the `paketo-community/pip` buildpack).
33+
34+
The resulting build command run by the Pip Install buildpack will be:
35+
```bash
36+
pip install
37+
--requirement <requirements file> # install from given requirements file
38+
--ignore-installed # ignores previously installed packages
39+
--exists-action=w # if path already exists, wipe before installation
40+
--cache-dir=<path to cache layer directory> # reuse pip cache
41+
--compile # compile python source files to bytecode
42+
--user # install to python user install directory set by PYTHONUSERBASE
43+
--disable-pip-version-check # ignore version check warning
44+
```
45+
Upgrade options are ignored if using `--ignore-installed` See [upgrade
46+
options](https://pip.pypa.io/en/stable/development/architecture/upgrade-options/).
47+
48+
This should be run with the environment variable `PYTHONUSERBASE` set to the packages layer directory.
49+
50+
If the app has a vendor directory at the root, the app will be considered vendored and the resulting build command will be:
51+
```bash
52+
pip install
53+
--requirement <requirements file>
54+
--ignore-installed
55+
--exists-action=w
56+
--no-index # ignore package index, uses --find-links URLs
57+
--find-links=<file://<app vendor directory>> # uses apps vendor directory
58+
--compile
59+
--user
60+
--disable-pip-version-check
61+
```
62+
63+
#### Environment variables
64+
65+
The buildpack should attach the environment variable `$PYTHONUSERBASE` to the
66+
`packages` layer, set its value to the layer's directory path, and make it
67+
available during both the build and launch phases.

0 commit comments

Comments
 (0)