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
32 changes: 0 additions & 32 deletions .github/workflows/build-merged-pull-requests.yml

This file was deleted.

60 changes: 0 additions & 60 deletions .github/workflows/lint-test-upon-push.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab:

name: Lint code
on:
workflow_call:

jobs:
lint:
name: Linting code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: pip
- run: python -m pip install black flake8 pydocstyle
- run: python -m black --check .
- run: python -m flake8 .
- run: python -m pydocstyle .
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
# vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab:

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

on:
push:
tags:
- v*.*.*
- v*.*.*.dev*
- v*.*.*.post*

jobs:
build:
name: Build package
uses: ./.github/workflows/build-merged-pull-requests.yml
test:
uses: ./.github/workflows/test.yml
secrets: inherit

build:
name: Build wheel
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
- run: python -m pip install build
- run: python -m build .
- uses: actions/upload-artifact@v4
with:
name: package
path: dist/*.*

merge-into-stable:
name: Update stable branch to point to this release
runs-on: ubuntu-latest
needs: [build]
if: "!contains(github.ref, 'dev')"
permissions: write-all
steps:
- name: Clone repository, check-out stable
uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: stable
Expand All @@ -32,21 +49,22 @@ jobs:
git push

deploy:
name: Upload built package to PyPi
name: Upload built wheel and source package to PyPi
runs-on: ubuntu-latest
needs: [build]
environment:
name: pypi
url: https://pypi.org/p/cartogram
permissions:
id-token: write
steps:
- name: Download built artifacts
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: package
path: dist/
- name: Upload package to PyPi
uses: pypa/gh-action-pypi-publish@release/v1.9
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
skip-existing: true

release:
name: Create a new release
Expand All @@ -56,13 +74,11 @@ jobs:
permissions:
contents: write
steps:
- name: Download built artifacts
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: package
path: dist/
- name: Create release and upload package
uses: softprops/action-gh-release@v2
- uses: softprops/action-gh-release@v2
with:
files: dist/*

Expand All @@ -74,13 +90,11 @@ jobs:
permissions:
contents: write
steps:
- name: Download built artifacts
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: package
path: dist/
- name: Create release and upload package
uses: softprops/action-gh-release@v2
- uses: softprops/action-gh-release@v2
with:
files: dist/*
prerelease: true
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab:

name: Unit tests
on:
pull_request:
workflow_call:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
uses: ./.github/workflows/lint.yml
secrets: inherit

test:
name: Run tests (${{ matrix.os }}, Python ${{ matrix.python_version }}
needs: lint
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python_version:
- '3.13'
- '3.12'
- '3.11'
- '3.10'

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '${{matrix.python_version}}'
cache: 'pip'

- run: python -m pip install --prefer-binary .[tests]

- run: python -m pytest

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- **1.0.0** (2025-04-25):
- migrated to PyPi Trusted Publishing
- included tests in source wheels

- **0.0.2** (2024-07-15):
- added documentation

Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
recursive-include tests *.py
recursive-include tests/data *
global-exclude *.pyc
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@
class CitationsToSphinxDesignCardsTransformer(
sphinx.transforms.post_transforms.SphinxPostTransform
):
"""Modify the bibliography entries created by sphinxcontrib.bibtex to be sphinx-design cards."""

default_priority = (
198 # before anything from sphinx_design, but after sphinxcontrib.bibtex
)

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

def handle(self, node):
"""Modify a single node."""
new_node = self._create_empty_sdcard_container()
for attribute in ["backrefs", "docname", "ids"]:
new_node[attribute] = node[attribute]
Expand Down
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/env python3

"""Define how the documentation is compiled."""

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
Expand Down Expand Up @@ -41,7 +45,6 @@
"sphinx.ext.napoleon",
"sphinx_design",
"sphinxcontrib.bibtex",
"sphinxcontrib.images",
]

templates_path = ["_templates"]
Expand Down
15 changes: 12 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# *python-cartogram* - compute continuous cartograms


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

The nine federal provinces of Austria, distorted so their area sizes match their population numbers
:::

% -> https://github.com/sphinx-contrib/images/pull/39#issuecomment-2258779386

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


**python-cartogram** is a Python package that can be used to compute continuous
cartograms. These map-like cartographic visualisations, also known as
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies = [
"pandas",
"shapely"
]
requires-python = ">=3.9"
requires-python = ">=3.10"

classifiers = [
"Programming Language :: Python :: 3",
Expand All @@ -35,7 +35,7 @@ docs = ["folium", "GitPython", "jupyterlab_myst", "mapclassify", "matplotlib",
"myst-nb", "nbsphinx", "pybtex-apa7-style", "sphinx",
"sphinx-book-theme", "sphinx-design", "sphinxcontrib-bibtex",
"sphinxcontrib-images", "xyzservices"]
tests = ["pytest", "pytest-asyncio", "pytest-lazy-fixtures"]
tests = ["pytest", "pytest-cov", "pytest-lazy-fixtures"]

[project.urls]
Documentation = "https://python-cartogram.readthedocs.org/"
Expand All @@ -47,9 +47,9 @@ Repository = "https://github.com/austromorph/python-cartogram"
omit = ["tests/*", ".virtualenv/**/*"]

[tool.pytest.ini_options]
#addopts = "-p no:faulthandler -r s"
addopts = "--cov=cartogram --cov-report term-missing --cov-report xml"
pythonpath = ["src"]
testpaths = ["tests"]
asyncio_mode = "auto"

[tool.setuptools.dynamic]
version = {attr = "cartogram.__version__"}
2 changes: 1 addition & 1 deletion src/cartogram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""Compute continuous cartograms."""

__version__ = "0.0.2"
__version__ = "1.0.0"

from .cartogram import Cartogram

Expand Down
Loading