Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v0.11.0
_commit: v0.14.2
_src_path: gl:znicholls/copier-core-python-repository
conda_release: false
email: zebedee.nicholls@climate-energy-college.org
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runs:
id: setup-uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.21"
version: "0.8.8"
python-version: ${{ inputs.python-version }}
- name: Install dependencies
shell: bash
Expand Down
43 changes: 15 additions & 28 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
name: Bump version
# For the time being, we still do this with pdm.
# Honestly, it doesn't really matter,
# but one day uv will have a bump command too and we can switch to that.
# Relevant issue in uv: https://github.com/astral-sh/uv/issues/6298

on:
workflow_dispatch:
inputs:
bump_rule:
type: choice
description: How to bump the project's version (see https://github.com/carstencodes/pdm-bump#usage)
description: How to bump the project's version (see https://docs.astral.sh/uv/reference/cli/#uv-version)
options:
- no-pre-release
# no micro because we always sit on a pre-release in main,
# so we would always use no-pre-release instead of micro
# - micro
- patch
- minor
- major
- "pre-release --pre alpha"
- "pre-release --pre beta"
- "pre-release --pre release-candidate"
- stable
- alpha
- beta
- rc
- post
- dev
required: true

jobs:
Expand All @@ -29,7 +25,7 @@ jobs:
strategy:
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.9" ]
python-version: [ "3.11" ]
runs-on: "${{ matrix.os }}"
env:
CI_COMMIT_EMAIL: "ci-runner@openscm-zenodo.invalid"
Expand All @@ -40,15 +36,6 @@ jobs:
fetch-depth: 0
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"

- name: Setup PDM
uses: pdm-project/setup-pdm@v4.1
with:
python-version: ${{ matrix.python-version }}

- name: Install pdm-bump
run: |
pdm self add pdm-bump

- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -59,13 +46,13 @@ jobs:
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$CI_COMMIT_EMAIL"

BASE_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.post]*\)"/\1/p' pyproject.toml`
echo "Bumping from version $BASE_VERSION"

# Bump
pdm bump ${{ github.event.inputs.bump_rule }}
uv version --bump ${{ github.event.inputs.bump_rule }}

NEW_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml`
echo "Bumping to version $NEW_VERSION"

# Build CHANGELOG
Expand All @@ -78,12 +65,12 @@ jobs:

# Bump to alpha (so that future commits do not have the same
# version as the tagged commit)
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml`

# Bump to pre-release of next version
pdm bump pre-release --pre alpha
uv version --bump post

NEW_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.post]*\)"/\1/p' pyproject.toml`
echo "Bumping version $BASE_VERSION > $NEW_VERSION"

# Commit and push
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
id: setup-uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.21"
version: "0.8.8"
python-version: ${{ matrix.python-version }}
- name: Create venv
run: |
Expand Down Expand Up @@ -187,8 +187,9 @@ jobs:
- name: Install
run: |
pip install --upgrade pip wheel
pip install .
pip install -r requirements-only-tests-locked.txt
pip install --no-deps .
pip install -r requirements-locked.txt
pip install -r requirements-only-tests-min-locked.txt
- name: Run tests
run: |
pytest tests -r a -vv tests
Expand All @@ -204,12 +205,17 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Set up Python "${{ matrix.python-version }}"
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
uv-dependency-install-flags: "--no-dev" # no extras is default
python-version: "${{ matrix.python-version }}"
- name: Install
run: |
pip install --upgrade pip wheel
pip install .
- name: Check importable without extras
run: uv run python scripts/test-install.py
run: python scripts/test-install.py

