Skip to content

Commit 48b5f28

Browse files
committed
chore: add README files
1 parent 092c771 commit 48b5f28

File tree

5 files changed

+323
-9
lines changed

5 files changed

+323
-9
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ SPDX-FileContributor: Samuel Gaist <samuel.gaist@idiap.ch>
55
SPDX-License-Identifier: Apache-2.0
66
-->
77

8-
# Python Packagers Cloud Native Buildpack
8+
# Python Installers Cloud Native Buildpack
99

10-
The Paketo Buildpack for Python Packagers is a Cloud Native Buildpack that
11-
installs packages using the adequate tool selected based on the content of the
12-
application sources and makes it available to it.
10+
The Paketo Buildpack for Python Installers is a Cloud Native Buildpack that
11+
installs python package managers.
1312

1413
The buildpack is published for consumption at
1514
`gcr.io/paketo-buildpacks/python-installers` and
@@ -18,14 +17,16 @@ The buildpack is published for consumption at
1817
## Behavior
1918
This buildpack participates if one of the following detection succeeds:
2019

21-
- (conda)[conda/README.md] -> `environment.yml`
22-
- (pip)[pip/README.md] -> `requirements.txt`
23-
- (pipenv)[pipenv/README.md] -> `Pipfile`
24-
- (poetry)[poetry/README.md] -> `pyproject.toml`
20+
- (miniconda)[installers/pkg/minconda/README.md] -> Always
21+
- (pip)[installers/ppkg/pip/README.md] -> Always
22+
- (pipenv)[installers/ppkg/pipenv/README.md] -> Always
23+
- (poetry)[installers/ppkg/poetry/README.md] -> `pyproject.toml` is present in the root folder
2524

2625
The buildpack will do the following:
2726
* At build time:
28-
- Installs the application packages to a layer made available to the app.
27+
- Installs the package manager
28+
- Makes it available on the `PATH`
29+
- Adjusts `PYTHONPATH` as required
2930
* At run time:
3031
- Does nothing
3132

