Skip to content

Commit bce40de

Browse files
committed
switch to hatch from setuptools
1 parent c39b6e6 commit bce40de

File tree

6 files changed

+157
-88
lines changed

6 files changed

+157
-88
lines changed

.github/workflows/ci-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
python-version: ${{ env.py-semver }}
4646
cache: pip
4747
cache-dependency-path: |
48-
requirements.txt
4948
tox.ini
5049
5150
- name: install dev libraries
@@ -137,7 +136,6 @@ jobs:
137136
python-version: 3.12
138137
cache: pip
139138
cache-dependency-path: |
140-
requirements.txt
141139
test-requirements.txt
142140
143141
- name: Install packages

Makefile

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ cleanup: sort_imports format flake8 pydocstyle
5252
install-dep: install-dependencies
5353

5454
install-dependencies:
55-
pip install -U pip setuptools wheel
55+
pip install -U pip wheel
5656
pip install --upgrade $(DEVPKGS)
5757

5858
## install-deb-dep : install many of the dev dependencies via apt-get
@@ -65,14 +65,14 @@ install: FORCE
6565

6666
## dev : install the cwl-utils package in dev mode
6767
dev: install-dep
68-
pip install -U pip setuptools wheel
68+
pip install -U pip wheel
6969
pip install -e .$(EXTRAS)
7070

7171
## dist : create a module package for distribution
7272
dist: dist/${MODULE}-$(VERSION).tar.gz
7373

7474
dist/${MODULE}-$(VERSION).tar.gz: $(SOURCES)
75-
python -m build
75+
python3 -m build
7676

7777
## docs : make the docs
7878
docs: FORCE
@@ -86,36 +86,36 @@ clean: FORCE
8686

8787
# Linting and code style related targets
8888
## sort_import : sorting imports using isort: https://github.com/timothycrosley/isort
89-
sort_imports: $(PYSOURCES)
90-
isort $^
89+
sort_imports: FORCE
90+
isort $(PYSOURCES)
9191

92-
remove_unused_imports: $(PYSOURCES)
93-
autoflake --in-place --remove-all-unused-imports $^
92+
remove_unused_imports: FORCE
93+
autoflake --in-place --remove-all-unused-imports $(PYSOURCES)
9494

9595
pep257: pydocstyle
9696
## pydocstyle : check Python docstring style
97-
pydocstyle: $(PYSOURCES)
98-
ruff check $^
97+
pydocstyle: FORCE
98+
ruff check $(PYSOURCES)
9999

100100
## codespell : check for common misspellings
101-
codespell:
101+
codespell: FORCE
102102
codespell -w $(shell git ls-files | grep -v mypy-stubs)
103103

104104
## format : check/fix all code indentation and formatting (runs black)
105-
format: $(PYSOURCES) FORCE
105+
format: FORCE
106106
black $(PYSOURCES)
107107

108-
format-check: $(PYSOURCES)
109-
black --diff --check $^
108+
format-check: FORCE
109+
black --diff --check $(PYSOURCES)
110110

111111
## pylint : run static code analysis on Python code
112-
pylint: $(PYSOURCES)
112+
pylint: FORCE
113113
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
114-
$^ -j0|| true
114+
$(PYSOURCES) -j0|| true
115115

116-
pylint_report.txt: $(PYSOURCES)
116+
pylint_report.txt: FORCE
117117
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
118-
$^ -j0> $@ || true
118+
$(PYSOURCES) -j0> $@ || true
119119

120120
diff_pylint_report: pylint_report.txt
121121
diff-quality --compare-branch=main --violations=pylint pylint_report.txt
@@ -144,34 +144,37 @@ diff-cover.html: coverage.xml
144144
diff-cover --compare-branch=main $^ --html-report $@
145145

146146
## test : run the cwl-utils test suite
147-
test: $(PYSOURCES)
148-
python -m pytest ${PYTEST_EXTRA}
147+
test: FORCE
148+
python3 -m pytest ${PYTEST_EXTRA}
149149

