Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp build #91

Merged
merged 6 commits into from
Dec 25, 2024
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
176 changes: 107 additions & 69 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,114 +15,152 @@ concurrency:
cancel-in-progress: true

jobs:
lint:
name: Lint

lint-build:
name: Linting
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install poetry
run: pip install "poetry==1.4.2"
- name: Install dependencies
run: poetry install
- name: Lint
run: poetry run flake8
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Ruff lint
run: |
ruff check --output-format=github .
- name: Ruff format
run: |
ruff format --check .

docs-build:
name: Docs
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install poetry
run: pip install "poetry==1.4.2"
- name: Install dependencies
run: poetry install --with docs
python-version: 3.12
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
pip install -U -e .[docs]
- name: Build docs
run: |
cd docs
poetry run make html SPHINXOPTS="-W --keep-going"
make html SPHINXOPTS="-W --keep-going"

test:
name: Test on ${{ matrix.name }}
runs-on: ubuntu-latest
test-builds:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux py38
pyversion: '3.8'
- name: Linux py39
- name: Test py39
os: ubuntu-latest
pyversion: '3.9'
- name: Linux py310
- name: Test py310
os: ubuntu-latest
pyversion: '3.10'
- name: Test py311
os: ubuntu-latest
pyversion: '3.11'
- name: Test py312
os: ubuntu-latest
pyversion: '3.12'
- name: Test py313
os: ubuntu-latest
pyversion: '3.13'
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.pyversion }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.pyversion }}
- name: Install poetry
# Note: we may wish to install in a dedicated venv in the future
# to avoid updating/changing poetries dependencies accidentally
run: pip install "poetry==1.4.2"
- name: Install dependencies
run: poetry install
- name: Test
run: poetry run pytest -v --cov=pylinalg --cov-report=term-missing
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.pyversion }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyversion }}
- name: Install package and dev dependencies
run: |
python -m pip install --upgrade pip
pip install .[tests]
rm -r pylinalg
- name: Unit tests
run: |
pytest -v tests --cov=pylinalg --cov-report=term-missing

build:
name: Build and test wheel
release-build:
name: Build release on ubuntu-latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install poetry
run: pip install "poetry==1.4.2"
- name: Install dependencies
run: poetry install
- name: Build wheel
run: poetry build
- name: Twine check
run: poetry run twine check dist/*
- name: Upload wheel artifact
uses: actions/upload-artifact@v2
with:
path: dist
name: dist
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
pip install -U flit build twine
- name: Create source distribution
run: |
python -m build -n -s
- name: Build wheel
run: |
python -m build -n -w
- name: Test sdist
shell: bash
run: |
rm -rf ./pylinalg
pushd $HOME
pip install $GITHUB_WORKSPACE/dist/*.tar.gz
python -c "import pylinalg; print(pylinalg.__version__)"
popd
# don't run tests, we just want to know if the sdist can be installed
pip uninstall -y pylinalg
git reset --hard HEAD
- name: Twine check
run: |
twine check dist/*
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
path: dist
name: dist

publish:
name: Publish release to Github and Pypi
runs-on: ubuntu-latest
needs: [lint, test, build]
needs: [test-builds, release-build]
if: success() && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: 3.12
- name: Download assets
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
dist/*.tar.gz
dist/*.whl
draft: true
prerelease: false
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
15 changes: 9 additions & 6 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.9"
jobs:
post_install:
- pip install poetry==1.4.2
- poetry config virtualenvs.create false
- poetry install --with docs
python: "3.12"

sphinx:
configuration: docs/conf.py
fail_on_warning: true

# Optionally declare the Python requirements required to build your docs
python:
install:
- method: pip
path: .
extra_requirements:
- docs
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ Linear algebra utilities for Python.
```bash
pip install pylinalg
```

### Development Install
To get a working dev install of pylinalg you can use the following steps:

```bash
# Click the Fork button on GitHub and navigate to your fork
git clone <address_of_your_fork>
cd pylinalg
# if you use a venv, create and activate it
pip install -e ".[dev,docs,examples]"
pytest tests
```
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# -- Project information -----------------------------------------------------

project = "pylinalg"
copyright = "2021-2023, Almar Klein, Korijn van Golen"
copyright = "2021-2025, Almar Klein, Korijn van Golen"
author = "Almar Klein, Korijn van Golen"

# The full version, including alpha/beta/rc tags
Expand Down
Loading
Loading