Skip to content

Commit 54a84f3

Browse files
committed
migrate to uv and update deps
1 parent efce9a7 commit 54a84f3

File tree

10 files changed

+228
-150
lines changed

10 files changed

+228
-150
lines changed

.github/workflows/test-lint.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- '3.10'
2121
- '3.11'
2222
- '3.12'
23+
- '3.13'
2324

2425
steps:
2526
- name: Checkout code
@@ -30,16 +31,16 @@ jobs:
3031
with:
3132
python-version: ${{ matrix.python-version }}
3233

33-
- name: Install Poetry
34+
- name: Install UV
3435
run: |
35-
curl -sSL https://install.python-poetry.org | python3 -
36+
curl -LsSf https://astral.sh/uv/install.sh | sh
3637
3738
- name: Install dependencies
38-
run: poetry install
39+
run: uv sync
3940

4041
- name: Run pytest
41-
run: poetry run pytest
42+
run: uv run pytest
4243

4344
- name: Run ruff
44-
run: poetry run ruff check --output-format=github
45+
run: uv run ruff check --output-format=github
4546
continue-on-error: true

.gitignore

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
!test
2-
README.rst
3-
requirements_optional.txt
4-
tmp
2+
uv.lock
53
profile.*
64

7-
# DepHell stuff
8-
poetry.lock
9-
105
# Byte-compiled / optimized / DLL files
116
__pycache__/
127
*.py[cod]

.pre-commit-config.yaml

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,46 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.3.3
3+
rev: v0.9.6
44
hooks:
55
- id: ruff
66
args: [ --fix ]
77
- id: ruff-format
88

99
- repo: https://github.com/RobertCraigie/pyright-python
10-
rev: v1.1.354
10+
rev: v1.1.394
1111
hooks:
1212
- id: pyright
1313

14-
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
15-
rev: v1.3.3
14+
- repo: local
1615
hooks:
17-
- id: python-safety-dependencies-check
18-
files: pyproject.toml
16+
- id: generate requirements
17+
name: generate requirements
18+
entry: uv export --no-hashes --no-dev -o requirements.txt
19+
language: system
20+
pass_filenames: false
21+
- id: safety
22+
name: safety
23+
entry: uv run safety
24+
language: system
25+
pass_filenames: false
26+
- id: make docs
27+
name: make docs
28+
entry: uv run handsdown --cleanup -o documentation/reference
29+
language: system
30+
pass_filenames: false
31+
- id: build package
32+
name: build package
33+
entry: uv build
34+
language: system
35+
pass_filenames: false
36+
- id: pytest
37+
name: pytest
38+
entry: uv run pytest
39+
language: system
40+
pass_filenames: false
1941

2042
- repo: https://github.com/pre-commit/pre-commit-hooks
21-
rev: v4.5.0
43+
rev: v5.0.0
2244
hooks:
2345
- id: trailing-whitespace
2446
- id: end-of-file-fixer
@@ -35,7 +57,7 @@ repos:
3557
- id: mixed-line-ending
3658

3759
- repo: https://github.com/boidolr/pre-commit-images
38-
rev: v1.5.2
60+
rev: v1.8.4
3961
hooks:
4062
- id: optimize-jpg
4163
- id: optimize-png

documentation/reference/layeredimage/layeredimage.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def addLayerOrGroup(self, layerOrGroup: Layer | Group) -> None: ...
7676

7777
### LayeredImage().extractGroups
7878