pkg/installers/miniconda/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
# Sub-package for Miniconda installation
9+
10+
Original implementation from `paketo-buildpack/miniconda`
11+
12+
This sub-package installs miniconda into a layer and makes it available on the
13+
PATH.
14+
15+
## Configuration
16+
17+
| Environment Variable | Description |
18+
|------------------------|------------------------------------------------------------------|
19+
| `$BP_MINICONDA_SOLVER` | Configure the solver to be used (current valid value is `mamba`) |
20+
21+
## Integration
22+
23+
The Miniconda CNB provides conda as a dependency. Downstream buildpacks can
24+
require the conda dependency by generating a [Build Plan
25+
TOML](https://github.com/buildpacks/spec/blob/master/buildpack.md#build-plan-toml)
26+
file that looks like the following:
27+
28+
```toml
29+
[[requires]]
30+
31+
# The name of the Miniconda dependency is "conda". This value is considered
32+
# part of the public API for the buildpack and will not change without a plan
33+
# for deprecation.
34+
name = "conda"
35+
36+
# The version of the conda dependency is not required. In the case it
37+
# is not specified, the buildpack will provide the default version, which can
38+
# be seen in the buildpack.toml file.
39+
# If you wish to request a specific version, the buildpack supports
40+
# specifying a semver constraint in the form of "4.*", "4.7.*", or even
41+
# "4.7.12".
42+
version = "4.7.12"
43+
44+
# The Miniconda buildpack supports some non-required metadata options.
45+
[requires.metadata]
46+
47+
# Setting the build flag to true will ensure that the conda
48+
# dependency is available on the $PATH for subsequent buildpacks during
49+
# their build phase. If you are writing a buildpack that needs to run
50+
# miniconda during its build process, this flag should be set to true.
51+
build = true
52+
53+
# Setting the launch flag to true will ensure that the conda
54+
# dependency is available on the $PATH for the running application. If you are
55+
# writing an application that needs to run miniconda at runtime, this flag
56+
# should be set to true.
57+
launch = true
58+
```
59+
60+
## Vendoring
61+
62+
Follow these steps to vendor python packages in your app using conda
63+
64+
**Prerequisites**
65+
- Must be run on linux OS and **case-sensitive file system**
66+
- Install conda build tools: `conda install conda-build`
67+
68+
**Steps**
69+
1. `cd <my_conda_app>`
70+
1. Create `environment.yml` file in the root of your app
71+
1. `CONDA_PKGS_DIRS=vendor/noarch conda env create -f environment.yml -n <env_name>`
72+
1. `conda index vendor`
73+
1. `conda list -n <env_name> -e > package-list.txt`
74+
1. Commit `environment.yml`, `vendor`, and `package-list.txt`

pkg/installers/pip/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
# Sub-package for pip installation
9+
10+
Original implementation from `paketo-buildpack/pip`
11+
12+
This sub-package installs pip into a layer and places it on the `PATH`.
13+
14+
## Behavior
15+
This sub-package always participates.
16+
17+
The buildpack will do the following:
18+
* At build time:
19+
- Contributes the `pip` binary to a layer
20+
- Prepends the `pip` layer to the `PYTHONPATH`
21+
- Adds the newly installed pip location to `PATH`
22+
* At run time:
23+
- Does nothing
24+
25+
## Configuration
26+
| Environment Variable | Description
27+
| -------------------- | -----------
28+
| `$BP_PIP_VERSION` | Configure the version of pip to install. Buildpack releases (and the pip versions for each release) can be found [here](https://github.com/paketo-buildpacks/pip/releases).
29+
30+
Note that Pip releases are of the form `X.Y` instead of `X.Y.0`, so providing
31+
`X.Y` will attempt to match that exact version. Providing `X.Y.Z` will select
32+
the exact patch version, and providing `X.Y.*` or `~X.Y` will select the latest
33+
patch version.
34+
35+
## Integration
36+
37+
The Pip CNB provides pip as a dependency. Downstream buildpacks can require the pip
38+
dependency by generating a [Build Plan
39+
TOML](https://github.com/buildpacks/spec/blob/master/buildpack.md#build-plan-toml)
40+
file that looks like the following:
41+
42+
```toml
43+
[[requires]]
44+
45+
# The name of the Pip dependency is "pip". This value is considered
46+
# part of the public API for the buildpack and will not change without a plan
47+
# for deprecation.
48+
name = "pip"
49+
50+
# The version of the Pip dependency is not required. In the case it
51+
# is not specified, the buildpack will select the latest supported version in
52+
# the buildpack.toml.
53+
# If you wish to request a specific version, the buildpack supports
54+
# specifying a semver constraint in the form of "21.*", "21.0.*", or even
55+
# "21.0.1".
56+
version = "21.0.1"
57+
58+
# The Pip buildpack supports some non-required metadata options.
59+
[requires.metadata]
60+
61+
# Setting the build flag to true will ensure that the Pip dependency is
62+
# available on the $PATH, and the $PYTHONPATH contains the path to pip for
63+
# subsequent buildpacks during their build phase. If you are writing a
64+
# buildpack that needs to run Pip during its build process, this flag should
65+
# be set to true.
66+
build = true
67+
68+
# Setting the launch flag to true will ensure that the Pip
69+
# dependency is available on the $PATH, and the $PYTHONPATH contains the
70+
# path to pip for the running application. If you are writing an
71+
# application that needs to run Pip at runtime, this flag should be set to
72+
# true.
73+
launch = true
74+
```

pkg/installers/pipenv/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
# Sub-package for Pipenv installation
9+
10+
Original implementation from `paketo-buildpack/pipenv`
11+
12+
This sub-package installs[pipenv](https://pypi.org/project/pipenv) into a layer
13+
and makes it available on the `PATH`.
14+
15+
## Behavior
16+
This sub-package always participates.
17+
18+
It will do the following:
19+
* At build time:
20+
- Contributes the `pipenv` binary to a layer
21+
- Prepends the `pipenv` layer to the `PYTHONPATH`
22+
- Adds the newly installed pipenv location to `PATH`
23+
* At run time:
24+
- Does nothing
25+
26+
## Configuration
27+
| Environment Variable | Description |
28+
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
29+
| `$BP_PIPENV_VERSION` | Configure the version of pipenv to install. Buildpack releases (and the supported pipenv versions for each release) can be found [here](https://github.com/paketo-buildpacks/pipenv/releases). |
30+
31+
## Integration
32+
33+
The Pipenv CNB provides pipenv as a dependency. Downstream buildpacks can
34+
require the pipenv dependency by generating a [Build Plan
35+
TOML](https://github.com/buildpacks/spec/blob/master/buildpack.md#build-plan-toml)
36+
file that looks like the following:
37+
38+
```toml
39+
[[requires]]
40+
41+
# The name of the Pipenv dependency is "pipenv". This value is considered
42+
# part of the public API for the buildpack and will not change without a plan
43+
# for deprecation.
44+
name = "pipenv"
45+
46+
# The Pipenv buildpack supports some non-required metadata options.
47+
[requires.metadata]
48+
49+
# Use `version` to request a specific version of `pipenv`.
50+
# This buildpack supports specifying a semver constraint in the form of "2018.*", "2018.11.*",
51+
# or even "2018.11.26".
52+
# Optional, defaults to the latest version of `pipenv` found in the `buildpack.toml` file.
53+
version = "2018.11.26"
54+
55+
# When `build` is true, this buildpack will ensure that `pipenv` is available
56+
# on the `$PATH` for later buildpacks.
57+
# Optional, default false.
58+
build = true
59+
60+
# When `launch` is true, this buildpack will ensure that `pipenv` is available
61+
# on the `$PATH` for the running application.
62+
# Optional, default false.
63+
launch = true
64+
```
65+
66+
## Limitations
67+
68+
This buildpack requires internet connectivity to install `pipenv`.
69+
Installation in an air-gapped environment is not supported.
70+
71+
The dependency contained in `buildpack.toml` is not actually used, as `pipenv` is
72+
installed directly from the internet. However, the rest of the dependency
73+
metadata is used (e.g. for generating an SBOM). This will be addressed in
74+
upcoming work which will change the way dependencies are consumed by
75+
buildpacks.

pkg/installers/poetry/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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

Comments
 (0)