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
19 changes: 6 additions & 13 deletions .github/workflows/deploy_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,16 @@ jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
uses: actions/checkout@v5
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Build
run: |
pip install wheel
pip install pbr
python setup.py sdist bdist_wheel
run: uv build
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
20 changes: 7 additions & 13 deletions .github/workflows/deploy_test_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,19 @@ jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
uses: actions/checkout@v5
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Build
run: |
pip install wheel
VERSION=$(python -c "import re; print(re.search(r\"__version__ = '(.+)'\", open('kingdon/__init__.py').read()).group(1))")
DEV_VERSION="${VERSION}.dev${{ github.run_number }}"
sed -i "s/version='${VERSION}'/version='${DEV_VERSION}'/" setup.py
python setup.py sdist bdist_wheel
uv version --frozen "$(uv version --short).dev${{ github.run_number }}"
uv build
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
14 changes: 5 additions & 9 deletions .github/workflows/generate_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
uses: actions/checkout@v5
- name: Set up uv and Python 3.13
uses: astral-sh/setup-uv@v7
with:
python-version: '3.13'
cache: pip
cache-dependency-path: requirements_docs.txt
enable-cache: true
- name: Build docs
run: |
sudo apt-get install pandoc
pip install --upgrade -r requirements_docs.txt
pip install --upgrade .
mkdir docs_build
sphinx-build -nW -b html docs docs_build
uv run --locked --group docs sphinx-build -nW -b html docs docs_build
26 changes: 9 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,22 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12', '3.13']
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: actions/checkout@v5
- name: Set up uv and Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.py
enable-cache: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[test]"
run: uv sync --locked --group test
# The array tests are parametrized over the array libraries that einops and
# array-api-compat both support, and skip those that are not installed. They are only
# installed on the newest python, since their wheels are large. cupy is absent
# altogether because it needs a GPU.
- name: Install torch and jax
if: matrix.python-version == '3.13'
# The CPU-only index keeps torch to a ~200 MB wheel, instead of the several GB of CUDA
# wheels that the default PyPI build pulls in and that the tests have no use for.
run: |
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install jax
if: matrix.python-version == '3.14'
run: uv sync --locked --group test --group arrays
- name: Test with pytest
run:
pytest
run: uv run --no-sync pytest
23 changes: 7 additions & 16 deletions .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
- uses: actions/checkout@v5
- name: Set up uv and Python 3.14
uses: astral-sh/setup-uv@v7
with:
python-version: '3.13'
cache: pip
cache-dependency-path: setup.py
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coveralls pytest-cov
pip install -e ".[test]"
python-version: '3.14'
enable-cache: true
- name: Test with coverage
run: |
pytest --cov=kingdon
run: uv run --locked --group test --with pytest-cov pytest --cov=kingdon
- name: Upload to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install --upgrade coveralls
coveralls --service=github
run: uv run --no-sync --with coveralls coveralls --service=github
24 changes: 11 additions & 13 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@
# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
os: ubuntu-24.04
tools:
python: "3.11"
python: "3.13"
jobs:
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 --locked --group docs

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
install:
- requirements: requirements_docs.txt
- method: pip
path: .
extra_requirements:
- all
27 changes: 14 additions & 13 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,24 @@ Ready to contribute? Here's how to set up `kingdon` for local development.

$ git clone git@github.com:your_name_here/kingdon.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
3. Set up your fork for local development with `uv <https://docs.astral.sh/uv/>`_, which creates a virtualenv in ``.venv`` with kingdon and its test dependencies installed::

$ mkvirtualenv kingdon
$ cd kingdon/
$ python setup.py develop
$ uv sync --group test

4. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

5. When you're done making changes, check that your changes pass flake8 and the
tests::
5. When you're done making changes, check that the tests pass::

$ flake8 kingdon tests
$ pytest
$ uv run pytest

To get flake8, just pip install it into your virtualenv.
To also run the array tests against torch and jax, add their group::

$ uv run --group arrays pytest

6. Commit your changes and push your branch to GitHub::

Expand All @@ -101,7 +100,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.11, 3.12, and 3.13, and for PyPy. Check
3. The pull request should work for Python 3.10 up to 3.14. Check
https://github.com/tBuLi/kingdon/actions
and make sure that the tests pass for all supported Python versions.

