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
5 changes: 5 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
exclude:
authors:
- dependabot
- pre-commit-ci
27 changes: 10 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: CI

permissions:
contents: read

Expand All @@ -19,26 +20,21 @@ env:
FORCE_COLOR: 3

jobs:
pre-commit:
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.x"
- name: Install uv
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: --hook-stage manual --all-files
- name: Run PyLint
run: |
echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
pipx run nox -s pylint
run: uv run --group nox nox -s pylint -- --output-format=github

tests:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
needs: [pre-commit]
needs: [format]
strategy:
fail-fast: false
matrix:
Expand All @@ -52,17 +48,14 @@ jobs:
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
- name: Install uv
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install package
run: python -m pip install .[test]

- name: Test package
run: >-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
uv run --group test pytest --cov --cov-report=xml --cov-report=term
--durations=20

- name: Upload coverage report
Expand All @@ -73,7 +66,7 @@ jobs:
status:
name: CI Pass
runs-on: ubuntu-latest
needs: [pre-commit, tests]
needs: [format, tests]
if: always()
steps:
- name: All required jobs passed
Expand Down
16 changes: 0 additions & 16 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from sybil import Sybil
from sybil.parsers.rest import DocTestParser, PythonCodeBlockParser, SkipParser

from optional_dependencies import OptionalDependencyEnum, auto

# TODO: stop skipping doctests on Windows when there is uniform support for
# numpy 2.0+ scalar repr. On windows it is printed as 1.0 instead of
# `np.float64(1.0)`.
Expand All @@ -24,17 +22,3 @@
parsers=parsers,
patterns=["*.rst", "*.py"],
).pytest()


class OptDeps(OptionalDependencyEnum): # type: ignore[misc] # pylint: disable=invalid-enum-extension
"""Optional dependencies for ``zeroth``."""

ASTROPY = auto()
GALA = auto()


collect_ignore_glob = []
if not OptDeps.ASTROPY.installed:
collect_ignore_glob.append("src/unxt/_interop/unxt_interop_astropy/*")
if not OptDeps.GALA.installed:
collect_ignore_glob.append("src/unxt/_interop/unxt_interop_gala/*")
88 changes: 65 additions & 23 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,94 @@
"""Nox configuration."""
# pylint: disable=import-error

import shutil
from pathlib import Path

import nox

nox.needs_version = ">=2024.3.2"
nox.options.sessions = [
# Linting
"lint",
"precommit",
"pylint",
# Testing
"tests",
]
nox.options.default_venv_backend = "uv"


DIR = Path(__file__).parent.resolve()

nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["lint", "pylint", "tests"]
nox.options.default_venv_backend = "uv|virtualenv"
# =============================================================================
# Linting


