-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
executable file
·181 lines (161 loc) · 5.77 KB
/
pyproject.toml
File metadata and controls
executable file
·181 lines (161 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "detectorist"
dynamic = ["version"]
description = "A desktop application for sorting and cropping photos using a machine learning for object detection."
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
# onnxruntime dropped macOS x86_64 wheels in v1.24.0, so pin to the last supported version for Intel Macs
"onnxruntime>=1.24 ; sys_platform != 'darwin' or platform_machine != 'x86_64'",
"onnxruntime<=1.23.2 ; sys_platform == 'darwin' and platform_machine == 'x86_64'",
"opencv-python",
"pillow-heif",
"pyside6",
# rawpy dropped macOS x86_64 wheels in v0.26.0, so pin to the last supported version for Intel Macs
"rawpy>=0.26 ; sys_platform != 'darwin' or platform_machine != 'x86_64'",
"rawpy<=0.25.1 ; sys_platform == 'darwin' and platform_machine == 'x86_64'",
"numpy",
"piexif",
]
[dependency-groups]
dev = [
"ruff",
"nuitka",
"imageio",
"poethepoet",
"md-toc",
]
[project.scripts]
detectorist = "detectorist.main:main"
[tool.setuptools]
package-dir = {"" = "src"}
packages = ["detectorist"]
[tool.setuptools.dynamic]
version = {attr = "detectorist._version.__version__"}
[tool.poe.tasks]
compile-ui = { shell = "for f in src/detectorist/*.ui; do base=\"${f%.ui}\"; out=\"${base%/*}/ui_${base##*/}.py\"; pyside6-uic --from-imports \"$f\" -o \"$out\"; done", help = "Compile Qt UI files to Python files with relative imports" }
# --format-version 1 omits per-file timestamps for reproducible output as setting SOURCE_DATE_EPOCH=0 does not work (Qt treats 0 as "not set" see QTBUG-62511).
compile-qrc = { shell = "for f in src/detectorist/*.qrc; do pyside6-rcc --format-version 1 \"$f\" -o \"${f%.qrc}_rc.py\"; done", help = "Compile Qt resource files to Python files" }
run-app = { cmd = "uv run src/detectorist/main.py", help = "Run the application" }
run = { sequence = ["compile-ui", "compile-qrc", "run-app"], help = "Compile UI and resource files and run the application" }
get_app_version = { shell = "python -c 'from detectorist._version import __version__; print(__version__.strip())'", help = "Get the application version" }
clean-dist = { shell = "rm -rf ./dist/*", help = "Clean the dist directory" }
ruff = { cmd = "uv run ruff check", help = "Run ruff linter" }
[tool.poe.tasks.build]
help = "Build for the current platform"
shell = """
case "$(uname -s)" in
Darwin) poe build-mac ;;
Linux) poe build-linux ;;
MINGW*|MSYS*|CYGWIN*) poe build-windows ;;
*) echo "Unsupported OS: $(uname -s)"; exit 1 ;;
esac
"""
[tool.poe.tasks.build-linux]
shell = """
ARCH=$(uname -m)
OUTPUT_DIR=dist/linux-$ARCH
rm -rf "$OUTPUT_DIR"
nuitka \
--standalone \
--onefile \
--enable-plugin=pyside6 \
--noinclude-qt-translations \
--noinclude-dlls='*.cpp.o' \
--noinclude-dlls='*.qsb' \
--include-qt-plugins=platforminputcontexts \
--disable-ccache \
--output-dir="$OUTPUT_DIR" \
--linux-icon=assets/icon.png \
--remove-output \
--output-filename=Detectorist-$(poe get_app_version)-linux-$ARCH \
./src/detectorist/main.py
"""
deps = ["compile-ui", "compile-qrc"]
help = "Build the application for Linux"
[tool.poe.tasks.build-mac]
shell = """
ARCH=$(uname -m)
VERSION=$(poe get_app_version)
OUTPUT_DIR=dist/macos-$ARCH
rm -rf "$OUTPUT_DIR"
nuitka \
--standalone \
--macos-create-app-bundle \
--macos-app-icon=assets/icon.png \
--enable-plugin=pyside6 \
--noinclude-qt-translations \
--noinclude-dlls='*.cpp.o' \
--noinclude-dlls='*.qsb' \
--include-qt-plugins=platforminputcontexts \
--disable-ccache \
--output-dir="$OUTPUT_DIR" \
--remove-output \
--product-name=Detectorist \
--macos-app-name=Detectorist \
--macos-app-version=$VERSION \
--macos-signed-app-name=de.ken.detectorist \
--output-filename=Detectorist-$VERSION-macos-$ARCH \
./src/detectorist/main.py
mv "$OUTPUT_DIR/main.app" \
"$OUTPUT_DIR/Detectorist-$VERSION-macos-$ARCH.app"
"""
deps = ["compile-ui", "compile-qrc"]
help = "Build the application for macOS"
[tool.poe.tasks.build-windows]
shell = """
ARCH=$(uname -m)
VERSION=$(poe get_app_version)
OUTPUT_DIR=dist/windows-$ARCH
rm -rf "$OUTPUT_DIR"
nuitka.cmd \
--standalone \
--onefile \
--onefile-tempdir-spec={PROGRAM_DIR}/.runtime/{PID}_{TIME} \
--enable-plugin=pyside6 \
--windows-icon-from-ico=assets/icon.ico \
--onefile-windows-splash-screen-image=assets/splash.png \
--noinclude-qt-translations \
--noinclude-dlls='*.cpp.o' \
--noinclude-dlls='*.qsb' \
--include-qt-plugins=platforminputcontexts \
--disable-ccache \
--output-dir="$OUTPUT_DIR" \
--remove-output \
--windows-product-name=Detectorist \
--windows-product-version=$VERSION \
--windows-file-version=$VERSION \
--windows-console-mode=attach \
--output-filename=Detectorist-$VERSION-windows-$ARCH \
--assume-yes-for-downloads \
--msvc=latest \
./src/detectorist/main.py
"""
deps = ["compile-ui", "compile-qrc"]
help = "Build the application for Windows"
[tool.vscode.tasks]
compile-ui = "poe compile-ui"
compile-qrc = "poe compile-qrc"
run = "poe run-app"
build-and-run = "poe run"
[tool.ruff]
# Exclude files generated from .ui and .qrc sources
extend-exclude = ["src/detectorist/ui_*.py", "src/detectorist/*_rc.py"]
[tool.ruff.lint]
# Never enforce `E501` (line length violations).
ignore = ["E501"]
# Select specific error codes to enforce
select = [
"F", # Pyflakes (basic Python errors)
"E", # pycodestyle errors
"W", # pycodestyle warnings
"I", # Import sorting
"C4", # Flake8 Comprehensions
"B", # Flake8 Bugbear (security and design checks)
"UP", # Pyupgrade (modernize Python code)
]
[tool.pytest.ini_options]
pythonpath = ["src"]