Skip to content

Commit d9b0adb

Browse files
authored
Build Linux on Python 3.12 and update QT version + various fixes (#287)
1 parent cfb1ad5 commit d9b0adb

File tree

6 files changed

+26
-36
lines changed

6 files changed

+26
-36
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ jobs:
4747
matrix:
4848
os: [windows-latest, ubuntu-22.04]
4949
python-version: ["3.10", "3.11", "3.12"]
50-
# Wayland issue on Ubuntu 22.04 https://bugreports.qt.io/browse/QTBUG-114635
51-
exclude:
52-
- os: ubuntu-22.04
53-
python-version: "3.12"
5450
steps:
5551
- name: Checkout ${{ github.repository }}/${{ github.ref }}
5652
uses: actions/checkout@v4
@@ -71,10 +67,6 @@ jobs:
7167
matrix:
7268
os: [windows-latest, ubuntu-22.04]
7369
python-version: ["3.10", "3.11", "3.12"]
74-
# Wayland issue on Ubuntu 22.04 https://bugreports.qt.io/browse/QTBUG-114635
75-
exclude:
76-
- os: ubuntu-22.04
77-
python-version: "3.12"
7870
steps:
7971
- name: Checkout ${{ github.repository }}/${{ github.ref }}
8072
uses: actions/checkout@v4
@@ -100,10 +92,6 @@ jobs:
10092
matrix:
10193
os: [windows-latest, ubuntu-22.04]
10294
python-version: ["3.11", "3.12"]
103-
# Wayland issue on Ubuntu 22.04 https://bugreports.qt.io/browse/QTBUG-114635
104-
exclude:
105-
- os: ubuntu-22.04
106-
python-version: "3.12"
10795
steps:
10896
- name: Checkout ${{ github.repository }}/${{ github.ref }}
10997
uses: actions/checkout@v4

scripts/install.ps1

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ $dev = If ($Env:GITHUB_JOB -eq 'Build') { '' } Else { '-dev' }
3434
If ($IsLinux) {
3535
If (-not $Env:GITHUB_JOB -or $Env:GITHUB_JOB -eq 'Build') {
3636
sudo apt-get update
37-
# python3-tk for splash screen, npm for pyright, the rest for PySide6
38-
sudo apt-get install -y python3-pip python3-tk npm libegl1 libxkbcommon0
37+
# python3-tk for splash screen the rest for PySide6
38+
sudo apt-get install -y python3-pip python3-tk libegl1 libxkbcommon0
39+
# having issues with npm for pyright, maybe let users take care of it themselves? (pyright from pip)
3940
}
4041
}
4142
# Ensures installation tools are up to date. This also aliases pip to pip3 on MacOS.
@@ -51,22 +52,6 @@ If ($IsLinux) {
5152
# Even then, PyPI with Pillow>=7.2.0 will install 0.1.3 instead of 0.1.5
5253
&"$python" -m pip install PyAutoGUI "D3DShot>=0.1.5 ; sys_platform == 'win32'" --no-deps --upgrade
5354

54-
# Patch libraries so we don't have to install from git
55-
56-
If ($IsWindows) {
57-
# Prevent PyAutoGUI and pywinctl from setting Process DPI Awareness, which Qt tries to do then throws warnings about it.
58-
# The unittest workaround significantly increases build time, boot time and build size with PyInstaller.
59-
# https://github.com/asweigart/pyautogui/issues/663#issuecomment-1296719464
60-
$libPath = &"$python" -c 'import pyautogui as _; print(_.__path__[0])'
61-
(Get-Content "$libPath/_pyautogui_win.py").replace('ctypes.windll.user32.SetProcessDPIAware()', 'pass') |
62-
Set-Content "$libPath/_pyautogui_win.py"
63-
$libPath = &"$python" -c 'import pymonctl as _; print(_.__path__[0])'
64-
(Get-Content "$libPath/_pymonctl_win.py").replace('ctypes.windll.shcore.SetProcessDpiAwareness(2)', 'pass') |
65-
Set-Content "$libPath/_pymonctl_win.py"
66-
$libPath = &"$python" -c 'import pywinbox as _; print(_.__path__[0])'
67-
(Get-Content "$libPath/_pywinbox_win.py").replace('ctypes.windll.shcore.SetProcessDpiAwareness(2)', 'pass') |
68-
Set-Content "$libPath/_pywinbox_win.py"
69-
}
7055
# Because Ubuntu 22.04 is forced to use an older version of PySide6, we do a dirty typing patch
7156
# https://bugreports.qt.io/browse/QTBUG-114635
7257
If ($IsLinux) {

scripts/requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
# Dependencies:
66
git+https://github.com/boppreh/keyboard.git#egg=keyboard # Fix install on macos and linux-ci https://github.com/boppreh/keyboard/pull/568
77
Levenshtein>=0.25
8-
numpy>=1.26 # Python 3.12 support
8+
# Some modules used by OpenCV are not compiled for Numpy 2 yet on Linux. Error happens on import at runtime
9+
numpy>=1.26,<2.0 # Python 3.12 support
910
opencv-python-headless>=4.9.0.80 # Typing fixes
1011
packaging
1112
psutil>=5.9.6 # Python 3.12 fixes
1213
# PyAutoGUI # See install.ps1
1314
PyWinCtl>=0.0.42 # py.typed
1415
# When needed, dev builds can be found at https://download.qt.io/snapshots/ci/pyside/dev?C=M;O=D
15-
PySide6-Essentials>=6.6.0 ; sys_platform == 'win32' # Python 3.12 support
16-
PySide6-Essentials<6.5.1 ; sys_platform == 'linux' # Wayland issue on Ubuntu 22.04 https://bugreports.qt.io/browse/QTBUG-114635
16+
PySide6-Essentials>=6.6.0 # Python 3.12 support
1717
scipy>=1.11.2 # Python 3.12 support
1818
toml
1919
typing-extensions>=4.4.0 # @override decorator support
@@ -31,4 +31,5 @@ winsdk>=1.0.0b10 ; sys_platform == 'win32' # Python 3.12 support
3131
#
3232
# Linux-only dependencies
3333
PyScreeze ; sys_platform == 'linux'
34+
pillow ; sys_platform == 'linux' # Necessary for PyScreeze. For unknown reasons it's not pulled in on CI
3435
python-xlib ; sys_platform == 'linux'

src/AutoSplit.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
#!/usr/bin/python3
2+
3+
import sys
4+
5+
# Prevent PyAutoGUI and pywinctl from setting Process DPI Awareness, which Qt tries to do then throws warnings about it.
6+
# The unittest workaround significantly increases build time, boot time and build size with PyInstaller.
7+
# https://github.com/asweigart/pyautogui/issues/663#issuecomment-1296719464
8+
# QT doesn't call those from Python/ctypes, meaning we can stop other programs from setting it.
9+
if sys.platform == "win32":
10+
import ctypes
11+
# pyautogui._pyautogui_win.py
12+
ctypes.windll.user32.SetProcessDPIAware = lambda: None # pyright: ignore[reportAttributeAccessIssue]
13+
# pymonctl._pymonctl_win.py
14+
# pywinbox._pywinbox_win.py
15+
ctypes.windll.shcore.SetProcessDpiAwareness = ( # pyright: ignore[reportAttributeAccessIssue]
16+
lambda _: None # pyright: ignore[reportUnknownLambdaType]
17+
)
18+
219
import os
320
import signal
4-
import sys
521
from collections.abc import Callable
622
from copy import deepcopy
723
from time import time

src/menu_bar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def __setup_bindings(self):
292292
set_hotkey_hotkey_button: QtWidgets.QPushButton = getattr(self, f"set_{hotkey}_hotkey_button")
293293
hotkey_input.setText(self._autosplit_ref.settings_dict.get(f"{hotkey}_hotkey", ""))
294294

295-
set_hotkey_hotkey_button.clicked.connect(partial(set_hotkey, hotkey=hotkey))
295+
set_hotkey_hotkey_button.clicked.connect(partial(set_hotkey, self._autosplit_ref, hotkey=hotkey))
296296
# Make it very clear that hotkeys are not used when auto-controlled
297297
if self._autosplit_ref.is_auto_controlled and hotkey != "toggle_auto_reset_image":
298298
set_hotkey_hotkey_button.setEnabled(False)

src/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class SubprocessKWArgs(TypedDict):
8585
stdin: int
8686
stdout: int
8787
stderr: int
88-
startupinfo: STARTUPINFO | None
88+
startupinfo: "STARTUPINFO | None"
8989
env: os._Environ[str] | None # pyright: ignore[reportPrivateUsage]
9090

9191

0 commit comments

Comments
 (0)