Skip to content

Commit

Permalink
Use pyproject.toml and new build system (#232)
Browse files Browse the repository at this point in the history
* draft pyproject.toml

* refactor versioning logic

* try redo dev workflow

* add lockfile

* try sync

* specify test dev

* lock

* remove 3.7

* add ipython

* try no ipython again

* add ipython back in

* add new lock

* test on 3.8 again

* skip locking

* fix venv command

* try uv run

* try oldest supported numpy

* docs

* rename

* fix up actions

* wip actions

* action fixes

* add pyproject.toml to bumpversion

* fix action

* change message name
  • Loading branch information
bdpedigo authored Nov 22, 2024
1 parent 2917de6 commit 8ecdc1c
Show file tree
Hide file tree
Showing 13 changed files with 4,966 additions and 147 deletions.
6 changes: 0 additions & 6 deletions .bumpversion.cfg

This file was deleted.

35 changes: 9 additions & 26 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
push:
branches:
- master
paths-ignore:
- "README.rst"
pull_request:
branches:
- master
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allows other workflows to trigger this workflow
Expand All @@ -27,32 +27,15 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v4
- name: Install the latest version of uv
id: setup-uv
uses: astral-sh/setup-uv@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('**/test_requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-
version: "0.5.2"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
pip install -r test_requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Set up venv
run: uv sync --python ${{ matrix.python-version }}

- name: Test with pytest
run: |
pytest
uvx --from poethepoet poe test
34 changes: 10 additions & 24 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,19 @@ jobs:
- name: Get gh-pages branch
run: git fetch origin gh-pages --depth=1

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Update pip
run: python -m pip install --upgrade pip

- name: Cache for virtual environment
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('doc_requirements.txt') }}

- name: Install dependencies
run: pip install -r doc_requirements.txt

- name: Configure git for github-actions[bot]
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# - name: Build and push versioned docs with mike
# run: |
# poetry run mike deploy --push --update-aliases dev
# poetry run mike set-default stable --push
- name: Install the latest version of uv
id: setup-uv
uses: astral-sh/setup-uv@v2
with:
version: "0.5.2"

- name: Build and push docs
run: |
mkdocs gh-deploy --force --remote-branch gh-pages --remote-name origin
- name: Set up Python
run: uv sync --python ${{ matrix.python-version }}

- name: Install dependencies
run: uvx --from poethepoet poe doc-push
13 changes: 8 additions & 5 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
with: # the --extend-select flag adds import sorting
args: check . --extend-select I
- uses: chartboost/ruff-action@v1
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v2
with:
args: format . --check
version: "0.5.2"
- name: Set up environment
run: uv sync --python 3.11
- name: Run format checks
run: uvx --from poethepoet poe lint
31 changes: 12 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ on:
type: boolean
required: true
default: true
skip-tests:
description: "Skip tests"
type: boolean
required: true
default: false

