Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip: Recommend pybuild-deps package for generating requirements-build.txt #780

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 2 additions & 74 deletions docs/pip.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,80 +432,8 @@ but contains build dependencies rather than runtime dependencies.
*Note: this file must contain all the transitive build dependencies of each of your transitive runtime dependencies
(you are installing dependencies from source).*

There's no great way to generate such a file. As far as we know, the best solution is pip-compile combined with this
standalone script that lives in the old Cachito repo:
[pip\_find\_builddeps.py](https://github.com/containerbuildsystem/cachito/blob/master/bin/pip_find_builddeps.py).

#### Prerequisites

Generate a [fully resolved requirements.txt](#requirementstxt)

Get the script ([download](https://raw.githubusercontent.com/containerbuildsystem/cachito/master/bin/pip_find_builddeps.py)
directly from Github, it has no runtime dependencies other than pip)

If your project itself has build dependencies (typically defined in pyproject.toml), copy them to `requirements-build.in`.

<details>
<summary>Example: pyproject.toml build dependencies</summary>

```toml
# pyproject.toml
[build-system]
requires = ["pdm-pep517"]
build-backend = "pdm.pep517.api"
```

Copy dependencies from build-system.requires:

```requirements.txt
# requirements-build.in
pdm-pep517
```

</details>

**Usage:**

Run the `pip_find_builddeps.py` script and pip-compile the output:

```shell
pip_find_builddeps.py requirements.txt \
--append \
--only-write-on-update \
-o requirements-build.in

pip-compile requirements-build.in --allow-unsafe --generate-hashes
```

<details>
<summary>Result: requirements-build.txt</summary>

```requirements.txt
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes requirements-build.in
#
flit-core==3.8.0 \
--hash=sha256:64a29ec845164a6abe1136bf4bc5ae012bdfe758ed42fc7571a9059a7c80bd83 \
--hash=sha256:b305b30c99526df5e63d6022dd2310a0a941a187bd3884f4c8ef0418df6c39f3
# via -r requirements-build.in
pdm-pep517==1.0.6 \
--hash=sha256:8ec0c13cbacc9b94a9820be7db9e513c81a48ebca0bb826eb743fb1b22d144a0 \
--hash=sha256:a4407703d50fa4d671383a354868b05a13060c1bf38264cbb5ddc9a73e4a1dc5
# via -r requirements-build.in
setuptools==66.1.1 \
--hash=sha256:6f590d76b713d5de4e49fe4fbca24474469f53c83632d5d0fd056f7ff7e8112b \
--hash=sha256:ac4008d396bc9cd983ea483cb7139c0240a07bbc74ffb6232fceffedc6cf03a8
# via -r requirements-build.in
wheel==0.38.4 \
--hash=sha256:965f5259b566725405b05e7cf774052044b1ed30119b5d586b2703aafe8719ac \
--hash=sha256:b60533f3f5d530e971d6737ca6d58681ee434818fab630c83a734bb10c083ce8
# via -r requirements-build.in
```

</details>
We recommend the [pybuild-deps](https://pypi.org/project/pybuild-deps) package to generate the requirements-build.txt file.
It will automatically generate build requirements from your requirements.txt file.

*Adding a requirements-build.txt should not require changes in your build process. Pip should install the build
dependencies automatically as needed, you don't have to install them explicitly. The purpose of requirements-build.txt
Expand Down
Loading