check-build:
strategy:
Expand All @@ -224,11 +230,15 @@ jobs:
id: setup-uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.21"
version: "0.8.8"
python-version: ${{ matrix.python-version }}
- name: Build package
run: |
uv run python scripts/add-locked-targets-to-pyproject-toml.py
cat pyproject.toml
uv build
# Just in case, undo the changes to `pyproject.toml`
git restore --staged . && git restore .
- name: Check build
run: |
tar -tvf dist/openscm_zenodo-*.tar.gz --wildcards '*openscm_zenodo/py.typed'
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ jobs:
id: setup-uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.21"
version: "0.8.8"
python-version: ${{ matrix.python-version }}
- name: Publish to PyPI
run: |
uv run python scripts/add-locked-targets-to-pyproject-toml.py
uv build
uv publish
# Just in case, undo the changes to `pyproject.toml`
git restore --staged . && git restore .
9 changes: 6 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.9" ]
python-version: [ "3.11" ]
runs-on: "${{ matrix.os }}"
steps:
- name: Check out repository
Expand All @@ -25,15 +25,18 @@ jobs:
id: setup-uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.21"
version: "0.8.8"
python-version: ${{ matrix.python-version }}
- name: Add version to environment
run: |
PROJECT_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
PROJECT_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml`
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
- name: Build package for PyPI
run: |
uv run python scripts/add-locked-targets-to-pyproject-toml.py
uv build
# Just in case, undo the changes to `pyproject.toml`
git restore --staged . && git restore .
- name: Generate Release Notes
run: |
echo "" >> ".github/release_template.md"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-upstream-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
id: setup-uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.21"
version: "0.8.8"
python-version: ${{ matrix.python-version }}
# Often you need a step like this for e.g. numpy, scipy, pandas
- name: Setup compilation dependencies
Expand Down
18 changes: 1 addition & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:
autoupdate_schedule: quarterly
autoupdate_branch: pre-commit-autoupdate
# Currently network access isn't supported in the pre-commit CI product.
skip: [uv-sync, uv-lock, uv-export, pdm-lock-check]
skip: [uv-sync, uv-lock, uv-export]

# See https://pre-commit.com/hooks.html for more hooks
repos:
Expand Down Expand Up @@ -60,19 +60,3 @@ repos:
args: ["-o", "requirements-only-tests-locked.txt", "--no-hashes", "--no-dev", "--no-emit-project", "--only-group", "tests"]
# # Not released yet
# - id: uv-sync
- repo: https://github.com/pdm-project/pdm
rev: 2.22.1
hooks:
# Update the `pdm.lock` file if needed.
# We need the pdm lock file too
# so that we can build the locked version of the package.
- name: pdm-lock
id: pdm-lock-check
# Overwrite the hook's standard entry point to get the behaviour we want
entry: pdm lock
args: ["--group", ":all", "--strategy", "inherit_metadata"]
files: ^pyproject.toml$
pass_filenames: false
# Double check that the `pdm.lock` file is up to date.
- id: pdm-lock-check
args: ["--group", ":all", "--strategy", "inherit_metadata"]
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ruff-fixes: ## fix the code using ruff

.PHONY: test
test: ## run the tests
uv run pytest src tests -r a -v --doctest-modules --cov=src
uv run pytest src tests -r a -v --doctest-modules --doctest-report ndiff --cov=src

# Note on code coverage and testing:
# You must specify cov=src.
Expand Down Expand Up @@ -80,12 +80,6 @@ licence-check: ## Check that licences of the dependencies are suitable
uv run liccheck -r $(TEMP_FILE) -R licence-check.txt
rm -f $(TEMP_FILE)

.PHONY: pdm-lock
pdm-lock: pdm.lock ## create/update the `pdm.lock` file

pdm.lock: pyproject.toml
pdm lock --group :all --strategy inherit_metadata

.PHONY: virtual-environment
virtual-environment: ## update virtual environment, create a new one if it doesn't already exist
uv sync --all-extras --group all-dev
Expand Down
1 change: 1 addition & 0 deletions changelog/18.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated to the latest version of the copier template
19 changes: 9 additions & 10 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ should change depending on the updates to the code base.
Releasing is semi-automated via a CI job.
The CI job requires the type of version bump
that will be performed to be manually specified.
See the pdm-bump docs for the
[list of available bump rules](https://github.com/carstencodes/pdm-bump#usage).
See the `uv version` docs (specifically the `--bump` flag) for the
[list of available bump rules](https://docs.astral.sh/uv/reference/cli/#uv-version).

### Standard process

The steps required are the following:

1. Bump the version: manually trigger the "bump" workflow from the main branch
(see here: [bump workflow](https://github.com/openscm/OpenSCM-zenodo/actions/workflows/bump.yaml)).
A valid "bump_rule" (see [pdm-bump's docs](https://github.com/carstencodes/pdm-bump#usage))
A valid "bump_rule" (see [uv's docs](https://docs.astral.sh/uv/reference/cli/#uv-version))
will need to be specified.
This will then trigger a draft release.

Expand All @@ -74,16 +74,15 @@ The steps required are the following:
else

1. Enjoy the newly available version
[TODO: add in conda release instructions]

#### Further details

We use [pdm](https://pdm-project.org/en/latest/) for building our project,
while [uv figures out how it wants to support building](https://github.com/astral-sh/uv/issues/3957).
This gives us the added benefit that we can use
[pdm-build-locked](https://pdm-build-locked.readthedocs.io/en/stable/)
to build locked versions of our package.
It is for these reasons that we have a pdm pre-commit hook
and a `pdm.lock` file in our repository.
We use [uv's build backend](https://docs.astral.sh/uv/concepts/build-backend) for building our project
and `scripts/add-locked-targets-to-pyproject-toml.py`
to provide locked extra groups for our package.
Including locked extra groups is why we run `scripts/add-locked-targets-to-pyproject-toml.py`
before any step related to building the package in the CI.

## Read the Docs

Expand Down
7 changes: 3 additions & 4 deletions docs/further-background/dependency-pinning-and-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ In the majority of cases, new releases do not cause issues
so pinning simply forces users to workaround overly strict pins[^1]
(which can be done, see
[working around incorrectly set pins][working-around-incorrectly-set-pins]).
The tradeoff with this approach is
This does run the risk that,
The tradeoff with this approach is that you run the risk that,
if a dependency releases a breaking change,
the function provided by our package may break too.

Expand Down Expand Up @@ -128,12 +127,12 @@ Finally, we also check the installation of the locked versions of the package,
i.e. installation with `pip install 'openscm-zenodo[locked]'`.
These tests give us the greatest coverage of Python versions and operating systems
and help alert us to places where users may face issues.
Having said that, these tests do require 30 separate CI runs,
Having said that, these tests do require 30 separate jobs,
which is why we don't run them in CI.

Through this combination of CI testing and installation testing,
we get a pretty good coverage of the different ways in which our package can be used.
It is not perfect, largely because the combinatorics don't allow for testing everything.
If we find a particular, key, use case failing often,
then we would happily discuss whether this should be included in the CI too,
to catch issues earlier than at user time.
to catch issues in advance of use.
19 changes: 17 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ plugins:
handlers:
python_xref:
paths: [src]
import:
inventories:
# Cross-ref helpers (lots included here, remove what you don't want)
- https://www.attrs.org/en/stable/objects.inv
- https://unidata.github.io/cftime/objects.inv
Expand All @@ -87,11 +87,25 @@ plugins:
- https://docs.scipy.org/doc/scipy/objects.inv
- https://scitools-iris.readthedocs.io/en/stable/objects.inv
- https://scmdata.readthedocs.io/en/stable/objects.inv
# # Not available for tqdm
# # https://github.com/tqdm/tqdm/issues/705
# - https://tqdm.github.io/objects.inv
- https://validators.readthedocs.io/en/stable/objects.inv
- http://xarray.pydata.org/en/stable/objects.inv
options:
# It turns out that xref does this check without considering config.
# As a result, every docstring is parsed as a google-style docstring.
# As docstrings are only parsed once, this results in rendering failures.
# Hence, turn off the checks here.
# mkdocs_autorefs catches anything which doesn't end up being a correct reference.
# The fix might be as simple as changing
# `self.collect(ref, PythonOptions())`
# to `self.collect(ref, self.get_options({}))`
# in the python-xref source, but it's hard to predict the side effects
# so we haven't bothered with that route.
check_crossrefs: false
docstring_style: numpy
relative_crossrefs: yes
relative_crossrefs: true
separate_signature: true
show_root_heading: false
show_signature_annotations: true
Expand All @@ -111,6 +125,7 @@ plugins:
markdown_extensions:
# https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown/#attribute-lists
- attr_list
- footnotes
# https://squidfunk.github.io/mkdocs-material/reference/math/#katex-mkdocsyml
- pymdownx.arithmatex:
generic: true
Expand Down
Loading
Loading