Skip to content
Draft
Show file tree
Hide file tree
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
21 changes: 10 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ jobs:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [ "3.10" ]

steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==2.0.1
- name: Setup Python 3.9
uses: actions/setup-python@v5
- name: Setup uv and Python
uses: astral-sh/setup-uv@v6
with:
python-version: "3.9"
cache: "poetry"
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Install Project
run: poetry install --no-interaction
run: uv sync --locked --group dev
- name: Ruff Lint Format
run: poetry run ruff format --check
run: uv run ruff format --check
id: format
- name: Ruff Lint Check
run: poetry run ruff check --output-format=github
run: uv run ruff check --output-format=github
if: success() || steps.format.conclusion == 'failure'
13 changes: 4 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==2.0.1
- name: Set up Python 3.9
uses: actions/setup-python@v5
- name: Setup uv and Python
uses: astral-sh/setup-uv@v6
with:
python-version: "3.9"
cache: "poetry"
- name: Install Python dependencies
run: poetry install --no-interaction --no-root
python-version: 3.10
- name: Build
run: poetry build
run: uv build
- name: Store distribution packages
uses: actions/upload-artifact@v4
with:
Expand Down
21 changes: 8 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,23 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
os: ["ubuntu-latest"]
include:
- python-version: "3.13"
- python-version: "3.14"
os: "windows-latest"

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==2.0.1
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Setup uv and Python
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Install Project
run: poetry install --no-interaction
- name: Poetry Build
run: poetry build
run: uv sync --locked --group dev
- name: Package Build
run: uv build
- name: Run tests
run: poetry run pytest
run: uv run pytest
13 changes: 4 additions & 9 deletions .github/workflows/test_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ jobs:

strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==2.0.1
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Setup uv and Python
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Install Project
run: poetry install --no-interaction
run: uv sync --locked --group dev
- name: Cache cassettes
uses: actions/cache@v4
with:
Expand Down
21 changes: 10 additions & 11 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.12"
python: "3.13"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"
apt_packages:
- graphviz
jobs:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry==2.0.1
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
# VIRTUAL_ENV needs to be set manually for now.
# See https://github.com/readthedocs/readthedocs.org/pull/11152/
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
pre_create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
create_environment:
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
install:
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs


# Build documentation in the "docs/" directory with Sphinx
sphinx:
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
.PHONY: test
test:
poetry run pytest
uv run pytest

.PHONY: integ
integ:
poetry run pytest --integration tests/integration --durations 0
uv run pytest --integration tests/integration --durations 0

.PHONY: mem
mem:
poetry run pytest --memray --memray-bin-path memray --integration tests/integration
uv run pytest --memray --memray-bin-path memray --integration tests/integration

.PHONY: prof
prof:
poetry run pyinstrument -m pytest --integration tests/integration
uv run pyinstrument -m pytest --integration tests/integration

.PHONY: lint
lint:
poetry run ruff check --fix
uv run ruff check --fix

.PHONY: format
format:
poetry run ruff format
uv run ruff format
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

Upcoming
--------

**Dependencies**

* Dropped support for Python 3.9

v1.6.0 (2025-09-10)
-------------------

Expand Down
34 changes: 20 additions & 14 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ Contributing
Get Started
-----------

To install USP for development, you'll need `Poetry <https://python-poetry.org/>`_ to automatically manage the virtual environment.
To install USP for development, you'll need `uv <https://docs.astral.sh/uv/>`_ to manage dependencies.

Fork and clone the repo, then run ``poetry install --with dev``. This will install all the dependencies and the package itself as an editable install. The remainder of this guide assumes you have activated the Poetry shell with ``poetry shell`` or will prefix each command with ``poetry run``.
Fork and clone the repo, then run ``uv sync`` to install dependencies in a local environment.

Generally, development is done with the lowest-supported Python version (currently 3.10). You may need to instruct uv to use this version by running ``uv venv --python 3.10``, or ``uv venv --python /path/to/python3.10``.

It's best practice to make an issue, or comment on an existing one, before working on your PR.

Expand All @@ -17,8 +19,8 @@ We use `Ruff <https://docs.astral.sh/ruff/>`_ to lint USP. This is done in two s

.. code-block:: bash

poetry run ruff check --fix
poetry run ruff format
uv run ruff check --fix
uv run ruff format

Testing
-------
Expand All @@ -30,7 +32,11 @@ When contributing please make sure that:
* any bugfixes include a test that fails without the fix
* any new functionality includes appropriate tests

To run tests, use ``pytest`` or ``make test``.
To run tests:

.. code-block:: bash

uv run pytest

Integration Tests
-----------------
Expand All @@ -50,39 +56,39 @@ To download and test against all cassettes, run:

.. code-block:: bash

python tests/integration/download.py
pytest --integration tests/integration
uv run tests/integration/download.py
uv run pytest --integration tests/integration

Memory Profiling
~~~~~~~~~~~~~~~~

Ensure you have installed the extra ``perf`` dependency group with ``poetry install --with perf``.
Ensure you have installed the extra ``perf`` dependency group with ``uv sync --group perf``.

To profile memory during integration tests, run the test command with ``--memray``.

.. code-block:: bash

pytest --integration [--memray-bin-path memray] tests/integration --memray
uv run pytest --integration [--memray-bin-path memray] tests/integration --memray

Without the ``--memray-bin-path`` argument, this will measure memory usage and report at the end of the test run.
With the argument, it will output the memory usage reports to the *memray* directory, which can then be used to generate reports e.g. `a flamegraph <https://bloomberg.github.io/memray/flamegraph.html>`_.

Performance Profiling
~~~~~~~~~~~~~~~~~~~~~

Ensure you have installed the extra ``perf`` dependency group with ``poetry install --with perf``.
Ensure you have installed the extra ``perf`` dependency group with ``uv sync --group perf``.

To profile performance during tests, run through the pyinstrument CLI:

.. code-block:: bash

pyinstrument -m pytest --integration tests/integration
uv run pyinstrument -m pytest --integration tests/integration

Pyinstrument does not distinguish between tests, so you may want to filter to a specific test at a time with ``-k``. For example, to only run the bbc.co.uk test:

.. code-block:: bash

pyinstrument -m pytest --integration -k bbc tests/integration
uv run pyinstrument -m pytest --integration -k bbc tests/integration

This can be viewed as an interactive HTML report by passing ``-r html`` to ``pyinstrument`` initially, or using the ``--load-prev`` command output at the end of the test run.

Expand All @@ -91,12 +97,12 @@ Documentation

This documentation is built with Sphinx.

To build documentation, install the extra ``docs`` dependency group with ``poetry install --with docs``, then:
To build documentation, install the extra ``docs`` dependency group with ``uv sync --with docs``, then:

.. code-block:: bash

cd docs
make livehtml
uv run make livehtml

This will start a live build of the docs at ``http://localhost:8000``.

Expand Down
Loading