Skip to content

Commit 296f218

Browse files
Merge pull request #23 from RudolfCardinal/sqlalchemy2
SQLAlchemy 2 update, and bump to 2.0.0
2 parents 992e7a6 + feddb1e commit 296f218

File tree

130 files changed

+2714
-890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+2714
-890
lines changed

.github/scripts/build_docs.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,32 @@
44
# Rebuild Sphinx docs from scratch and check generated files match those checked
55
# in
66

7-
set -eux -o pipefail
7+
set -euo pipefail
8+
9+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
10+
PROJECT_ROOT_DIR=${THIS_DIR}/../..
11+
DOCS_DIR=${PROJECT_ROOT_DIR}/docs
12+
VENV_DIR=${HOME}/venv
13+
14+
cd "${PROJECT_ROOT_DIR}"
815

916
sudo apt-get install texlive-latex-extra dvipng
10-
python -m venv "${HOME}/venv"
11-
source "${HOME}/venv/bin/activate"
12-
python -VV
13-
python -m site
14-
python -m pip install -U pip
15-
echo installing pip packages
16-
python -m pip install -r docs/docs_requirements.txt
17-
python -m pip install -e .
17+
PYTHON=${VENV_DIR}/bin/python
18+
echo Installing pip packages for docs
19+
${PYTHON} -m pip install -r "${DOCS_DIR}/docs_requirements.txt"
1820
########################################################################################
19-
cd "${GITHUB_WORKSPACE}/docs"
2021
echo Creating autodocs
21-
python ./create_all_autodocs.py --make --destroy_first
22-
cd "${GITHUB_WORKSPACE}"
22+
${PYTHON} "${DOCS_DIR}/create_all_autodocs.py" --make --destroy_first
2323
echo Checking if files generated by create_all_autodocs need to be checked in
2424
git diff
2525
git update-index --refresh
2626
git diff-index --quiet HEAD --
2727
test -z "$(git ls-files --exclude-standard --others)"
28-
cd docs
2928
echo Rebuilding docs
30-
python ./rebuild_docs.py --warnings_as_errors
29+
30+
# Have to be in the virtualenv for sphinx-build to be picked up.
31+
source "${VENV_DIR}"/bin/activate
32+
python "${DOCS_DIR}/rebuild_docs.py" --warnings_as_errors
3133
echo Checking if files generated by rebuild_docs need to be checked in
3234
git diff
3335
git update-index --refresh
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SYSTEM_PYTHON=python3
6+
7+
if [ $# -eq 1 ]; then
8+
# Script needs at least Python 3.10 for docs. Allow this to be specified
9+
SYSTEM_PYTHON=$1
10+
fi
11+
12+
VENV_DIR=${HOME}/venv
13+
14+
${SYSTEM_PYTHON} -m venv "${VENV_DIR}"
15+
PYTHON=${VENV_DIR}/bin/python
16+
${PYTHON} -VV
17+
${PYTHON} -m site
18+
${PYTHON} -m pip install -U pip setuptools
19+
echo Dumping pre-installed packages
20+
${PYTHON} -m pip freeze
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
PROJECT_ROOT_DIR=${THIS_DIR}/../..
7+
VENV_DIR=${HOME}/venv
8+
9+
PYTHON=${VENV_DIR}/bin/python
10+
echo Installing pip packages
11+
${PYTHON} -m pip install -e "${PROJECT_ROOT_DIR}"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
VENV_DIR=${HOME}/venv
6+
7+
PYTHON=${VENV_DIR}/bin/python
8+
${PYTHON} -m pip install "numpy<1.23" # 1.23 incompatible with numba
9+
${PYTHON} -m pip install xlrd
10+
${PYTHON} -m pip install dogpile.cache==0.9.2 # Later versions incompatible
11+
${PYTHON} -m pip install pytest
12+
${PYTHON} -m pip install xhtml2pdf weasyprint pdfkit # For PDF tests

.github/scripts/python_checks.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
# Run from .github/workflows/python_checks.yml
44

5-
set -eux -o pipefail
5+
set -euo pipefail
66

7-
python3 -m venv "${HOME}/venv"
8-
source "${HOME}/venv/bin/activate"
9-
python -m site
10-
python -m pip install -U pip setuptools
7+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8+
PROJECT_ROOT_DIR=${THIS_DIR}/../..
9+
VENV_DIR=${HOME}/venv
10+
PYTHON=${VENV_DIR}/bin/python
11+
PRECOMMIT=${VENV_DIR}/bin/pre-commit
1112

12-
echo installing pip packages
13-
python -m pip install -e .
14-
python -m pip install pre-commit
13+
cd "${PROJECT_ROOT_DIR}"
1514

16-
echo running pre-commit checks
17-
pre-commit run --all-files
15+
echo Installing pre-commit
16+
${PYTHON} -m pip install -e .
17+
${PYTHON} -m pip install pre-commit
18+
19+
echo Running pre-commit checks
20+
${PRECOMMIT} run --all-files

.github/scripts/run_tests.sh

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,16 @@
22

33
# Run from .github/workflows/tests.yml
44

5-
set -eux -o pipefail
5+
set -euo pipefail
66

7-
sudo apt-get install wkhtmltopdf
7+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8+
PROJECT_ROOT_DIR=${THIS_DIR}/../..
9+
VENV_DIR=${HOME}/venv
10+
PYTEST=${VENV_DIR}/bin/pytest
811

9-
python -m venv "${HOME}/venv"
10-
source "${HOME}/venv/bin/activate"
11-
python -m site
12-
python -m pip install -U pip
13-
echo installing pip packages
12+
sudo apt-get install wkhtmltopdf
1413

15-
python -m pip install "numpy<1.23" # 1.23 incompatible with numba
16-
python -m pip install xlrd
17-
python -m pip install dogpile.cache==0.9.2 # Later versions incompatible
18-
python -m pip install pytest
19-
python -m pip install xhtml2pdf weasyprint pdfkit # For PDF tests
20-
python -m pip install -e .
14+
cd "${PROJECT_ROOT_DIR}"
2115

2216
# pytest --log-cli-level=INFO
23-
pytest
17+
${PYTEST}

.github/workflows/docs.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,27 @@ on: push
66

77
jobs:
88
build-docs:
9-
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
include:
12+
- name: ubuntu-22.04
13+
os: ubuntu-22.04
14+
python-version: "3.10"
15+
runs-on: ${{ matrix.os }}
1016
steps:
11-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Create virtualenv
22+
run: ${GITHUB_WORKSPACE}/.github/scripts/create_virtualenv.sh
23+
- name: Install base Python packages
24+
run: ${GITHUB_WORKSPACE}/.github/scripts/install_base_python_packages.sh
1225
- name: Build docs
1326
run: ${GITHUB_WORKSPACE}/.github/scripts/build_docs.sh
27+
- name: Dump stuff on failure
28+
if: failure()
29+
run: |
30+
set -euxo pipefail
31+
ls -l ${HOME}/venv/bin
32+
${HOME}/venv/bin/python -m pip freeze

.github/workflows/python_checks.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@ on:
66
push:
77
paths:
88
- '**.py'
9-
- .github/workflows/python-checks.yml
9+
- .github/scripts/create_virtualenv.sh
10+
- .github/scripts/install_base_python_packages.sh
1011
- .github/scripts/python_checks.sh
12+
- .github/workflows/python-checks.yml
1113
jobs:
1214
python-checks:
1315
runs-on: ubuntu-latest
1416
strategy:
1517
matrix:
16-
python-version: ["3.8", "3.9", "3.10"]
18+
python-version: ["3.9", "3.10"]
1719
steps:
18-
- uses: actions/checkout@v3
19-
- uses: actions/setup-python@v4
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-python@v5
2022
with:
2123
python-version: ${{ matrix.python-version }}
24+
- name: Create virtualenv
25+
run: ${GITHUB_WORKSPACE}/.github/scripts/create_virtualenv.sh
26+
- name: Install base Python packages
27+
run: ${GITHUB_WORKSPACE}/.github/scripts/install_base_python_packages.sh
2228
- name: Python checks
2329
run: ${GITHUB_WORKSPACE}/.github/scripts/python_checks.sh

.github/workflows/run_tests.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
---
22
# yamllint disable rule:line-length
3-
name: Tests
3+
name: Run tests
44
# yamllint disable-line rule:truthy
55
on:
66
push:
77
paths:
88
- '**.py'
99
- .github/scripts/change_apt_mirror.sh
10-
- .github/workflows/run_tests.yml
10+
- .github/scripts/create_virtualenv.sh
11+
- .github/scripts/install_base_python_packages.sh
12+
- .github/scripts/install_test_python_packages.sh
1113
- .github/scripts/run_tests.sh
14+
- .github/workflows/run_tests.yml
1215
jobs:
13-
pip-install-and-tests:
16+
run-tests:
1417
runs-on: ubuntu-latest
1518
strategy:
1619
matrix:
17-
python-version: ["3.8", "3.9", "3.10"]
20+
python-version: ["3.9", "3.10"]
1821
steps:
19-
- uses: actions/checkout@v3
20-
- uses: actions/setup-python@v4
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-python@v5
2124
with:
2225
python-version: ${{ matrix.python-version }}
2326
- name: Change apt mirror
24-
run: |
25-
set -euxo pipefail
26-
${GITHUB_WORKSPACE}/.github/scripts/change_apt_mirror.sh
27+
run: ${GITHUB_WORKSPACE}/.github/scripts/change_apt_mirror.sh
28+
- name: Create virtualenv
29+
run: ${GITHUB_WORKSPACE}/.github/scripts/create_virtualenv.sh
30+
- name: Install test Python packages
31+
run: ${GITHUB_WORKSPACE}/.github/scripts/install_test_python_packages.sh
32+
- name: Install base Python packages
33+
run: ${GITHUB_WORKSPACE}/.github/scripts/install_base_python_packages.sh
2734
- name: Run tests
2835
run: ${GITHUB_WORKSPACE}/.github/scripts/run_tests.sh

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ repos:
1818
rev: 5.0.4
1919
hooks:
2020
- id: flake8
21+
- repo: https://github.com/asottile/yesqa
22+
rev: v1.5.0
23+
hooks:
24+
- id: yesqa
25+
- repo: https://github.com/pre-commit/pygrep-hooks
26+
rev: v1.9.0
27+
hooks:
28+
- id: python-check-blanket-noqa

0 commit comments

Comments
 (0)