150150
## testcov : run the cwl-utils test suite and collect coverage
151-
testcov: $(PYSOURCES)
152-
python -m pytest --cov ${PYTEST_EXTRA}
151+
testcov: FORCE
152+
python3 -m pytest --cov ${PYTEST_EXTRA}
153153

154-
sloccount.sc: $(PYSOURCES) Makefile
155-
sloccount --duplicates --wide --details $^ > $@
154+
sloccount.sc: FORCE
155+
sloccount --duplicates --wide --details $(PYSOURCES) Makefile > $@
156156

157157
## sloccount : count lines of code
158-
sloccount: $(PYSOURCES) Makefile
159-
sloccount $^
158+
sloccount: FORCE
159+
sloccount $(PYSOURCES) Makefile
160160

161161
list-author-emails:
162162
@echo 'name, E-Mail Address'
163163
@git log --format='%aN,%aE' | sort -u | grep -v 'root'
164164

165-
mypy3: mypy
166-
mypy: ${PYSOURCES}
167-
MYPYPATH=$$MYPYPATH:mypy-stubs mypy $^
165+
mypy: FORCE
166+
MYPYPATH=$$MYPYPATH:mypy-stubs mypy $(PYSOURCES)
167+
168+
mypyc: FORCE
169+
MYPYPATH=mypy-stubs HATCH_BUILD_HOOKS_ENABLE=1 pip install --verbose -e . \
170+
&& pytest "${PYTEST_EXTRA}"
168171

169172
shellcheck: FORCE
170173
shellcheck release-test.sh
171174

172-
pyupgrade: $(PYSOURCES)
173-
pyupgrade --exit-zero-even-if-changed --py310-plus $^
174-
auto-walrus $^
175+
pyupgrade: FORCE
176+
pyupgrade --exit-zero-even-if-changed --py310-plus $(PYSOURCES)
177+
auto-walrus $(PYSOURCES)
175178

