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

pyproject.toml #11

Merged
merged 5 commits into from
May 2, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
pip install hatch

- name: Run tests
run: pytest
run: hatch run test:all
lint:
runs-on: ubuntu-latest

Expand All @@ -38,10 +38,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
pip install hatch

- name: Sourcery login
run: sourcery login --token ${{ secrets.SOURCERY_TOKEN }}
- name: Setup environment
run: |
hatch run sourcery login --token ${{ secrets.SOURCERY_TOKEN }}

- name: Set up pre-commit
uses: pre-commit/action@v3.0.0
48 changes: 42 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ This package is in active development.

### Setup

After cloning the repository, install the package in editable mode with the development dependencies using:
This project uses [hatch](https://hatch.pypa.io/latest/) to manage the development environment and build and publish releases. Make sure `hatch` is [installed](https://hatch.pypa.io/latest/install/) first:

```bash
$ pip install -e .[dev]
$ pip install hatch
```

Now you can [enter the development environment](https://hatch.pypa.io/latest/environment/#entering-environments) using:

```bash
$ hatch shell
```

This will install development dependencies in an isolated environment and drop you into a shell (use `exit` to leave).

### Pre-commit

This project uses [pre-commit](https://pre-commit.com/) to run testing, linting, type-checking, and formatting. You can run pre-commit manually with:
Use [pre-commit](https://pre-commit.com/) to run linting, type-checking, and formatting:

```bash
$ pre-commit run --all-files
Expand All @@ -26,16 +34,44 @@ $ pre-commit run --all-files
$ pre-commit install
```

You can run pre-commit hooks separately and pass additional arguments to them. For example, to run `flake8` on a single file:

```bash
$ pre-commit run flake8 --files=src/sklearn_knn/_base.py
```

### Testing

Unit tests are *not* run by `pre-commit`, but can be run manually with:
Unit tests are *not* run by `pre-commit`, but can be run manually using `hatch` [scripts](https://hatch.pypa.io/latest/config/environment/overview/#scripts):

```bash
$ pytest
$ hatch run test:all
```

Measure test coverage with:

```bash
$ pytest --cov=sklearn_knn
$ hatch run test:coverage
```

Any additional arguments are passed to `pytest`. For example, to run a subset of tests matching a keyword:

```bash
$ hatch run test:all -k gnn
```

### Releasing

First, use `hatch` to [update the version number](https://hatch.pypa.io/latest/version/#updating).

```bash
$ hatch version [major|minor|patch]
```

Then, [build](https://hatch.pypa.io/latest/build/#building) and [publish](https://hatch.pypa.io/latest/publish/#publishing) the release to PyPI with:

```bash
$ hatch clean
$ hatch build
$ hatch publish
```
54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "scikit-learn-knn"
dynamic = ["version"]
description = "Scikit-learn estimators for kNN methods"
readme = "README.md"
license = ""
requires-python = ">=3.8"
authors = [
{ name = "Matt Gregory", email = "matt.gregory@oregonstate.edu" },
{ name = "Aaron Zuspan", email = "aaron.zuspan@oregonstate.edu" }
]
dependencies = [
"numpy",
"scikit-learn",
]

[project.urls]
Homepage = "https://github.com/lemma-osu/scikit-learn-knn"
Source = "https://github.com/lemma-osu/scikit-learn-knn"

[tool.hatch.version]
path = "src/sklearn_knn/__about__.py"

[tool.hatch.build.targets.wheel]
packages = ["src/sklearn_knn"]

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

[tool.hatch.envs.default]
dependencies = [
"pre-commit",
"sourcery",
]

[tool.hatch.envs.test]
dependencies = [
"pytest",
"pytest-cov",
"pandas"
]

[tool.hatch.envs.test.scripts]
all = "pytest {args}"
coverage = "pytest --cov=src/sklearn_knn {args}"

[tool.pytest.ini_options]
pythonpath = "src/"
40 changes: 0 additions & 40 deletions setup.py

This file was deleted.

1 change: 1 addition & 0 deletions src/sklearn_knn/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
1 change: 1 addition & 0 deletions src/sklearn_knn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .__about__ import __version__ # noqa: F401
from ._euclidean import Euclidean
from ._gnn import GNN
from ._mahalanobis import Mahalanobis
Expand Down