jobs:
bump:
Expand All @@ -37,23 +32,20 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v2
with:
version: "0.5.2"
- name: Get tags
run: git fetch --tags origin
- name: Configure git for github-actions[bot]
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Twine
run: pip install twine
- name: Install bumpversion
run: pip install bumpversion
- name: Bump version with bumpversion
run: |
bumpversion ${{ github.event.inputs.part }}
uvx --from bump-my-version bump-my-version bump ${{ github.event.inputs.part }}
- name: Commit and push with tags
if: ${{ github.event.inputs.dry-run == 'false' }}
run: git push --follow-tags
Expand Down Expand Up @@ -86,12 +78,13 @@ jobs:
with:
# want this to be the version that was just bumped
ref: master
- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.11"
- name: build sdist
run: python setup.py sdist
version: "0.5.2"
- name: Build
run: uv build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ A full description of the Connectome Annotation Versioning Engine can be found [
```bash
pip install caveclient
```

To add optional dependencies (currently for interfacing with the segmentation, imagery,
and some skeleton formats via cloud-volume), you can install with the following:

```bash
pip install caveclient[cv]
```

## Python version support
Currently we are officially supporting and testing against python 3.8, 3.9, 3.10, 3.11 and 3.12.

Currently we are officially supporting and testing against Python 3.8, 3.9, 3.10, 3.11 and 3.12.

## Documentation

Expand Down
4 changes: 3 additions & 1 deletion caveclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
__version__ = "7.0.2"
import importlib.metadata

__version__ = importlib.metadata.version("CAVEclient")

from .frameworkclient import CAVEclient
from .session_config import get_session_defaults, set_session_defaults
Expand Down
14 changes: 0 additions & 14 deletions doc_requirements.txt

This file was deleted.

94 changes: 94 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
[project]
authors = [{ name = "CAVE Developers" }]
classifiers = []
dependencies = [
"attrs>=21.3.0",
"cachetools>=4.2.1",
"ipython>6",
"jsonschema",
"networkx",
"oldest-supported-numpy",
"packaging>=24.1",
"pandas<3.0.0",
"pyarrow>=3",
"requests",
"urllib3",
]
description = "A client for interacting with the Connectome Annotation Versioning Engine"
license = "MIT"
maintainers = [{ name = "CAVE Developers" }]
name = "caveclient"
readme = "README.md"
requires-python = ">=3.8"
version = "7.0.2"

[project.urls]
Documentation = "https://caveconnectome.github.io/CAVEclient/"
Homepage = "https://caveconnectome.github.io/CAVEclient/"
Issues = "https://github.com/CAVEconnectome/CAVEclient/issues"
Repository = "https://github.com/CAVEconnectome/CAVEclient/"

[project.optional-dependencies]
cv = ["cloud-volume"]

[dependency-groups]
bump = ['bump-my-version']
dev = [
{ include-group = 'bump' },
{ include-group = 'docs' },
{ include-group = 'lint' },
{ include-group = 'test' },
]
docs = [
"mkdocs",
"mkdocs-autorefs",
"mkdocs-git-authors-plugin",
"mkdocs-git-committers-plugin-2",
"mkdocs-git-revision-date-localized-plugin",
"mkdocs-include-markdown-plugin",
"mkdocs-jupyter",
"mkdocs-macros-plugin",
"mkdocs-material",
"mkdocs-material-extensions",
"mkdocs-section-index",
"mkdocstrings[crystal,python]",
"mknotebooks",
"pymdown-extensions",
]
lint = ["ruff"]
test = ["pytest", "pytest-cov", "pytest-env", "pytest-mock", "responses"]

[tool.bumpversion]
allow_dirty = false
commit = true
commit_args = ""
current_version = "7.0.2"
ignore_missing_version = false
message = "Bump version: {current_version} → {new_version}"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
regex = false
replace = "{new_version}"
search = "{current_version}"
serialize = ["{major}.{minor}.{patch}"]
sign_tags = false
tag = true
tag_message = "Bump version: {current_version} → {new_version}"
tag_name = "v{new_version}"

[[tool.bumpversion.files]]
filename = "pyproject.toml"

[tool.poe.tasks]
checks = ['doc-build', 'lint', 'test']
doc-build = "mkdocs build"
doc-push = "mkdocs gh-deploy --force --remote-branch gh-pages --remote-name origin"
doc-serve = "mkdocs serve"
dry-bump = "uv run bump-my-version bump --dry-run --verbose"
lint = ['lint-check', 'lint-format']
lint-check = "uv run ruff check . --extend-select I"
lint-format = "uv run ruff format . --check"
test = "uv run pytest tests"

[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]
45 changes: 0 additions & 45 deletions setup.py

This file was deleted.

5 changes: 0 additions & 5 deletions test_requirements.txt

This file was deleted.

Loading

0 comments on commit 8ecdc1c

Please sign in to comment.