Skip to content

Commit 735e803

Browse files
committed
[ci] Modernize build system with uv and hatch
Also fix all issues flagged by Ruff.
1 parent 571c14d commit 735e803

File tree

5 files changed

+41
-17
lines changed

5 files changed

+41
-17
lines changed

.ruff.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ target-version = "py38"
22

33
line-length = 150
44

5-
select = ["ALL"]
5+
lint.select = ["ALL"]
66

7-
ignore = [
7+
lint.ignore = [
88

99
# ignore complete rule packages [common]
1010

Makefile

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
lint:
2-
ruff check --show-source imsize/[^a]*.py
2+
ruff check imsize/[^a]*.py
33

44
download:
55
ifeq (,$(wildcard ./test/images/*.DNG))
@@ -14,17 +14,19 @@ test: download
1414
make lint
1515

1616
install:
17-
pip3 install --user build
18-
rm -rf build dist || true
19-
pip3 uninstall --yes imsize || true
20-
ping -c 3 www.google.com # pyproject-build requires internet access
21-
pyproject-build || true
22-
pip3 install --user dist/*.whl || true
23-
rm -rf build imsize.egg-info || true
17+
hatch build # pip install hatch
18+
uv pip uninstall --quiet imsize
19+
uv pip install dist/*.whl || true
20+
unzip -v dist/*.whl
2421
@python3 -c 'import imsize; print(f"Installed imsize version {imsize.__version__}.")'
2522

23+
qinstall: # quick & quiet install; wheel only
24+
@hatch build -t wheel
25+
@uv pip uninstall --quiet imsize
26+
@uv pip install --quiet dist/*.whl || true
27+
2628
release:
27-
pip3 install --user twine
29+
uv pip install twine
2830
make install
2931
twine upload dist/*
3032

imsize/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
from .imsize import ImageFileError
1818
from .version import __version__
1919

20-
__all__ = ["read", "ImageInfo", "FILETYPES", "ImageFileError", "__version__"]
20+
__all__ = ["FILETYPES", "ImageFileError", "ImageInfo", "__version__", "read"]

imsize/imsize.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def _read_insp(filespec):
381381

382382
def _rot90_steps(exif_orientation):
383383
exif_to_rot90 = {1: 0, 2: 0, 3: 2, 4: 0, 5: 1, 6: 3, 7: 3, 8: 1}
384-
rot90_ccw_steps = exif_to_rot90.get(exif_orientation, None)
384+
rot90_ccw_steps = exif_to_rot90.get(exif_orientation)
385385
return rot90_ccw_steps
386386

387387

pyproject.toml

+26-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
15
[project]
26
name = "imsize"
3-
version = "1.7.0"
47
description="Lightning-fast extraction of basic image metadata"
5-
authors = [{name = "Tomi Aarnio", email = "[email protected]"}]
8+
authors = [
9+
{name = "Tomi Aarnio", email = "[email protected]"}
10+
]
611
readme = "README.md"
7-
requires-python = ">= 3.8"
8-
license = {file = "LICENSE"}
12+
requires-python = ">= 3.10"
13+
dynamic = ["version"]
914
classifiers = [
1015
"Programming Language :: Python :: 3",
1116
"License :: OSI Approved :: MIT License",
@@ -18,8 +23,25 @@ dependencies = [
1823
"rawpy >= 0.19.0"
1924
]
2025

26+
[tool.hatch.envs.default]
27+
installer = "uv"
28+
2129
[project.urls]
2230
Homepage = "http://github.com/toaarnio/imsize"
2331

2432
[project.scripts]
2533
imsize = "imsize.consoleapp:main"
34+
35+
[tool.hatch.version]
36+
path = "imsize/version.py"
37+
38+
[tool.hatch.build]
39+
include = ["imsize"]
40+
exclude = ["*test*"]
41+
42+
[tool.hatch.metadata]
43+
allow-direct-references = true
44+
45+
[tool.pytest.ini_options]
46+
pythonpath = ["."]
47+
addopts = "--tb=short"

0 commit comments

Comments
 (0)