79-
[Show source in layeredimage.py:126](../../../layeredimage/layeredimage.py#L126)
79+
[Show source in layeredimage.py:127](../../../layeredimage/layeredimage.py#L127)
8080

8181
Extract the groups from the image.
8282

@@ -168,7 +168,7 @@ def removeLayerOrGroup(self, index: int) -> None: ...
168168

169169
### LayeredImage().updateGroups
170170

171-
[Show source in layeredimage.py:134](../../../layeredimage/layeredimage.py#L134)
171+
[Show source in layeredimage.py:135](../../../layeredimage/layeredimage.py#L135)
172172

173173
Update the groups from the image.
174174

@@ -180,7 +180,7 @@ def updateGroups(self) -> None: ...
180180

181181
### LayeredImage().updateLayers
182182

183-
[Show source in layeredimage.py:122](../../../layeredimage/layeredimage.py#L122)
183+
[Show source in layeredimage.py:123](../../../layeredimage/layeredimage.py#L123)
184184

185185
Update the layers from the image.
186186

@@ -194,7 +194,7 @@ def updateLayers(self) -> None: ...
194194

195195
## render
196196

197-
[Show source in layeredimage.py:139](../../../layeredimage/layeredimage.py#L139)
197+
[Show source in layeredimage.py:140](../../../layeredimage/layeredimage.py#L140)
198198

199199
Flatten a layer or group on to an image of what has already been flattened.
200200

layeredimage/io/layered.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def grabLayer_LAYERED(
8383
zipFile: ZipFile, layer: dict[str, Any], blendLookup: dict[str, Any]
8484
) -> Layer:
8585
"""Grab an image from .layered."""
86-
with zipFile.open(f'data/{layer["name"]}.png') as layerImage:
86+
with zipFile.open(f"data/{layer['name']}.png") as layerImage:
8787
image = Image.open(layerImage).convert("RGBA")
8888
return Layer(
8989
name=layer["name"],

layeredimage/layeredimage.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ def extractLayers(self) -> list[Layer]:
9999
if isinstance(layerOrGroup, Layer):
100100
layers.append(layerOrGroup)
101101
else:
102-
for layer in layerOrGroup.layers:
103-
# Render the layer
104-
layers.append(
102+
layers.extend(
103+
[
105104
Layer(
106105
name=layer.name,
107106
image=layer.image,
@@ -116,7 +115,9 @@ def extractLayers(self) -> list[Layer]:
116115
opacity=layerOrGroup.opacity * layer.opacity,
117116
visible=layerOrGroup.visible and layer.visible,
118117
)
119-
)
118+
for layer in layerOrGroup.layers
119+
]
120+
)
120121
return layers
121122

122123
def updateLayers(self) -> None:
@@ -150,6 +151,9 @@ def render(layerOrGroup: Layer | Group, project_image: np.ndarray) -> np.ndarray
150151
np.ndarray: Flattened image
151152
152153
"""
154+
if not layerOrGroup.visible:
155+
return project_image
156+
153157
if isinstance(layerOrGroup, Layer):
154158
return blendLayersArray(
155159
project_image,

pyproject.toml

+43-40
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
[tool.poetry]
1+
[project]
22
name = "layeredimage"
3-
version = "2024.3"
4-
license = "mit"
3+
version = "2025"
54
description = "Use this module to read, and write to a number of layered image formats"
6-
authors = ["FredHappyface"]
5+
authors = [{ name = "FredHappyface" }]
6+
requires-python = ">=3.9,<4.0"
7+
readme = "README.md"
8+
license = "mit"
79
classifiers = [
8-
"Environment :: Console",
9-
"Development Status :: 5 - Production/Stable",
10-
"Intended Audience :: Developers",
11-
"Intended Audience :: Education",
12-
"Natural Language :: English",
13-
"Operating System :: OS Independent",
14-
"Programming Language :: Python :: Implementation :: CPython",
15-
"Topic :: Multimedia :: Graphics",
16-
"Topic :: Software Development :: Libraries :: Python Modules",
17-
"Topic :: Utilities",
10+
"Environment :: Console",
11+
"Development Status :: 5 - Production/Stable",
12+
"Intended Audience :: Developers",
13+
"Intended Audience :: Education",
14+
"Natural Language :: English",
15+
"Operating System :: OS Independent",
16+
"Programming Language :: Python :: Implementation :: CPython",
17+
"Topic :: Multimedia :: Graphics",
18+
"Topic :: Software Development :: Libraries :: Python Modules",
19+
"Topic :: Utilities",
20+
]
21+
dependencies = [
22+
"blendmodes>=2025",
23+
"gimpformats>=2025",
24+
"loguru>=0.7.3",
25+
"pillow>=10.4.0",
26+
"psd-tools>=1.10.6",
27+
"pylsr>=2024",
28+
"pyora>=0.3.11",
29+
"pypdn>=1.0.6",
1830
]
19-
homepage = "https://github.com/FHPythonUtils/LayeredImage"
20-
repository = "https://github.com/FHPythonUtils/LayeredImage"
21-
documentation = "https://github.com/FHPythonUtils/LayeredImage/blob/master/README.md"
22-
readme = "README.md"
23-
24-
[tool.poetry.dependencies]
25-
python = ">=3.9,<4.0"
26-
blendmodes = "<2026,>=2024.1.1"
27-
pylsr = "<2026,>=2024"
28-
pyora = "<2,>=0.3.11"
29-
pypdn = "<2,>=1.0.6"
30-
psd-tools = "<2,>=1.9.31"
31-
pillow = "<11,>=10.2.0"
32-
gimpformats = "<2026,>=2024"
33-
loguru = "<2,>=0.7.2"
3431

35-
[tool.poetry.group.dev.dependencies]
36-
imgcompare = "^2.0.1"
37-
pytest = "^8.1.1"
38-
handsdown = "^2.1.0"
39-
coverage = "^7.4.4"
40-
ruff = "^0.3.3"
41-
pyright = "^1.1.354"
32+
[project.urls]
33+
Homepage = "https://github.com/FHPythonUtils/LayeredImage"
34+
Repository = "https://github.com/FHPythonUtils/LayeredImage"
35+
Documentation = "https://github.com/FHPythonUtils/LayeredImage/blob/master/README.md"
4236

43-
[build-system]
44-
requires = ["poetry-core"]
45-
build-backend = "poetry.core.masonry.api"
37+
[dependency-groups]
38+
dev = [
39+
"coverage>=7.6.12",
40+
"handsdown>=2.1.0",
41+
"imgcompare>=2.0.1",
42+
"pyright>=1.1.394",
43+
"pytest>=8.3.4",
44+
"ruff>=0.9.7",
45+
]
4646

4747
[tool.ruff]
4848
line-length = 100
@@ -52,7 +52,6 @@ target-version = "py38"
5252
[tool.ruff.lint]
5353
select = ["ALL"]
5454
ignore = [
55-
"ANN101", # type annotation for self in method
5655
"COM812", # enforce trailing comma
5756
"D2", # pydocstyle formatting
5857
"ISC001",
@@ -96,3 +95,7 @@ deps =
9695
pytest
9796
commands = pytest tests
9897
"""
98+
99+
[build-system]
100+
requires = ["hatchling"]
101+
build-backend = "hatchling.build"

requirements.txt

+34-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
1-
blendmodes<2026,>=2024.1.1
2-
gimpformats<2026,>=2024
3-
loguru<2,>=0.7.2
4-
pillow<11,>=10.2.0
5-
psd-tools<2,>=1.9.31
6-
pylsr<2026,>=2024
7-
pyora<2,>=0.3.11
8-
pypdn<2,>=1.0.6
1+
# This file was autogenerated by uv via the following command:
2+
# uv export --no-hashes --no-dev -o requirements.txt
3+
-e .
4+
aenum==3.1.15
5+
aggdraw==1.3.19
6+
attrs==25.1.0
7+
blendmodes==2025
8+
brackettree==0.2.5
9+
colorama==0.4.6 ; sys_platform == 'win32'
10+
defusedxml==0.7.1
11+
deprecation==2.1.0
12+
docopt==0.6.2
13+
gimpformats==2025
14+
imageio==2.37.0
15+
lazy-loader==0.4
16+
loguru==0.7.3
17+
networkx==3.2.1 ; python_full_version < '3.10'
18+
networkx==3.4.2 ; python_full_version >= '3.10'
19+
numpy==2.0.2 ; python_full_version < '3.10'
20+
numpy==2.2.3 ; python_full_version >= '3.10'
21+
packaging==24.2
22+
pillow==10.4.0
23+
psd-tools==1.10.6
24+
pylsr==2024
25+
pyora==0.3.11
26+
pypdn==1.0.6
27+
scikit-image==0.24.0 ; python_full_version < '3.10'
28+
scikit-image==0.25.2 ; python_full_version >= '3.10'
29+
scipy==1.13.1 ; python_full_version < '3.10'
30+
scipy==1.15.2 ; python_full_version >= '3.10'
31+
tifffile==2024.8.30 ; python_full_version < '3.10'
32+
tifffile==2025.2.18 ; python_full_version >= '3.10'
33+
typing-extensions==4.12.2 ; python_full_version < '3.11'
34+
win32-setctime==1.2.0 ; sys_platform == 'win32'

0 commit comments

Comments
 (0)