Expand All @@ -110,7 +109,7 @@ Tips

To run a subset of tests::

$ pytest tests.test_kingdon
$ uv run pytest tests/test_kingdon.py


Deploying
Expand All @@ -120,7 +119,9 @@ A reminder for the maintainers on how to deploy.
Make sure all your changes are committed (including an entry in HISTORY.rst).
Then run::

$ bump-my-version bump patch # possible: major / minor / patch, add --dry-run -vv for dry-run.
$ git push origin <tag_name>
$ uv version --bump patch # possible: major / minor / patch, add --dry-run for a dry run.
$ git commit -am "Bump version to $(uv version --short)"
$ git tag v$(uv version --short)
$ git push origin master v$(uv version --short)

Travis will then deploy to PyPI if tests pass.
Pushing the tag makes GitHub Actions build kingdon and publish it to PyPI.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Next release
------------
* Fixed integer powers of multivectors with interval-valued or otherwise non-scalar
coefficients by preserving repeated symbolic operands in geometric squares.
* Python 3.10 and 3.14 are now supported.
* Packaging moved from setup.py to pyproject.toml, and development to uv (thanks @arsenovic).

0.1.0 (2023-08-12)
------------------
Expand Down
12 changes: 0 additions & 12 deletions MANIFEST.in

This file was deleted.

9 changes: 8 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ To install Kingdon, run this command in your terminal:

$ pip install kingdon

or, to add it to a `uv`_ project:

.. code-block:: console

$ uv add kingdon

This is the preferred method to install Kingdon, as it will always install the most recent stable release.

If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.

.. _pip: https://pip.pypa.io
.. _uv: https://docs.astral.sh/uv/
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/


Expand All @@ -44,7 +51,7 @@ Once you have a copy of the source, you can install it with:

.. code-block:: console

$ python setup.py install
$ pip install .


.. _Github repo: https://github.com/tbuli/kingdon
Expand Down
4 changes: 3 additions & 1 deletion kingdon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

__author__ = """Martin Roelfs"""
__email__ = 'martinroelfs@yahoo.com'
__version__ = '3.0.0'

import sys
import importlib.metadata

from sympy import symbols

Expand All @@ -18,6 +18,8 @@
)
from kingdon.matrixreps import expr_as_matrix

__version__ = importlib.metadata.version('kingdon')


def load_ipython_extension(ipython):
""" Register the :code:`%%graph` cell magic; called by :code:`%load_ext kingdon`. """
Expand Down
48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "kingdon"
version = "3.0.0"
description = "Pythonic Geometric Algebra Package"
readme = "README.rst"
license = "MIT"
license-files = ["LICENSE"]
authors = [{name = "Martin Roelfs", email = "martinroelfs@yahoo.com"}]
keywords = ["kingdon", "geometric algebra"]
# types.EllipsisType is new in 3.10.
requires-python = ">=3.10"
dependencies = ["numpy", "sympy", "anywidget"]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]

[project.urls]
Homepage = "https://github.com/tbuli/kingdon"
Changelog = "https://github.com/tbuli/kingdon/blob/master/HISTORY.rst"

[dependency-groups]
test = ["pytest>=3", "einops", "array-api-compat"]
# The array tests are parametrized over the array libraries that einops and array-api-compat both support, and skip those that are not installed.
# cupy is not listed because it needs a GPU; install it by hand with `pip install "cupy-cuda12x[ctk]"`, matching 12x/13x to your driver's CUDA version.
# The [ctk] extra installs the CUDA libraries as wheels, which cuda-pathfinder prefers over a system-wide CUDA toolkit; a version mismatch with the latter is an access violation rather than an error.
arrays = ["torch", "jax"]
docs = ["sphinx", "einops", "nbsphinx", "ipykernel", "symfit", "matplotlib", "clifford"]

# The CPU-only index keeps torch to a ~200 MB wheel, instead of the several GB of CUDA wheels that the tests have no use for.
[tool.uv.sources]
torch = {index = "pytorch-cpu"}

[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

9 changes: 0 additions & 9 deletions requirements_dev.txt

This file was deleted.

Loading
Loading