Skip to content

Commit 02ed8d8

Browse files
authored
Setup improvements from updating environments (#329)
1 parent 9f42c30 commit 02ed8d8

File tree

7 files changed

+36
-412
lines changed

7 files changed

+36
-412
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.png eol=auto
55
*.gif eol=auto
66
*.ico eol=auto
7+
*.whl eol=auto
78
# Set linguist-language to support comments syntax highlight
89
pyrightconfig*.json linguist-language=jsonc
910
.vscode/*.json linguist-language=jsonc

.github/workflows/lint-and-build.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ on:
3030
env:
3131
GITHUB_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
3232
GITHUB_EXCLUDE_BUILD_NUMBER: ${{ inputs.excludeBuildNumber }}
33+
UV_NO_SYNC: true # Avoid accidentally pulling in dependency-groups with uv run
3334

3435
concurrency:
3536
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -47,14 +48,13 @@ jobs:
4748
steps:
4849
- uses: actions/checkout@v4
4950
- name: Set up uv for Python ${{ matrix.python-version }}
50-
uses: astral-sh/setup-uv@v5
51+
uses: astral-sh/setup-uv@v6
5152
with:
5253
enable-cache: true
53-
cache-dependency-glob: "uv.lock"
5454
python-version: ${{ matrix.python-version }}
55+
activate-environment: true
5556
- run: scripts/install.ps1
5657
shell: pwsh
57-
- run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
5858
- name: Analysing the code with Pyright
5959
uses: jakebailey/pyright-action@v2
6060
with:
@@ -66,12 +66,8 @@ jobs:
6666
runs-on: ubuntu-latest
6767
steps:
6868
- uses: actions/checkout@v4
69-
- name: Set up uv
70-
uses: astral-sh/setup-uv@v5
71-
with:
72-
enable-cache: true
73-
cache-dependency-glob: "uv.lock"
74-
- run: uvx --with uvloop uv-secure
69+
- uses: astral-sh/setup-uv@v6
70+
- run: uvx uv-secure[faster-async]
7571

7672
Build:
7773
runs-on: ${{ matrix.os }}
@@ -84,17 +80,17 @@ jobs:
8480
steps:
8581
- uses: actions/checkout@v4
8682
# region https://github.com/pyinstaller/pyinstaller/issues/9012
87-
- name: Set up uv for Python ${{ matrix.python-version }}
88-
uses: astral-sh/setup-uv@v5
89-
with:
90-
enable-cache: true
91-
cache-dependency-glob: "uv.lock"
92-
python-version: ${{ !startsWith(matrix.os, 'ubuntu') && matrix.python-version || null }}
9383
- name: Set up Python for PyInstaller tk issue
9484
if: ${{ startsWith(matrix.os, 'ubuntu') }}
9585
uses: actions/setup-python@v5
9686
with:
87+
allow-prereleases: true
9788
python-version: ${{ matrix.python-version }}
89+
- name: Set up uv for Python ${{ matrix.python-version }}
90+
uses: astral-sh/setup-uv@v6
91+
with:
92+
enable-cache: true
93+
python-version: ${{ !startsWith(matrix.os, 'ubuntu') && matrix.python-version || null }}
9894
# endregion
9995
- run: scripts/install.ps1
10096
shell: pwsh

.vscode/extensions.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
// GitHub
1818
"bierner.github-markdown-preview",
1919
"github.vscode-github-actions",
20-
// Dotenv
21-
"dotenv.dotenv-vscode",
2220
// Python/TOML
2321
"charliermarsh.ruff",
2422
"ms-python.mypy-type-checker",

docs/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#### Comparison Method
3535

36-
- There are three comparison methods to choose from: L2 Norm, Histograms, and Perceptual Hash (or pHash).
36+
- There are three comparison methods to choose from: L2 Norm, Histograms, and Perceptual Hash (aka pHash).
3737
- L2 Norm: This method should be fine to use for most cases. It finds the difference between each pixel, squares it, sums it over the entire image and takes the square root. This is very fast but is a problem if your image is high frequency. Any translational movement or rotation can cause similarity to be very different.
3838
- Histograms: An explanation on Histograms comparison can be found [here](https://mpatacchiola.github.io/blog/2016/11/12/the-simplest-classifier-histogram-intersection.html). This is a great method to use if you are using several masked images.
3939
> This algorithm is particular reliable when the colour is a strong predictor of the object identity. The histogram intersection [...] is robust to occluding objects in the foreground.

pyproject.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies = [
77
"Levenshtein >=0.25",
88
"PyAutoGUI >=0.9.52",
99
"PyWinCtl >=0.0.42", # py.typed
10-
"keyboard", # [see tool.uv.sources]
10+
"keyboard @ git+https://github.com/boppreh/keyboard.git", # Fix install on macos and linux-ci https://github.com/boppreh/keyboard/pull/568
1111
"numpy >=2.1", # Python 3.13 support
1212
"opencv-python-headless >=4.10", # NumPy 2 support
1313
"packaging >=20.0", # py.typed
@@ -19,10 +19,10 @@ dependencies = [
1919

2020
#
2121
# Build and compile resources
22-
"pyinstaller >=6.12.0", # Build fix for built-in _tkinter (splash screen)
22+
"pyinstaller >=6.14.0", # Mitigate issues with pkg_resources deprecation warning
2323

2424
#
25-
# https://peps.python.org/pep-0508/#environment-markers
25+
# https://packaging.python.org/en/latest/specifications/dependency-specifiers/#environment-markers
2626
#
2727
# Windows-only dependencies:
2828
"pygrabber >=0.2; sys_platform == 'win32'", # Completed types
@@ -39,7 +39,6 @@ dependencies = [
3939
#
4040
# Linux-only dependencies
4141
"PyScreeze >=1.0.0; sys_platform == 'linux'",
42-
"dprint-py>=0.50.0.0",
4342
"pillow >=11.0; sys_platform == 'linux'", # Python 3.13 support # Necessary for PyScreeze/ImageGrab.
4443
"python-xlib >=0.33; sys_platform == 'linux'",
4544
]
@@ -50,12 +49,10 @@ dev = [
5049
"qt6-applications >=6.5.0",
5150
#
5251
# Linters & Formatters
52+
"dprint-py>=0.50.0.0",
5353
"mypy[faster-cache] >=1.16",
5454
"pyright[nodejs] >=1.1.400", # reportPrivateImportUsage behaviour change
5555
"ruff >=0.11.13",
56-
"uv-secure",
57-
"uvloop; sys_platform != 'win32'",
58-
"winloop; sys_platform == 'win32'",
5956
#
6057
# Types
6158
"scipy-stubs >=1.14.1.1",
@@ -78,8 +75,6 @@ dependency-metadata = [
7875
{ name = "PyAutoGUI", requires-dist = [] },
7976
{ name = "types-PyAutoGUI", requires-dist = [] },
8077
]
81-
[tool.uv.sources]
82-
keyboard = { git = "https://github.com/boppreh/keyboard.git" } # Fix install on macos and linux-ci https://github.com/boppreh/keyboard/pull/568
8378

8479
[tool.uv-secure.maintainability_criteria]
8580
forbid_yanked = true

src/compare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def compare_phash(source: MatLike, capture: MatLike, mask: MatLike | None = None
125125
# Apply the mask to the source and capture before calculating the
126126
# pHash for each of the images. As a result of this, this function
127127
# is not going to be very helpful for large masks as the images
128-
# when shrinked down to 8x8 will mostly be the same.
128+
# when shrunk down to 8x8 will mostly be the same.
129129
if is_valid_image(mask):
130130
source = cv2.bitwise_and(source, source, mask=mask)
131131
capture = cv2.bitwise_and(capture, capture, mask=mask)

0 commit comments

Comments
 (0)