Skip to content

Commit

Permalink
chore: Migrate from hatch to uv (#14)
Browse files Browse the repository at this point in the history
* Move dev-deps to uv.tool

* Create uv lock file

* Remove hatch cli config and update developer README

* Update workflows

* Update outdated pyproject.toml fields
  • Loading branch information
manzt authored Oct 18, 2024
1 parent 44b95e6 commit cc66891
Show file tree
Hide file tree
Showing 5 changed files with 347 additions and 78 deletions.
33 changes: 14 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,28 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: astral-sh/setup-uv@v3
with:
python-version: "3.x"
version: "0.4.x"
- run: |
pipx install hatch
hatch run lint
uv run ruff format --check
uv run ruff check
Schema:
name: JS viewconf validation with generated JSON Schema
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: astral-sh/setup-uv@v3
with:
python-version: "3.x"
version: "0.4.x"

- run: |
pip install -e .
higlass-schema export > schema.json
uvx --from . higlass-schema export > schema.json
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'
- run: npm install -g ajv-cli
- run: ajv validate -s schema.json -d "tests/fixtures/{docs/examples/viewconfs,test/{view-configs,view-configs-more}}/*.json"

Expand All @@ -46,17 +45,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pipx install hatch
hatch run test
version: "0.4.x"
- run: uv run pytest
env:
UV_PYTHON: ${{ matrix.python-version }}
9 changes: 3 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v4
- uses: astral-sh/setup-uv@v3
with:
python-version: "3.x"
version: "0.4.x"

- run: |
pipx install hatch
hatch build
- run: uv build

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@ pip install higlass-schema

## Development

Try it out:

```bash
$ pip install -e .
$ higlass-schema check ./example.json # [--verbose]
$ higlass-schema export # prints JSON schema to stdout
$ uvx --no-cache --from . higlass-schema check ./example.json # [--verbose]
$ uvx --no-cache --from . higlass-schema export # prints JSON schema to stdout
```

Testing, linting, & formatting are enforced in CI. Locally, you can run:

```sh
uv run pytest # tests
uv run ruff check # linting
uv run ruff format --check # formatting (remove --check to apply)
```

## Release
Expand Down
64 changes: 14 additions & 50 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,35 @@ build-backend = "hatchling.build"
[project]
name = "higlass-schema"
description = "Pydantic models for HiGlass"
authors = [
{ name = "Trevor Manz", email = "[email protected]" }
]
authors = [{ name = "Trevor Manz", email = "[email protected]" }]
license = { text = "MIT" }
readme = "README.md"
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
]
url = { homepage = "https://github.com/higlass/higlass-schema" }
requires-python = ">=3.8"
dynamic = ["version"]
dependencies = [
"pydantic>=1.10,<2.0",
"rich>=13.3.3",
]
dependencies = ["pydantic>=1.10,<2.0", "rich>=13.0.0"]

[project.optional-dependencies]
dev = [
"black",
"pytest",
"ruff",
]
[project.urls]
homepage = "https://github.com/higlass/higlass-schema"

[tool.uv]
dev-dependencies = ["black", "pytest", "ruff"]

[project.scripts]
higlass-schema = "higlass_schema.cli:main"

[tool.hatch.build]
sources = ["src"]

[tool.hatch.version]
source = "vcs"

[tool.hatch.envs.default]
features = ["dev"]

[tool.hatch.envs.default.scripts]
lint = [
"ruff {args:.}",
"black --check --diff {args:.}",
]
fmt = [
"black {args:.}",
"ruff --fix {args:.}",
"lint",
]
test = "pytest ."

# https://github.com/charliermarsh/ruff
[tool.ruff]
line-length = 88
target-version = "py38"
src = ["src", "tests"]

[tool.ruff.lint]
extend-select = [
"E", # style errors
"F", # flakes
"I", # isort
"UP", # pyupgrade
"RUF", # ruff-specific rules
"E", # style errors
"F", # flakes
"I", # isort
"UP", # pyupgrade
"RUF", # ruff-specific rules
]
Loading

0 comments on commit cc66891

Please sign in to comment.