Skip to content

Commit 2658ac6

Browse files
authored
generate doc/requirements.txt (#10031)
* generate doc/requirements.txt As suggested in #10030 (review) * generate doc/requirements.txt As suggested in #10030 (review)
1 parent 4072eb8 commit 2658ac6

File tree

5 files changed

+27
-108
lines changed

5 files changed

+27
-108
lines changed

.github/workflows/users-guide.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ on:
1515
- 'doc/Makefile'
1616
- 'doc/pyproject.toml'
1717
- 'doc/requirements.in'
18-
- 'doc/requirements.txt'
1918
- 'doc/*.inc'
2019
- 'doc/*.py'
2120
- 'doc/*.rst'
@@ -26,7 +25,6 @@ on:
2625
- 'doc/Makefile'
2726
- 'doc/pyproject.toml'
2827
- 'doc/requirements.in'
29-
- 'doc/requirements.txt'
3028
- 'doc/*.inc'
3129
- 'doc/*.py'
3230
- 'doc/*.rst'
@@ -58,6 +56,14 @@ jobs:
5856
with:
5957
python-version: ${{ matrix.python-version }}
6058

59+
- name: Install pip-compile
60+
run: |
61+
pip install pip-tools
62+
63+
- name: Create requirements.txt from requirements.in
64+
run: |
65+
make users-guide-requirements
66+
6167
# Subsumed by make users-guide
6268
# - name: Install dependencies
6369
# run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ cabal-testsuite/**/haddocks
8787
venv
8888
.venv
8989
/doc/.skjold_cache/
90+
/doc/requirements.txt
9091

9192
# macOS folder metadata
9293
.DS_Store

.readthedocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ build:
77
os: "ubuntu-22.04"
88
tools:
99
python: "3.8"
10+
jobs:
11+
post_create_environment:
12+
- pip install pip-tools
13+
- make users-guide-requirements
1014

1115
python:
1216
install:

doc/README.md

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,34 @@ http://cabal.readthedocs.io/
1111

1212
### How to build it
1313

14-
Building the documentation requires Python 3 and PIP. Run the following command either from the root of the cabal repository or from the `docs/` subdirectory:
14+
Building the documentation requires Python 3, PIP, and `pip-tools` (see the second note below for how to install it). Run the following command either from the root of the cabal repository or from the `docs/` subdirectory:
1515

1616
``` console
17-
make users-guide
17+
> make users-guide
1818
```
1919

2020
Note: Python on Mac OS X dislikes `LC_CTYPE=UTF-8`, so unset the variable
2121
and instead set `LC_ALL=en_US.UTF-8`.
2222

23-
### How to update dependencies
24-
25-
Once in a while you need to update Python dependencies (for instance,
26-
when Dependabot alerts about possible security flaw). The list of
27-
transitive dependencies (`requirements.txt`) is generated from the
28-
list of direct dependencies in `requirements.in`. To perform the
29-
generation step run
23+
Note: You can use a vendor package for `pip-tools`, or run
3024

31-
```console
32-
> make users-guide-requirements
25+
``` console
26+
> pip install pip-tools
3327
```
3428

35-
either from the root of the cabal repository or from the `docs/` subdirectory.
29+
Make sure the installation directory (often `$HOME/.local/bin`) is on your `$PATH`.
3630

37-
Note that generating `requirements.txt` is sensitive to the Python version.
38-
The version currently used is stamped at the top of `requirements.txt`.
39-
Normally, we would expect the same version of Python to be used for
40-
regeneration. An easy way to enforce a particular version is to perform
41-
regeneration in a Docker container, e.g. (from the root of repository):
31+
### How to update dependencies
32+
33+
The list of transitive dependencies (`requirements.txt`) is generated from the list of direct dependencies in `requirements.in`. To perform the generation step, run
4234

4335
```console
44-
> docker run -itv $PWD:/cabal python:3.10-alpine sh
45-
...
46-
# apk add make
47-
...
48-
# cd cabal
49-
# make users-guide-requirements
36+
> make users-guide-requirements
5037
```
5138

52-
One way to make sure the dependencies are reasonably up to date
53-
is to remove `requirements.txt` and regenerate it as described
54-
above. But in some cases you may have to add a bound manually
55-
to `requirements.in`, e.g. `requests >= 2.31.0`.
39+
either from the root of the cabal repository or from the `docs/` subdirectory. You will need to do this before building documentation the first time, but should only need to repeat it after a `git clean` or if the dependencies in `requirements.in` change.
40+
41+
In some cases, you may have to add a bound manually to `requirements.in`, e.g. `requests >= 2.31.0`.
5642

5743
### Gitpod workflow
5844

@@ -70,6 +56,7 @@ Make your edits, rebuild the guide and refresh the browser to preview the
7056
changes. When happy, commit your changes with git in the included terminal.
7157

7258
### Caveats, for newcomers to RST from MD
59+
7360
RST does not allow you to skip section levels when nesting, like MD
7461
does.
7562
So, you cannot have

doc/requirements.txt

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)