Skip to content

Commit

Permalink
Running pip install '.[docs]' on ReadTheDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw authored Nov 24, 2023
1 parent 0d8818d commit 04a0013
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions readthedocs/pip-install-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Running pip install '.[docs]' on ReadTheDocs

I decided to use ReadTheDocs for my in-development [datasette-enrichments](https://github.com/datasette/datasette-enrichments) project.

Previously when I've used ReadTheDocs I've had a `docs/` folder in my project with its own `docs/requirements.txt` file containing the requirements.

For this project I decided to try putting my documentation dependencies in a `setup.py` file (which I will likely upgrade to `pyproject.toml` in the future) like this:

```python
# ...
extras_require={
"test": ["pytest", "pytest-asyncio", "black", "cogapp", "ruff"],
"docs": [
"sphinx==7.2.6",
"furo==2023.9.10",
"sphinx-autobuild",
"sphinx-copybutton",
"myst-parser",
"cogapp",
],
},
# ...
```
When I'm working on this project locally I install these dependencies like so:
```bash
pip install -e '.[docs]'
```
It took me a few iterations to figure it out, so here's how to run that same command on ReadTheDocs using the `.readthedocs.yaml` configuration file:

```yaml
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

sphinx:
configuration: docs/conf.py

formats:
- pdf
- epub

python:
install:
- method: pip
path: .
extra_requirements:
- docs
```

1 comment on commit 04a0013

@simonw
Copy link
Owner Author

@simonw simonw commented on 04a0013 Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.