Skip to content

Commit 475d1c1

Browse files
authored
Split docs requirements into separate group (#122)
On Python versions earlier than 3.10, flake8 and Sphinx are just not going to be compatible, and need to be in separate groups so both don't have to be installed at the same time or in the same environment. This also updates our ReadTheDocs setup to use their newer configuration file format. Overall, this follows the arrangement I set up for the Wayback package in edgi-govdata-archiving/wayback#91.
1 parent 27dbf47 commit 475d1c1

File tree

11 files changed

+140
-67
lines changed

11 files changed

+140
-67
lines changed

.circleci/config.yml

Lines changed: 69 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,91 @@
11
version: 2.1
22

33
parameters:
4-
python-version:
4+
primary-python-version:
55
type: string
6-
default: "3.7.13"
6+
default: "3.10.7"
77

8-
jobs:
9-
build:
10-
working_directory: ~/web-monitoring-diff
11-
docker:
12-
- image: cimg/python:<< pipeline.parameters.python-version >>
8+
commands:
9+
setup_pip:
10+
description: "Set Up Dependencies"
11+
parameters:
12+
python-version:
13+
type: string
14+
install-docs:
15+
description: Install docs dependencies
16+
type: boolean
17+
default: false
1318
steps:
14-
- checkout
15-
- run:
16-
name: Install System Dependencies
17-
command: |
18-
sudo apt-get update
19-
sudo apt-get install \
20-
libxml2-dev libxslt-dev libssl-dev openssl libcurl4-openssl-dev
21-
2219
- restore_cache:
2320
keys:
24-
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-experimental.txt" }}
25-
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-
26-
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-
27-
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-
28-
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-
21+
- cache-v3-{{ arch }}-python<< parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-experimental.txt" }}-{{ checksum "requirements-docs.txt" }}
22+
- cache-v3-{{ arch }}-python<< parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-experimental.txt" }}-
23+
- cache-v3-{{ arch }}-python<< parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-
24+
- cache-v3-{{ arch }}-python<< parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-
25+
- cache-v3-{{ arch }}-python<< parameters.python-version >>-{{ checksum "requirements.txt" }}-
26+
- cache-v3-{{ arch }}-python<< parameters.python-version >>-
2927

30-
# Bundle install dependencies
3128
- run:
3229
name: Install Dependencies
3330
command: |
34-
python -m venv venv
35-
. venv/bin/activate
36-
pip install -e .[server,dev] --no-binary lxml
31+
python -m venv ~/venv
32+
. ~/venv/bin/activate
33+
# Ensure pip is up-to-date
34+
pip install --upgrade pip
35+
pip install .[server,dev] --no-binary lxml
3736
pip install -r requirements-experimental.txt
3837
39-
# Store bundle cache
38+
# Docs dependencies are only compatible on Python 3.10+, so only install
39+
# them on demand.
40+
- when:
41+
condition: << parameters.install-docs >>
42+
steps:
43+
- run:
44+
command: |
45+
. ~/venv/bin/activate
46+
pip install -r requirements-docs.txt
47+
4048
- save_cache:
41-
key: cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-experimental.txt" }}
49+
key: cache-v3-{{ arch }}-python<< parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-experimental.txt" }}-{{ checksum "requirements-docs.txt" }}
4250
paths:
43-
- venv
51+
- ~/venv
4452

53+
jobs:
54+
test:
55+
parameters:
56+
python-version:
57+
type: string
58+
working_directory: ~/web-monitoring-diff
59+
docker:
60+
- image: cimg/python:<< parameters.python-version >>
61+
steps:
62+
- checkout
63+
- setup_pip:
64+
python-version: << parameters.python-version >>
4565
- run:
4666
name: Tests
4767
command: |
48-
. venv/bin/activate
68+
. ~/venv/bin/activate
4969
coverage run -m pytest -vv
5070
- run:
5171
name: Coverage
5272
command: |
53-
. venv/bin/activate
73+
. ~/venv/bin/activate
5474
coverage report -m
75+
76+
lint:
77+
working_directory: ~/web-monitoring-diff
78+
docker:
79+
- image: cimg/python:<< pipeline.parameters.primary-python-version >>
80+
steps:
81+
- checkout
82+
- setup_pip:
83+
python-version: << pipeline.parameters.primary-python-version >>
5584
- run:
5685
name: Code linting
5786
command: |
58-
. venv/bin/activate
87+
. ~/venv/bin/activate
5988
flake8 .
60-
# - run:
61-
# name: Build docs
62-
# command: |
63-
# . venv/bin/activate
64-
# cd docs && make html
6589
6690
build_docker:
6791
machine:
@@ -149,7 +173,14 @@ workflows:
149173
#
150174
# See more in:
151175
# https://circleci.com/docs/2.0/workflows/#executing-workflows-for-a-git-tag
152-
- build:
176+
- test:
177+
filters:
178+
tags:
179+
only: /^v.*/
180+
matrix:
181+
parameters:
182+
python-version: ["3.7", "3.8", "3.9", "3.10"]
183+
- lint:
153184
filters:
154185
tags:
155186
only: /^v.*/
@@ -160,7 +191,8 @@ workflows:
160191
# Publishing only happens for tags starting with "v", and no branches.
161192
- publish_docker:
162193
requires:
163-
- build
194+
- test
195+
- lint
164196
- build_docker
165197
filters:
166198
branches:

.readthedocs.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
build:
9+
os: ubuntu-22.04
10+
tools:
11+
python: "3.10"
12+
apt_packages:
13+
- libxml2-dev
14+
- libxslt-dev
15+
- libssl-dev
16+
- openssl
17+
- libcurl4-openssl-dev
18+
19+
python:
20+
install:
21+
- method: pip
22+
path: "."
23+
extra_requirements:
24+
- server
25+
- docs
26+
- requirements: "requirements-experimental.txt"
27+
28+
sphinx:
29+
configuration: docs/source/conf.py
30+
31+
formats: all

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# We separate them out so that the final `release` image can layer on top of
77
# this one without needing compiler-related packages.
88
##
9-
FROM python:3.7.13-slim as base
9+
FROM python:3.10.7-slim as base
1010
LABEL maintainer="enviroDGI@gmail.com"
1111

1212
RUN apt-get update && apt-get install -y --no-install-recommends \

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,19 @@ First, make sure you have an appropriate Python version and the necessary system
189189
2. Perform an *editable* install of the package in the repo:
190190

191191
```sh
192-
$ pip install -e . --no-binary lxml
192+
$ pip install -e .[server,dev,docs] --no-binary lxml
193193
```
194194

195-
3. Install additional experimental and development dependencies:
195+
NOTE: if you are using Python 3.9 or earlier you may not be able to install both the development and docs dependencies at the same time. Instead, just install the `dev` dependencies:
196+
197+
```sh
198+
$ pip install -e .[server,dev] --no-binary lxml
199+
```
200+
201+
3. Install additional dependencies for experimental features:
196202

197203
```sh
198204
$ pip install -r requirements-experimental.txt
199-
$ pip install -r requirements-dev.txt
200205
```
201206

202207
4. Make sure it works without errors by running a python interpreter and importing the package:

docs/requirements.txt

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

docs/source/conf.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@
3131
# The full version, including alpha/beta/rc tags.
3232
release = web_monitoring_diff.__version__
3333

34-
3534
# -- General configuration ---------------------------------------------------
3635

36+
# The language for content autogenerated by Sphinx. Refer to documentation
37+
# for a list of supported languages.
38+
#
39+
# This is also used if you do content translation via gettext catalogs.
40+
# Usually you set "language" from the command line for these cases.
41+
language = 'en'
42+
3743
# Add any Sphinx extension module names here, as strings. They can be
3844
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3945
# ones.
@@ -55,6 +61,8 @@
5561
autosummary_generate = True
5662
numpydoc_show_class_members = False
5763
autodoc_mock_imports = ['html5_parser', 'pycurl', 'sentry']
64+
numpydoc_xref_param_type = True
65+
numpydoc_xref_ignore = {'type', 'optional', 'default'}
5866

5967
# Add any paths that contain templates here, relative to this directory.
6068
templates_path = ['_templates']
@@ -66,7 +74,7 @@
6674

6775
# Set up link shortcuts
6876
extlinks = {
69-
'issue': ('https://github.com/edgi-govdata-archiving/web-monitoring-diff/issues/%s', '#'),
77+
'issue': ('https://github.com/edgi-govdata-archiving/web-monitoring-diff/issues/%s', 'Issue #%s'),
7078
}
7179

7280
# Example configuration for intersphinx: refer to the Python standard library.

requirements-dev.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,3 @@
1010
coverage ~=6.5
1111
flake8 ~=5.0.4
1212
pytest ~=7.1.3
13-
ipython ~=7.34.0
14-
numpydoc ~=1.4
15-
sphinx ~=4.3.2
16-
sphinx-copybutton ~=0.5.0
17-
sphinx_rtd_theme ~=1.0.0

requirements-docs.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Tools for building documentation. Some of our docs tools conflict with dev
2+
# tools on Python < 10, so docs tools are listed here in order to make it
3+
# possible to skip installing them if not needed.
4+
#
5+
# Unlike most requirements.txt files, this is not a frozen list of exact
6+
# dependencies (a.k.a. a lock file). Instead, it specifies:
7+
# - Direct dependencies only.
8+
# - Package names and valid version *ranges*
9+
#
10+
# It only exists to keep the list of dependencies in a separate file from
11+
# setup.py.
12+
ipython ~=7.34.0
13+
numpydoc ~=1.4
14+
sphinx ~=5.2.3
15+
sphinx-copybutton ~=0.5.0
16+
sphinx_rtd_theme ~=1.0.0

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@ def read_requirements(fname):
7777
extras_require={
7878
'server': read_requirements('requirements-server.txt'),
7979
'dev': read_requirements('requirements-dev.txt'),
80+
'docs': read_requirements('requirements-docs.txt'),
8081
},
8182
)

web_monitoring_diff/server/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ class PublicError(tornado.web.HTTPError):
131131
132132
Parameters
133133
----------
134-
status_code : int, optional
135-
Status code for the response. Defaults to `500`.
134+
status_code : int, default: 500
135+
Status code for the response.
136136
public_message : str, optional
137137
Textual description of the error. This will be publicly visible in
138138
production mode, unlike `log_message`.

0 commit comments

Comments
 (0)