@nox.session
def lint(session: nox.Session) -> None:
@nox.session(venv_backend="uv")
def lint(session: nox.Session, /) -> None:
"""Run the linter."""
session.install("pre-commit")
session.run(
"pre-commit",
"run",
"--all-files",
"--show-diff-on-failure",
*session.posargs,
precommit(session) # reuse pre-commit session
pylint(session) # reuse pylint session


@nox.session(venv_backend="uv")
def precommit(session: nox.Session, /) -> None:
"""Run pre-commit."""
session.run_install(
"uv",
"sync",
"--group=lint",
f"--python={session.virtualenv.location}",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("pre-commit", "run", "--all-files", *session.posargs)


@nox.session
def pylint(session: nox.Session) -> None:
@nox.session(venv_backend="uv")
def pylint(session: nox.Session, /) -> None:
"""Run PyLint."""
# This needs to be installed into the package environment, and is slower
# than a pre-commit check
session.install(".", "pylint")
session.run_install(
"uv",
"sync",
"--group=lint",
f"--python={session.virtualenv.location}",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("pylint", "zeroth", *session.posargs)


@nox.session
def tests(session: nox.Session) -> None:
# =============================================================================
# Testing


@nox.session(venv_backend="uv")
def tests(session: nox.Session, /) -> None:
"""Run the unit and regular tests."""
session.install(".[test]")
session.run_install(
"uv",
"sync",
"--group=test",
f"--python={session.virtualenv.location}",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("pytest", *session.posargs)


@nox.session
def build(session: nox.Session) -> None:
# =============================================================================


@nox.session(venv_backend="uv")
def build(session: nox.Session, /) -> None:
"""Build an SDist and wheel."""
build_path = DIR.joinpath("build")
if build_path.exists():
shutil.rmtree(build_path)

session.install("build")
session.run_install(
"uv",
"sync",
"--group=build",
f"--python={session.virtualenv.location}",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("python", "-m", "build")
136 changes: 79 additions & 57 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,67 +1,89 @@
[project]
name = "zeroth"
dynamic = ["version"]
description = "Efficiently get the index-0 element of an iterable."
readme = "README.md"
requires-python = ">=3.9"
authors = [
{ name = "Nathaniel Starkman", email = "nstarman@users.noreply.github.com" },
]
classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
]
license.file = "LICENSE"
dependencies = []

[project.urls]
"Bug Tracker" = "https://github.com/GalacticDynamics/zeroth/issues"
Changelog = "https://github.com/GalacticDynamics/zeroth/releases"
Discussions = "https://github.com/GalacticDynamics/zeroth/discussions"
Homepage = "https://github.com/GalacticDynamics/zeroth"


[build-system]
build-backend = "hatchling.build"
requires = ["hatch-vcs", "hatchling"]


[project]
authors = [
{ name = "Nathaniel Starkman", email = "nstarman@users.noreply.github.com" },
]
classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
]
dependencies = []
description = "Efficiently get the index-0 element of an iterable."
dynamic = ["version"]
license.file = "LICENSE"
name = "zeroth"
readme = "README.md"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = ["zeroth[docs,test]"]
docs = [
"furo>=2023.08.17",
"myst_parser>=0.13",
"sphinx>=7.0",
"sphinx_autodoc_typehints",
"sphinx_copybutton",
]
test = [
"numpy",
"optional_dependencies >= 0.3",
"pytest >=6",
"pytest-cov >=3",
"pytest-github-actions-annotate-failures",
"sybil",
]

[project.urls]
"Bug Tracker" = "https://github.com/GalacticDynamics/zeroth/issues"
Changelog = "https://github.com/GalacticDynamics/zeroth/releases"
Discussions = "https://github.com/GalacticDynamics/zeroth/discussions"
Homepage = "https://github.com/GalacticDynamics/zeroth"
[dependency-groups]
dev = [
"ipykernel>=6.29.5",
"cz-conventional-gitmoji>=0.6.1",
{ include-group = "build" },
{ include-group = "docs" },
{ include-group = "lint" },
{ include-group = "nox" },
{ include-group = "test" },
]
build = [
"build>=1.3.0",
]
docs = [
"furo>=2023.08.17",
"myst_parser>=0.13",
"sphinx>=7.0",
"sphinx-autodoc-typehints>=2.3.0",
"sphinx-copybutton>=0.5.2",
]
lint = [
"pre-commit>=4.1.0",
"pylint>=3.3.8",
]
nox = ["nox>=2024.10.9"]
test = [
"numpy>=2.0.2",
"optional_dependencies>=0.3",
"pytest>=8.4.2",
"pytest-cov>=6.2.1",
"pytest-github-actions-annotate-failures>=0.3.0",
"sybil[pytest]>=9.2.0",
]


[tool.hatch]
version.source = "vcs"
build.hooks.vcs.version-file = "src/zeroth/_version.py"
version.source = "vcs"


[tool.codespell]
skip = "uv.lock"


[tool.hatch.envs.default]
features = ["test"]
scripts.test = "pytest {args}"
[tool.commitizen]
name = "cz_gitmoji"


[tool.pytest.ini_options]
Expand All @@ -74,8 +96,8 @@
]
filterwarnings = ["error"]
log_cli_level = "INFO"
minversion = "6.0"
testpaths = ["tests/", "docs", "src/"]
minversion = "8.3"
testpaths = ["src/", "tests/", "README", "docs"]
xfail_strict = true


Expand Down
Loading
Loading