Skip to content

Commit babe52b

Browse files
committed
Merge branch 'main' of https://github.com/Toufool/AutoSplit
2 parents e8a032c + bfea018 commit babe52b

14 files changed

+3771
-204
lines changed

Diff for: .github/workflows/lint-and-build.yml

+26-29
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,10 @@ jobs:
3838
ruff:
3939
runs-on: ubuntu-22.04
4040
steps:
41-
- name: Checkout ${{ github.repository }}/${{ github.ref }}
42-
uses: actions/checkout@v4
43-
- name: Get Ruff version
44-
id: ruff_version
45-
run: |
46-
$Env:RUFF_VERSION=Select-String -path scripts/requirements-dev.txt -pattern 'ruff ?([=<>~]?= ?[\d\.]+)' | %{ $_.Matches[0].Groups[1].Value }
47-
echo $Env:RUFF_VERSION
48-
echo "RUFF_VERSION=$Env:RUFF_VERSION" >> $Env:GITHUB_OUTPUT
49-
shell: pwsh
41+
- uses: actions/checkout@v4
5042
- uses: astral-sh/ruff-action@v3
5143
with:
52-
version: ${{ steps.ruff_version.outputs.RUFF_VERSION }}
44+
version-file: "pyproject.toml"
5345
- run: ruff format --check
5446
Pyright:
5547
runs-on: ${{ matrix.os }}
@@ -60,27 +52,20 @@ jobs:
6052
os: [windows-latest, ubuntu-22.04]
6153
python-version: ["3.11", "3.12", "3.13"]
6254
steps:
63-
- name: Checkout ${{ github.repository }}/${{ github.ref }}
64-
uses: actions/checkout@v4
65-
- name: Set up Python ${{ matrix.python-version }}
66-
uses: actions/setup-python@v5
55+
- uses: actions/checkout@v4
56+
- name: Set up uv for Python ${{ matrix.python-version }}
57+
uses: astral-sh/setup-uv@v5
6758
with:
59+
enable-cache: true
60+
cache-dependency-glob: "uv.lock"
6861
python-version: ${{ matrix.python-version }}
69-
cache: "pip"
70-
cache-dependency-path: "scripts/requirements*.txt"
7162
- run: scripts/install.ps1
7263
shell: pwsh
73-
- name: Get pyright version
74-
id: pyright_version
75-
run: |
76-
PYRIGHT_VERSION=$(grep '$pyrightVersion = ' 'scripts/lint.ps1' | cut -d "#" -f 1 | cut -d = -f 2 | tr -d " '")
77-
echo pyright version: "${PYRIGHT_VERSION}"
78-
echo PYRIGHT_VERSION="${PYRIGHT_VERSION}" >> "${GITHUB_OUTPUT}"
79-
shell: bash
64+
- run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
8065
- name: Analysing the code with Pyright
8166
uses: jakebailey/pyright-action@v2
8267
with:
83-
version: ${{ steps.pyright_version.outputs.PYRIGHT_VERSION }}
68+
version: PATH
8469
working-directory: src/
8570
python-version: ${{ matrix.python-version }}
8671
Build:
@@ -98,14 +83,26 @@ jobs:
9883
- os: ubuntu-22.04
9984
python-version: "3.12"
10085
steps:
101-
- name: Checkout ${{ github.repository }}/${{ github.ref }}
102-
uses: actions/checkout@v4
103-
- name: Set up Python ${{ matrix.python-version }}
86+
- uses: actions/checkout@v4
87+
- name: Set up uv for Python ${{ matrix.python-version }}
88+
if: ${{ matrix.os == 'windows-latest' }}
89+
uses: astral-sh/setup-uv@v5
90+
with:
91+
enable-cache: true
92+
cache-dependency-glob: "uv.lock"
93+
python-version: ${{ matrix.python-version }}
94+
# https://github.com/pyinstaller/pyinstaller/issues/9012
95+
- name: Set up uv for Python ${{ matrix.python-version }}
96+
if: ${{ matrix.os == 'ubuntu-22.04' }}
97+
uses: astral-sh/setup-uv@v5
98+
with:
99+
enable-cache: true
100+
cache-dependency-glob: "uv.lock"
101+
- name: Set up Python for PyInstaller tk issue
102+
if: ${{ matrix.os == 'ubuntu-22.04' }}
104103
uses: actions/setup-python@v5
105104
with:
106105
python-version: ${{ matrix.python-version }}
107-
cache: "pip"
108-
cache-dependency-path: "scripts/requirements.txt"
109106
- run: scripts/install.ps1
110107
shell: pwsh
111108
- run: scripts/build.ps1

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ Not a developer? You can still help through the following methods:
9999
- <https://bugreports.qt.io/browse/QTBUG-114635>
100100
- <https://bugreports.qt.io/browse/PYSIDE-2541>
101101
- <https://bugreports.qt.io/browse/PYSIDE-2542>
102-
- <https://github.com/pypa/pip/issues/9948>
103-
- <https://github.com/pypa/pip/pull/10837>
102+
- <https://github.com/pyinstaller/pyinstaller/issues/9012>
103+
- <https://github.com/astral-sh/uv/issues/1495>
104104
- <https://github.com/opencv/opencv/issues?q=is%3Aissue+is%3Aopen+involves%3AAvasam+sort%3Areactions-%2B1-asc+>
105105
- <https://github.com/opencv/opencv/issues/18305>
106106
- <https://github.com/opencv/opencv/issues/23906>

