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

update pyproject.toml to work for uv #54

Merged
merged 8 commits into from
Nov 21, 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
41 changes: 14 additions & 27 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,23 @@ on:

jobs:
build:

name: python
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
run: |
python -m pip install --upgrade pip
pip install pipx flake8
pipx install hatch
- name: Set up pip cache
if: runner.os == 'Linux'
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}-py#{{ matrix.python-version }}
restore-keys: ${{ runner.os }}-pip-
- 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: Run tests
run: hatch test -i python=${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "0.5.2"
- name: Set up Python ${{ matrix.python-version }}
run : uv python install ${{ matrix.python-version }}
- name: Install project and dependencies
run: uv sync
- name: Run tests
run: uv run pytest tests
- name: Lint with ruff
run: uv run ruff check src/*
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
files: src|tests

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.4
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi]
- id: ruff-format
types_or: [ python, pyi]
106 changes: 56 additions & 50 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,26 @@ build-backend = "hatchling.build"

[project]
name = "nglui"
dynamic = ["version"]
version = "3.6.1"
description = "Framework for data-driven generation of neuroglancer states."
readme = "README.md"
license = "MIT"
requires-python = ">= 3.9"
requires-python = ">=3.9"
dependencies = [
"attrs>=24.2.0",
"caveclient>=7.0.0",
"ipython>=8.18.1",
"neuroglancer>=2.40.1",
"numpy>=1.26.4",
"pandas>=2.2.3",
"python-box>=7.2.0",
"requests>=2.32.3",
"six>=1.16.0",
"webcolors>=24.11.1",
]
authors = [
{ name = "Casey Schneider-Mizell", email = "[email protected]" },
{ name = "Derrick Brittain"},
{ name = "Forrest Collman" },
]

dependencies = [
"python-box",
"caveclient>=6.4.1",
"ipython",
"neuroglancer >= 2.40.1",
"numpy>=1.11.0",
"pandas>=1.0.0",
"requests",
"six",
"webcolors",
"attrs>=23.2.0",
]
classifiers = [
"License :: OSI Approved :: MIT License",
"Development Status :: 4 - Beta",
Expand All @@ -43,44 +40,53 @@ Repository = "https://github.com/CAVEconnectome/nglui.git"
Changelog = "https://caveconnectome.github.io/nglui/changelog/"
Issues = "https://github.com/CAVEconnectome/nglui/issues"

[tool.hatch.version]
path = "src/nglui/__init__.py"

[tool.hatch.build.targets.sdist]
include = [
"/src",
]

[tool.hatch.envs.default]
python = "3.12"
installer = "uv"

[tool.hatch.envs.nglui-nb]
python = "3.12"
installer = "uv"
extra-dependencies = [
"ipykernel",
]

[tool.hatch.envs.hatch-test]
extra-dependencies = [
[dependency-groups]
dev = [
"pytest",
"pytest-mock",
"pytest-cov",
"pytest-mock",
"responses",
"ipykernel",
"bump-my-version",
]
docs = [
"mkdocs",
"mkdocs-material",
"mkdocstrings[python]",
]
lint = [
"ruff"
]
[tool.uv]
default-groups = ["dev", "docs", "lint"]

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

[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.9", "3.10", "3.11", "3.12"]
[[tool.bumpversion.files]]
filename = "src/nglui/__init__.py"

[tool.ruff.lint]
select=["E9","F63","F7","F82"]

[tool.hatch.envs.docs]
dependencies = [
"mkdocs",
"mkdocs-material",
"mkdocstrings[python]",
]
[tool.hatch.envs.docs.scripts]
build = "mkdocs build --clean --strict"
serve = "mkdocs serve --dev-addr localhost:8000"
[tool.poe.tasks.drybump]
cmd = "uv run bump-my-version bump --dry-run --verbose"
help = "Dry run of version bump for the project. Use with 'patch', 'minor', or 'major' to specify the version change."

[tool.poe.tasks.bump]
cmd = "uv run bump-my-version bump"
help = "Bump the version number in the project. Use with 'patch', 'minor', or 'major' to specify the version change."
1 change: 0 additions & 1 deletion src/nglui/easyviewer/ev_base/nglite/json_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Facilities for converting JSON <-> Python objects"""


import collections
import copy
import inspect
Expand Down
1 change: 0 additions & 1 deletion src/nglui/easyviewer/ev_base/nglite/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def encode(self, source):
result.write(edges.tobytes())
if len(source.vertex_attributes) > 0:
for name, info in six.iteritems(source.vertex_attributes):

attribute = np.array(
vertex_attributes[name], np.dtype(info.data_type).newbyteorder("<")
)
Expand Down
1 change: 0 additions & 1 deletion src/nglui/easyviewer/ev_base/nglite_compatibility/base.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@


5 changes: 3 additions & 2 deletions src/nglui/segmentprops/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ def to_dataframe(self):
"Converts the segment properties to a pandas dataframe"
df_dict = {"ids": self.ids}
for prop in self._property_list():
if (
isinstance(prop, (DescriptionProperty, LabelProperty, NumberProperty, StringProperty))
if isinstance(
prop,
(DescriptionProperty, LabelProperty, NumberProperty, StringProperty),
):
df_dict[prop.id] = prop.values
elif isinstance(prop, TagProperty):
Expand Down
Loading