176179
release-test: FORCE
177180
git diff-index --quiet HEAD -- || ( echo You have uncommitted changes, please commit them and try again; false )
@@ -180,13 +183,13 @@ release-test: FORCE
180183
release: release-test
181184
. testenv2/bin/activate && \
182185
pip install build && \
183-
python -m build testenv2/src/${PACKAGE} && \
186+
python3 -m build testenv2/src/${PACKAGE} && \
184187
pip install twine && \
185188
twine upload testenv2/src/${PACKAGE}/dist/* && \
186189
git tag ${VERSION} && git push --tags
187190

188-
flake8: $(PYSOURCES)
189-
flake8 $^
191+
flake8: FORCE
192+
flake8 $(PYSOURCES)
190193

191194
cwl_utils/parser/cwl_v1_0.py: FORCE
192195
schema-salad-tool --codegen python \

pyproject.toml

Lines changed: 113 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["setuptools>=61.2"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling>=1.27.0"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "cwl-utils"
@@ -30,7 +30,15 @@ classifiers = [
3030
"Typing :: Typed",
3131
]
3232
requires-python = ">=3.10,<3.15"
33-
dynamic = ["version", "dependencies"]
33+
dynamic = ["version"]
34+
dependencies = [
35+
"cwl-upgrader >= 1.2.3",
36+
"packaging",
37+
"rdflib",
38+
"requests",
39+
"schema-salad >= 8.8.20250205075315,<9",
40+
"ruamel.yaml >= 0.17.6, < 0.19",
41+
]
3442

3543
[project.urls]
3644
Documentation = "https://cwl-utils.readthedocs.io/"
@@ -44,7 +52,13 @@ Changelog = "https://github.com/common-workflow-language/cwl-utils/releases"
4452
pretty = ["cwlformat"]
4553
testing = [
4654
"pytest<10",
47-
"pytest-mock",
55+
"pytest-cov",
56+
"pytest-xdist[psutil]",
57+
"cwl-utils[pretty]",
58+
"pytest-mock >= 1.10.0",
59+
"jsonschema >= 4.21.1",
60+
"udocker",
61+
"cwltool",
4862
]
4963

5064
[project.scripts]
@@ -55,41 +69,109 @@ cwl-graph-split = "cwl_utils.graph_split:main"
5569
cwl-normalizer = "cwl_utils.normalizer:main"
5670
cwl-inputs-schema-gen = "cwl_utils.inputs_schema_gen:main"
5771

58-
[tool.aliases]
59-
test = "pytest"
60-
6172
[tool.pytest.ini_options]
6273
testpaths = ["tests"]
6374
addopts = "-rsx -n auto"
6475

65-
[tool.setuptools]
66-
packages = [
67-
"cwl_utils",
68-
"cwl_utils.parser",
69-
"cwl_utils.tests",
70-
"cwl_utils.testdata",
71-
"cwl_utils.testdata.checker_wf",
72-
"cwl_utils.testdata.extensions",
73-
"cwl_utils.testdata.types",
74-
"cwl_utils.testdata.workflows",
76+
[tool.hatch.version]
77+
path = "cwl_utils/__meta__.py"
78+
79+
[tool.hatch.build.targets.sdist]
80+
exclude = [
81+
"/.github",
82+
"**~",
83+
"**.pyc",
84+
"**.orig",
85+
]
86+
include = [
87+
"/README.rst",
88+
"/Makefile",
89+
"/LICENSE",
90+
"/*requirements.txt",
91+
"/create_cwl_from_objects.py",
92+
"/load_cwl_by_path.py",
93+
"/cwl_utils/**.py",
94+
"/cwl_utils/*.js",
95+
"/cwl_utils/templates/*",
96+
"/tests/**.py",
97+
"/testdata/*.cwl",
98+
"/testdata/*.yaml",
99+
"/testdata/*.yml",
100+
"/testdata/*.input",
101+
"/testdata/*.json",
102+
"/testdata/*.ttl",
103+
"/testdata/*.owl",
104+
"/testdata/*.js",
105+
"/testdata/remote-cwl/*.cwl",
106+
"/testdata/workflows/*.cwl",
107+
"/testdata/workflows/*.yaml",
108+
"/testdata/types/*.yml",
109+
"/testdata/checker_wf/*.cwl",
110+
"/testdata/extensions/*.cwl",
111+
"/cwl_utils/py.typed",
112+
"/docs/conf.py",
113+
"/docs/Makefile",
114+
"/docs/_static/favicon.ico",
115+
"/docs/requirements.txt",
116+
"/docs/*.rst",
117+
]
118+
119+
[tool.hatch.build.targets.wheel]
120+
exclude = [
121+
"/.github",
122+
"**~",
123+
"**.pyc",
124+
"**.orig",
125+
]
126+
include = [
127+
"/README.rst",
128+
"/Makefile",
129+
"/LICENSE",
130+
"/load_cwl_by_path.py",
131+
"/cwl_utils/**.py",
132+
"/cwl_utils/*.js",
133+
"/cwl_utils/templates/*",
134+
"/tests/**.py",
135+
"/testdata/*.cwl",
136+
"/testdata/*.yaml",
137+
"/testdata/*.yml",
138+
"/testdata/*.input",
139+
"/testdata/*.json",
140+
"/testdata/*.ttl",
141+
"/testdata/*.owl",
142+
"/testdata/*.js",
143+
"/testdata/remote-cwl/*.cwl",
144+
"/testdata/workflows/*.cwl",
145+
"/testdata/workflows/*.yaml",
146+
"/testdata/types/*.yml",
147+
"/testdata/checker_wf/*.cwl",
148+
"/testdata/extensions/*.cwl",
149+
"/cwl_utils/py.typed",
75150
]
76-
include-package-data = true
77151

78-
[tool.setuptools.package-dir]
79-
"cwl_utils.parser" = "cwl_utils/parser"
80-
"cwl_utils.tests" = "tests"
81-
"cwl_utils.testdata" = "testdata"
82-
"cwl_utils.testdata.checker_wf" = "testdata/checker_wf"
83-
"cwl_utils.testdata.extensions" = "testdata/extensions"
84-
"cwl_utils.testdata.types" = "testdata/types"
85-
"cwl_utils.testdata.workflows" = "testdata/workflows"
152+
[tool.hatch.build.targets.wheel.sources]
153+
"tests" = "cwl_utils/tests"
154+
"testdata" = "cwl_utils/testdata"
155+
"testdata/checker_wf" = "cwl_utils/testdata/checker_wf"
156+
"testdata/extensions" = "cwl_utils/testdata/extensions"
157+
"testdata/types" = "cwl_utils/testdata/types"
158+
"testdata/workflows" = "cwl_utils/testdata/workflows"
159+
160+
[tool.hatch.build.targets.wheel.hooks.mypyc]
161+
enable-by-default = false
162+
dependencies = [
163+
"hatch-mypyc>=0.16.0",
164+
"mypy==1.19.0",
165+
]
166+
require-runtime-dependencies = true
167+
exclude = [
168+
"/create_cwl_from_objects.py",
169+
"/load_cwl_by_path.py",
170+
]
86171

87-
[tool.setuptools.package-data]
88-
"cwl_utils" = ["templates/*.json"]
89172

90-
[tool.setuptools.dynamic]
91-
version = {attr = "cwl_utils.__meta__.__version__"}
92-
dependencies = {file = ["requirements.txt"]}
173+
[tool.hatch.envs.test]
174+
features = ["testing"]
93175

94176
[tool.isort]
95177
profile = "black"

release-test.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ else
1919
fi
2020
run_tests="bin/py.test --pyargs ${module}"
2121
pipver=23.1 # minimum required version of pip for Python 3.12
22-
setuptoolsver=67.6.1 # required for Python 3.12
2322
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
2423

2524
rm -Rf testenv? || /bin/true
@@ -31,10 +30,7 @@ then
3130
# First we test the head
3231
# shellcheck source=/dev/null
3332
source testenv1/bin/activate
34-
rm -Rf testenv1/local
35-
rm -f testenv1/lib/python-wheels/setuptools* \
36-
&& pip install --force-reinstall -U pip==${pipver} \
37-
&& pip install setuptools==${setuptoolsver} wheel
33+
pip install --force-reinstall -U pip==${pipver} build
3834
pip install -rtest-requirements.txt ".${extras}"
3935
make test
4036
pip uninstall -y ${package} || true; pip uninstall -y ${package} || true; make install
@@ -57,9 +53,8 @@ rm -Rf testenv[2345]/local
5753
pushd testenv2
5854
# shellcheck source=/dev/null
5955
source bin/activate
60-
rm -f lib/python-wheels/setuptools* \
61-
&& pip install --force-reinstall -U pip==${pipver} \
62-
&& pip install setuptools==${setuptoolsver} wheel
56+
pip install --force-reinstall -U pip==${pipver} \
57+
&& pip install build wheel
6358
# The following can fail if you haven't pushed your commits to ${repo}
6459
pip install -e "git+${repo}@${HEAD}#egg=${package}${extras}"
6560
pushd src/${package}
@@ -80,9 +75,8 @@ popd
8075
pushd testenv3/
8176
# shellcheck source=/dev/null
8277
source bin/activate
83-
rm -f lib/python-wheels/setuptools* \
84-
&& pip install --force-reinstall -U pip==${pipver} \
85-
&& pip install setuptools==${setuptoolsver} wheel
78+
pip install --force-reinstall -U pip==${pipver} \
79+
&& pip install build wheel
8680
package_tar=$(find . -name "${module}*tar.gz")
8781
pip install "-r${DIR}/test-requirements.txt" build
8882
pip install "${package_tar}${extras}"
@@ -103,10 +97,9 @@ popd
10397

10498
pushd testenv4/
10599
# shellcheck source=/dev/null
106-
source bin/activate
107-
rm -f lib/python-wheels/setuptools* \
100+
source bin/activate \
108101
&& pip install --force-reinstall -U pip==${pipver} \
109-
&& pip install setuptools==${setuptoolsver} wheel
102+
&& pip install build wheel
110103
pip install "$(ls ${module}*.whl)${extras}"
111104
pip install "-r${DIR}/test-requirements.txt"
112105
mkdir not-${module}

0 commit comments

Comments
 (0)