Diff for: docs/build instructions.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@
1111
- You need to be part of the `input` and `tty` groups, as well as have permissions on a few files and folders.
1212
If you are missing from either groups, the install script will take care of it on its first run, but you'll need to restart your session.
1313

14+
### WSL
15+
16+
If using WSL to test on Windows, you might need to tell uv to point to a different environment than `.venv`. You can point to your system environment by running:
17+
18+
```shell
19+
export UV_PROJECT_ENVIRONMENT=$(python3 -c "import sysconfig; print(sysconfig.get_config_var('prefix'))")
20+
```
21+
22+
Read more: <https://docs.astral.sh/uv/concepts/projects/config/#project-environment-path>
23+
1424
### All platforms
1525

16-
- [Python](https://www.python.org/downloads/) 3.11+.
17-
- [Node](https://nodejs.org) is optional, but required for complete linting.
18-
- Alternatively you can install the [pyright python wrapper](https://pypi.org/project/pyright/) which has a bit of an overhead delay.
26+
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
1927
- [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell) is used to run all the scripts.
2028
- This is needed even for Windows, as the bundled PowerShell 5.1 is too old.
2129
- [VSCode](https://code.visualstudio.com/Download) is not required, but highly recommended.
@@ -24,15 +32,7 @@
2432

2533
## Install and Build steps
2634

27-
- Create and activate a virtual environment:
28-
- Windows / PowerShell:
29-
- `python -m venv .venv`
30-
- `& ./.venv/Scripts/Activate.ps1`
31-
- Unix / Bash:
32-
- `python3 -m venv .venv`
33-
- `source .venv/bin/activate`
34-
- Run `./scripts/install.ps1` to install all dependencies.
35-
- If you're having issues with the PySide generated code, you might want to first run `pip uninstall -y shiboken6 PySide6 PySide6-Essentials`
35+
- Run `./scripts/install.ps1` to create/update a virtual environment and install all dependencies.
3636
- Run the app directly with `./scripts/start.ps1 [--auto-controlled]`.
3737
- Or debug by pressing `F5` in VSCode.
3838
- The `--auto-controlled` flag is passed when AutoSplit is started by LiveSplit.

Diff for: pyproject.toml

+77
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
1+
[project]
2+
name = "AutoSplit"
3+
dynamic = ["version"]
4+
requires-python = " >=3.11"
5+
dependencies = [
6+
# Dependencies:
7+
"Levenshtein >=0.25",
8+
"PyAutoGUI >=0.9.52",
9+
"PyWinCtl >=0.0.42", # py.typed
10+
"keyboard",
11+
"numpy >=2.1", # Python 3.13 support
12+
"opencv-python-headless >=4.10", # NumPy 2 support
13+
"packaging >=20.0", # py.typed
14+
"psutil >=6.0.0", # Python 3.13 support
15+
# When needed, dev builds can be found at https://download.qt.io/snapshots/ci/pyside/dev?C=M;O=D
16+
"PySide6-Essentials <6.8.1", # Has typing issue with QMessageBox.warning https://bugreports.qt.io/browse/PYSIDE-2939
17+
# "PySide6-Essentials >=6.8.2", # Fixed typing issue with QMessageBox.warning
18+
"scipy >=1.14.1", # Python 3.13 support
19+
"tomli-w >=1.1.0", # Typing fixes
20+
"typing-extensions >=4.4.0", # @override decorator support
21+
22+
#
23+
# Build and compile resources
24+
"pyinstaller >=6.10.0", # Python 3.13 support
25+
26+
#
27+
# https://peps.python.org/pep-0508/#environment-markers
28+
#
29+
# Windows-only dependencies:
30+
"pygrabber >=0.2; sys_platform == 'win32'", # Completed types
31+
"pywin32 >=307; sys_platform == 'win32'", # Python 3.13 support
32+
"typed-D3DShot[numpy] >=1.0.1; sys_platform == 'win32'",
33+
"winrt-Windows.Foundation >=2.2.0; sys_platform == 'win32'", # Python 3.13 support
34+
"winrt-Windows.Graphics >=2.2.0; sys_platform == 'win32'", # Python 3.13 support
35+
"winrt-Windows.Graphics.Capture >=2.3.0; sys_platform == 'win32'", # Python 3.13 support
36+
"winrt-Windows.Graphics.Capture.Interop >=2.3.0; sys_platform == 'win32'", # Python 3.13 support
37+
"winrt-Windows.Graphics.DirectX >=2.3.0; sys_platform == 'win32'", # Python 3.13 support
38+
"winrt-Windows.Graphics.DirectX.Direct3D11 >=2.3.0; sys_platform == 'win32'", # Python 3.13 support
39+
"winrt-Windows.Graphics.DirectX.Direct3D11.Interop >=2.3.0; sys_platform == 'win32'",
40+
"winrt-Windows.Graphics.Imaging >=2.3.0; sys_platform == 'win32'", # Python 3.13 support
41+
#
42+
# Linux-only dependencies
43+
"PyScreeze >=1.0.0; sys_platform == 'linux'",
44+
"pillow >=11.0; sys_platform == 'linux'", # Python 3.13 support # Necessary for PyScreeze/ImageGrab.
45+
"python-xlib >=0.33; sys_platform == 'linux'",
46+
]
47+
[dependency-groups]
48+
dev = [
49+
#
50+
# Visual Designer
51+
"qt6-applications >=6.5.0",
52+
#
53+
# Linters & Formatters
54+
"mypy >=1.14",
55+
"pyright[nodejs] >=1.1",
56+
"ruff >=0.8.5",
57+
#
58+
# Types (pins based on implementation version)
59+
"scipy-stubs >=1.14.1.1",
60+
"types-PyAutoGUI >=0.9.3",
61+
"types-PyScreeze >=1.0.0; sys_platform == 'linux'",
62+
"types-keyboard >=0.13.2",
63+
"types-psutil >=6.0.0",
64+
"types-pyinstaller >=6.10.0",
65+
"types-python-xlib >=0.33; sys_platform == 'linux'",
66+
"types-pywin32 >=307; sys_platform == 'win32'",
67+
]
68+
[tool.uv]
69+
dependency-metadata = [
70+
# PyAutoGUI installs extra libraries we don't want. We only use it for hotkeys
71+
# PyScreeze -> pyscreenshot -> mss deps calls SetProcessDpiAwareness on Windows
72+
{ name = "PyAutoGUI", requires-dist = [] },
73+
{ name = "types-PyAutoGUI", requires-dist = [] },
74+
]
75+
[tool.uv.sources]
76+
keyboard = { git = "https://github.com/boppreh/keyboard.git" } # Fix install on macos and linux-ci https://github.com/boppreh/keyboard/pull/568
77+
178
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md#sample-pyprojecttoml-file
279
[tool.pyright]
380
typeCheckingMode = "strict"

Diff for: scripts/build.ps1

+3-19
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,9 @@ $arguments = @(
66
'--windowed',
77
'--additional-hooks-dir=Pyinstaller/hooks',
88
'--icon=res/icon.ico',
9-
'--splash=res/splash.png',
10-
'--exclude=pkg_resources',
11-
'--exclude=setuptools',
12-
# The install script should ensure that these are not installed
13-
# But we'll still include unused dependencies that would be picked up by PyInstaller
14-
# if requirements.txt was used directly to help ensure consistency when building locally.
15-
#
16-
# Installed by PyAutoGUI
17-
'--exclude=pygetwindow',
18-
'--exclude=pymsgbox',
19-
'--exclude=pytweening',
20-
'--exclude=mouseinfo')
9+
'--splash=res/splash.png')
2110
if ($IsWindows) {
22-
# These are used on Linux
2311
$arguments += @(
24-
# Installed by PyAutoGUI
25-
'--exclude=pyscreeze',
26-
# Sometimes installed by other automation/image libraries.
27-
# Keep this exclusion even if nothing currently installs it, to stay future-proof.
28-
'--exclude=PIL',
2912
# Hidden import by winrt.windows.graphics.imaging.SoftwareBitmap.create_copy_from_surface_async
3013
'--hidden-import=winrt.windows.foundation')
3114
}
@@ -35,7 +18,8 @@ if ($IsLinux) {
3518
'--hidden-import pynput.keyboard._xorg',
3619
'--hidden-import pynput.mouse._xorg')
3720
}
38-
Start-Process -Wait -NoNewWindow pyinstaller -ArgumentList $arguments
21+
22+
Start-Process -Wait -NoNewWindow uv -ArgumentList $(@("run", "pyinstaller")+$arguments)
3923

4024
If ($IsLinux) {
4125
Move-Item -Force $PSScriptRoot/../dist/AutoSplit $PSScriptRoot/../dist/AutoSplit.elf

Diff for: scripts/compile_resources.ps1

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Set-Location "$PSScriptRoot/.."
33

44
New-Item ./src/gen -ItemType directory -Force | Out-Null
55
New-Item ./src/gen/__init__.py -ItemType File -Force | Out-Null
6-
pyside6-uic './res/about.ui' -o './src/gen/about.py'
7-
pyside6-uic './res/design.ui' -o './src/gen/design.py'
8-
pyside6-uic './res/settings.ui' -o './src/gen/settings.py'
9-
pyside6-uic './res/update_checker.ui' -o './src/gen/update_checker.py'
10-
pyside6-rcc './res/resources.qrc' -o './src/gen/resources_rc.py'
6+
uv run pyside6-uic './res/about.ui' -o './src/gen/about.py'
7+
uv run pyside6-uic './res/design.ui' -o './src/gen/design.py'
8+
uv run pyside6-uic './res/settings.ui' -o './src/gen/settings.py'
9+
uv run pyside6-uic './res/update_checker.ui' -o './src/gen/update_checker.py'
10+
uv run pyside6-rcc './res/resources.qrc' -o './src/gen/resources_rc.py'
1111
$files = Get-ChildItem ./src/gen/ *.py
1212
foreach ($file in $files) {
1313
(Get-Content $file.PSPath) |

Diff for: scripts/designer.ps1

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
$python = $IsWindows ? 'python' : 'python3'
2-
$qt6_applications_import = 'import qt6_applications; print(qt6_applications.__path__[0])'
1+
$qt6_applications_path = uv run python -c 'import qt6_applications; print(qt6_applications.__path__[0])'
32

4-
$qt6_applications_path = &"$python" -c $qt6_applications_import
5-
if ($null -eq $qt6_applications_path) {
6-
Write-Host 'Designer not found, installing qt6_applications'
7-
&"$python" -m pip install qt6_applications
8-
}
9-
10-
$qt6_applications_path = &"$python" -c $qt6_applications_import
113
& "$qt6_applications_path/Qt/bin/designer" `
124
"$PSScriptRoot/../res/design.ui" `
135
"$PSScriptRoot/../res/about.ui" `

Diff for: scripts/install.ps1

+6-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
$python = $IsWindows ? 'python' : 'python3'
2-
31
# Validating user groups on Linux
42
If ($IsLinux) {
53
$groups = groups
@@ -30,34 +28,20 @@ If ($IsLinux) {
3028
}
3129

3230
# Installing Python dependencies
33-
$dev = If ($Env:GITHUB_JOB -eq 'Build') { '' } Else { '-dev' }
3431
If ($IsLinux) {
3532
If (-not $Env:GITHUB_JOB -or $Env:GITHUB_JOB -eq 'Build') {
3633
sudo apt-get update
3734
# python3-tk for splash screen, libxcb-cursor-dev for QT_QPA_PLATFORM=xcb, the rest for PySide6
38-
sudo apt-get install -y python3-pip python3-tk libxcb-cursor-dev libegl1 libxkbcommon0
39-
# having issues with npm for pyright, maybe let users take care of it themselves? (pyright from pip)
35+
sudo apt-get install -y python3-tk libxcb-cursor-dev libegl1 libxkbcommon0
4036
}
4137
}
42-
# Ensures installation tools are up to date. This also aliases pip to pip3 on MacOS.
43-
&"$python" -m pip install wheel pip setuptools --upgrade
44-
# Upgrading QT to 6.6.2 w/o first uninstalling shiboken6 can lead to issues
45-
# https://bugreports.qt.io/browse/PYSIDE-2616?focusedId=777285&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-777285
46-
&"$python" -m pip uninstall shiboken6 -y
47-
&"$python" -m pip install -r "$PSScriptRoot/requirements$dev.txt" --upgrade
48-
# These libraries install extra requirements we don't want
49-
# Open suggestion for support in requirements files: https://github.com/pypa/pip/issues/9948 & https://github.com/pypa/pip/pull/10837
50-
# PyAutoGUI: We only use it for hotkeys
51-
&"$python" -m pip install PyAutoGUI --no-deps --upgrade
5238

53-
# Uninstall optional dependencies if PyAutoGUI was installed outside this script
54-
# PyScreeze -> pyscreenshot -> mss deps call SetProcessDpiAwareness, used to be installed on Windows
55-
# pygetwindow, pymsgbox, pytweening, MouseInfo are picked up by PyInstaller
56-
# (also --exclude from build script, but more consistent with unfrozen run)
57-
&"$python" -m pip uninstall pyscreenshot mss pygetwindow pymsgbox pytweening MouseInfo -y
58-
If ($IsWindows) { &"$python" -m pip uninstall PyScreeze -y }
39+
$prod = If ($Env:GITHUB_JOB -eq 'Build') { '--no-dev' } Else { }
40+
$lock = If ($Env:GITHUB_JOB) { '--locked' } Else { '--upgrade' }
41+
Write-Output "Installing Python dependencies with: uv sync $prod $lock"
42+
uv sync $prod $lock
5943

6044
# Don't compile resources on the Build CI job as it'll do so in build script
61-
If ($dev) {
45+
If (-not $prod) {
6246
& "$PSScriptRoot/compile_resources.ps1"
6347
}

Diff for: scripts/lint.ps1

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Set-Location "$PSScriptRoot/.."
33
$exitCodes = 0
44

55
Write-Host "`nRunning Ruff check ..."
6-
ruff check --fix
6+
uv run ruff check --fix
77
$exitCodes += $LastExitCode
88
if ($LastExitCode -gt 0) {
99
Write-Host "`Ruff failed ($LastExitCode)" -ForegroundColor Red
@@ -13,18 +13,15 @@ else {
1313
}
1414

1515
Write-Host "`nRunning Ruff format ..."
16-
ruff format
16+
uv run ruff format
1717

18-
$pyrightVersion = 'latest' # Change this if latest has issues
18+
$pyrightVersion = $(uv run pyright --version).replace("pyright ", "")
1919
Write-Host "`nRunning Pyright $pyrightVersion ..."
2020
$Env:PYRIGHT_PYTHON_FORCE_VERSION = $pyrightVersion
21-
npx -y pyright@$pyrightVersion src/
21+
uv run pyright src/
2222
$exitCodes += $LastExitCode
2323
if ($LastExitCode -gt 0) {
2424
Write-Host "`Pyright failed ($LastExitCode)" -ForegroundColor Red
25-
if ($pyrightVersion -eq 'latest') {
26-
npx pyright@latest --version
27-
}
2825
}
2926
else {
3027
Write-Host "`Pyright passed" -ForegroundColor Green

Diff for: scripts/python_build_from_source_linux.bash

-28
This file was deleted.

0 commit comments

Comments
 (0)