Skip to content

Commit 78dda84

Browse files
v1.0.0 (#2)
* update github action runners * Include tests in source packages * prepare v1.0.0 * typo * linted * coverage * coverage * remove sphinxcontrib-images * typo * add some more tests * linted
1 parent 1e10521 commit 78dda84

15 files changed

Lines changed: 292 additions & 129 deletions

File tree

.github/workflows/build-merged-pull-requests.yml

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

.github/workflows/lint-test-upon-push.yml

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

.github/workflows/lint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab:
2+
3+
name: Lint code
4+
on:
5+
workflow_call:
6+
7+
jobs:
8+
lint:
9+
name: Linting code
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.13'
16+
cache: pip
17+
- run: python -m pip install black flake8 pydocstyle
18+
- run: python -m black --check .
19+
- run: python -m flake8 .
20+
- run: python -m pydocstyle .
Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,44 @@
11
# vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab:
22

3-
name: Create a release and deploy to PyPi whenever a protected tag (v0.0.0) is created
3+
name: Create a release and deploy to PyPi
44

55
on:
66
push:
77
tags:
88
- v*.*.*
9+
- v*.*.*.dev*
10+
- v*.*.*.post*
911

1012
jobs:
11-
build:
12-
name: Build package
13-
uses: ./.github/workflows/build-merged-pull-requests.yml
13+
test:
14+
uses: ./.github/workflows/test.yml
1415
secrets: inherit
1516

17+
build:
18+
name: Build wheel
19+
needs: test
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.13"
26+
cache: "pip"
27+
- run: python -m pip install build
28+
- run: python -m build .
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: package
32+
path: dist/*.*
33+
1634
merge-into-stable:
1735
name: Update stable branch to point to this release
1836
runs-on: ubuntu-latest
1937
needs: [build]
2038
if: "!contains(github.ref, 'dev')"
2139
permissions: write-all
2240
steps:
23-
- name: Clone repository, check-out stable
24-
uses: actions/checkout@v4.1.1
41+
- uses: actions/checkout@v4
2542
with:
2643
fetch-depth: 0
2744
ref: stable
@@ -32,21 +49,22 @@ jobs:
3249
git push
3350
3451
deploy:
35-
name: Upload built package to PyPi
52+
name: Upload built wheel and source package to PyPi
3653
runs-on: ubuntu-latest
3754
needs: [build]
55+
environment:
56+
name: pypi
57+
url: https://pypi.org/p/cartogram
58+
permissions:
59+
id-token: write
3860
steps:
39-
- name: Download built artifacts
40-
uses: actions/download-artifact@v3
61+
- uses: actions/download-artifact@v4
4162
with:
4263
name: package
4364
path: dist/
44-
- name: Upload package to PyPi
45-
uses: pypa/gh-action-pypi-publish@release/v1.9
65+
- uses: pypa/gh-action-pypi-publish@release/v1
4666
with:
47-
user: __token__
48-
password: ${{ secrets.PYPI_API_TOKEN }}
49-
skip_existing: true
67+
skip-existing: true
5068

5169
release:
5270
name: Create a new release
@@ -56,13 +74,11 @@ jobs:
5674
permissions:
5775
contents: write
5876
steps:
59-
- name: Download built artifacts
60-
uses: actions/download-artifact@v3
77+
- uses: actions/download-artifact@v4
6178
with:
6279
name: package
6380
path: dist/
64-
- name: Create release and upload package
65-
uses: softprops/action-gh-release@v2
81+
- uses: softprops/action-gh-release@v2
6682
with:
6783
files: dist/*
6884

@@ -74,13 +90,11 @@ jobs:
7490
permissions:
7591
contents: write
7692
steps:
77-
- name: Download built artifacts
78-
uses: actions/download-artifact@v3
93+
- uses: actions/download-artifact@v4
7994
with:
8095
name: package
8196
path: dist/
82-
- name: Create release and upload package
83-
uses: softprops/action-gh-release@v2
97+
- uses: softprops/action-gh-release@v2
8498
with:
8599
files: dist/*
86100
prerelease: true

.github/workflows/test.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab:
2+
3+
name: Unit tests
4+
on:
5+
pull_request:
6+
workflow_call:
7+
push:
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
lint:
17+
uses: ./.github/workflows/lint.yml
18+
secrets: inherit
19+
20+
test:
21+
name: Run tests (${{ matrix.os }}, Python ${{ matrix.python_version }}
22+
needs: lint
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os:
28+
- ubuntu-latest
29+
- windows-latest
30+
- macos-latest
31+
python_version:
32+
- '3.13'
33+
- '3.12'
34+
- '3.11'
35+
- '3.10'
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: '${{matrix.python_version}}'
43+
cache: 'pip'
44+
45+
- run: python -m pip install --prefer-binary .[tests]
46+
47+
- run: python -m pytest
48+
49+
- uses: codecov/codecov-action@v4
50+
with:
51+
fail_ci_if_error: true
52+
token: ${{ secrets.CODECOV_TOKEN }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
- **1.0.0** (2025-04-25):
2+
- migrated to PyPi Trusted Publishing
3+
- included tests in source wheels
4+
15
- **0.0.2** (2024-07-15):
26
- added documentation
37

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
recursive-include tests *.py
2+
recursive-include tests/data *
3+
global-exclude *.pyc

docs/_extensions/bibliography_as_sphinxdesign_cards/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@
5959
class CitationsToSphinxDesignCardsTransformer(
6060
sphinx.transforms.post_transforms.SphinxPostTransform
6161
):
62+
"""Modify the bibliography entries created by sphinxcontrib.bibtex to be sphinx-design cards."""
63+
6264
default_priority = (
6365
198 # before anything from sphinx_design, but after sphinxcontrib.bibtex
6466
)
6567

6668
def apply(self, **kwargs):
69+
"""Apply the transformation to all relevant nodes."""
6770
for node in self.document.findall(docutils.nodes.citation):
6871
self.handle(node)
6972

7073
def handle(self, node):
74+
"""Modify a single node."""
7175
new_node = self._create_empty_sdcard_container()
7276
for attribute in ["backrefs", "docname", "ids"]:
7377
new_node[attribute] = node[attribute]

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/bin/env python3
2+
3+
"""Define how the documentation is compiled."""
4+
15
# Configuration file for the Sphinx documentation builder.
26
#
37
# For the full list of built-in configuration values, see the documentation:
@@ -41,7 +45,6 @@
4145
"sphinx.ext.napoleon",
4246
"sphinx_design",
4347
"sphinxcontrib.bibtex",
44-
"sphinxcontrib.images",
4548
]
4649

4750
templates_path = ["_templates"]

docs/index.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# *python-cartogram* - compute continuous cartograms
22

33

4-
:::{thumbnail} _static/images/Austria_PopulationCartogram_NUTS2_20170101.svg
4+
:::{figure} _static/images/Austria_PopulationCartogram_NUTS2_20170101.svg
55
:alt: A map showing the nine federal provinces of Austria, distorted in a way that their relative areas relate to their population numbers.
6-
:title: The nine federal provinces of Austria, distorted so their area sizes match their population numbers
7-
:show_caption: 1
86
:class: align-default
7+
8+
The nine federal provinces of Austria, distorted so their area sizes match their population numbers
99
:::
1010

11+
% -> https://github.com/sphinx-contrib/images/pull/39#issuecomment-2258779386
12+
13+
% :::{thumbnail} _static/images/Austria_PopulationCartogram_NUTS2_20170101.svg
14+
% :alt: A map showing the nine federal provinces of Austria, distorted in a way that their relative areas relate to their population numbers.
15+
% :title: The nine federal provinces of Austria, distorted so their area sizes match their population numbers
16+
% :show_caption: 1
17+
% :class: align-default
18+
% :::
19+
1120

1221
**python-cartogram** is a Python package that can be used to compute continuous
1322
cartograms. These map-like cartographic visualisations, also known as

0 commit comments

Comments
 (0)