Skip to content

Commit e8cabbd

Browse files
committed
Fix #374 switch to Hatch for builds
Also update the GitHub CI workflows to use the new hatch commands
1 parent cc0e56b commit e8cabbd

File tree

5 files changed

+178
-146
lines changed

5 files changed

+178
-146
lines changed

.github/workflows/checks.yml

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,33 @@ on:
77
branches: [main]
88

99
jobs:
10-
build:
11-
10+
lint:
1211
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python 3.8
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: 3.8
18+
- name: Install Hatch
19+
run: pipx install hatch
20+
- name: Lint
21+
run: hatch run dev:lint
22+
- name: Type Check
23+
run: hatch run dev:typecheck
24+
tests:
25+
runs-on: ${{ matrix.os }}
1326
strategy:
1427
matrix:
1528
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16-
29+
os: [ubuntu-latest, windows-latest]
1730
steps:
18-
- uses: actions/checkout@v3
19-
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v4
21-
with:
22-
python-version: ${{ matrix.python-version }}
23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install .[tests]
27-
- name: Lint with flake8
28-
run: |
29-
# stop the build if there are Python syntax errors or undefined names
30-
flake8 delphin --count --select=E9,F63,F7,F82 --show-source --statistics
31-
# exit-zero treats all errors as warnings. PEP-8 says 99 chars is a good width
32-
flake8 delphin --count --exit-zero --extend-ignore E221 --max-line-length=99 --statistics
33-
# E221 = whitespace before operator
34-
# disabled for now: --max-complexity=10
35-
- name: Test with pytest
36-
run: |
37-
pytest .
38-
- name: Type-check with mypy
39-
run: |
40-
mypy delphin --namespace-packages --explicit-package-bases --ignore-missing-imports
31+
- uses: actions/checkout@v4
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
- name: Install Hatch
37+
run: pipx install hatch
38+
- name: Test
39+
run: hatch run dev:test

.github/workflows/publish.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Build and Publish to PyPI or TestPyPI
2+
3+
# Adapted from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
4+
5+
on:
6+
push
7+
8+
jobs:
9+
build:
10+
name: Build distribution
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.x"
18+
- name: Install Hatch
19+
run: pipx install hatch
20+
- name: Build
21+
run: hatch build
22+
- name: Store the distribution packages
23+
uses: actions/upload-artifact@v3
24+
with:
25+
name: python-package-distributions
26+
path: dist/
27+
28+
publish-to-pypi:
29+
name: Publish distributions to PyPI
30+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
31+
needs:
32+
- build
33+
runs-on: ubuntu-latest
34+
environment:
35+
name: pypi
36+
url: https://pypi.org/p/PyDelphin
37+
permissions:
38+
id-token: write # IMPORTANT: mandatory for trusted publishing
39+
steps:
40+
- name: Download the dists
41+
uses: actions/download-artifact@v3
42+
with:
43+
name: python-package-distributions
44+
path: dist/
45+
- name: Publish to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1
47+
48+
publish-to-testpypi:
49+
name: Publish distributions to TestPyPI
50+
needs:
51+
- build
52+
runs-on: ubuntu-latest
53+
environment:
54+
name: testpypi
55+
url: https://test.pypi.org/p/PyDelphin
56+
permissions:
57+
id-token: write # IMPORTANT: mandatory for trusted publishing
58+
steps:
59+
- name: Download the dists
60+
uses: actions/download-artifact@v3
61+
with:
62+
name: python-package-distributions
63+
path: dist/
64+
- name: Publish to TestPyPI
65+
uses: pypa/gh-action-pypi-publish@release/v1
66+
with:
67+
repository-url: https://test.pypi.org/legacy/
68+
skip-existing: true

.github/workflows/pythonpublish.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

pyproject.toml

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
11
[build-system]
2-
requires = ["setuptools>=40.8.0", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "PyDelphin"
7+
dynamic = ["version"]
8+
description = "Libraries and scripts for DELPH-IN data"
9+
readme = "README.md"
10+
requires-python = ">=3.8"
11+
license = "MIT"
12+
authors = [
13+
{name = "Michael Wayne Goodman", email = "[email protected]"}
14+
]
15+
keywords = ["nlp", "semantics", "hpsg", "delph-in", "linguistics"]
16+
classifiers = [
17+
"Development Status :: 5 - Production/Stable",
18+
"Environment :: Console",
19+
"Intended Audience :: Developers",
20+
"Intended Audience :: Information Technology",
21+
"Intended Audience :: Science/Research",
22+
"License :: OSI Approved :: MIT License",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Topic :: Scientific/Engineering :: Information Analysis",
30+
"Topic :: Software Development :: Libraries :: Python Modules",
31+
"Topic :: Text Processing :: Linguistic",
32+
"Topic :: Utilities",
33+
]
34+
dependencies = [
35+
"penman",
36+
"progress",
37+
"Pygments",
38+
]
39+
40+
[project.optional-dependencies]
41+
web = [
42+
"falcon",
43+
"requests",
44+
]
45+
repp = [
46+
"regex"
47+
]
48+
49+
[projects.scripts]
50+
delphin = "delphin.main:main"
51+
52+
[project.urls]
53+
Homepage = "https://github.com/delph-in/pydelphin"
54+
Documentation = "https://pydelphin.readthedocs.io"
55+
Changelog = "https://github.com/delph-in/pydelphin/blob/main/CHANGELOG.md"
56+
57+
[tool.hatch.version]
58+
path = "delphin/__about__.py"
59+
60+
[tool.hatch.build.targets.sdist]
61+
exclude = [
62+
"/.github",
63+
]
64+
65+
[tool.hatch.envs.dev]
66+
dependencies = [
67+
"pytest",
68+
"flake8",
69+
"mypy",
70+
"types-requests",
71+
]
72+
[tool.hatch.envs.dev.scripts]
73+
test = "pytest {args:.}"
74+
lint = "flake8 delphin --count --exit-zero --extend-ignore=E221 --max-line-length=99 --statistics"
75+
typecheck = "mypy delphin --namespace-packages --explicit-package-bases --ignore-missing-imports"
76+
77+
[tool.hatch.envs.docs]
78+
dependencies = [
79+
"sphinx",
80+
"sphinx-rtd-theme",
81+
"requests",
82+
"falcon",
83+
]
84+
[tool.hatch.envs.docs.scripts]
85+
build = "make -C docs html"
86+
clean = "make -C docs clean"

setup.py

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)