Skip to content

Commit

Permalink
Bump PyInstaller to 6.12, Ruff to 0.9.6, and simplify UV build workar…
Browse files Browse the repository at this point in the history
…ound (#316)
  • Loading branch information
Avasam authored Feb 11, 2025
1 parent 5e21312 commit 0e6a682
Show file tree
Hide file tree
Showing 8 changed files with 696 additions and 651 deletions.
31 changes: 13 additions & 18 deletions .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ on:
branches:
- main
paths:
- "**.py"
- "**.ui"
- ".github/workflows/lint-and-build.yml"
- "**/requirements.txt"
- "src/**"
- "scripts/**"
- "*.toml"
- "uv.lock"
pull_request:
branches:
- main
paths:
- "**.py"
- "**.pyi"
- "**.ui"
- ".github/workflows/lint-and-build.yml"
- "**/requirements*.txt"
- "src/**"
- "scripts/**"
- "*.toml"
- "uv.lock"

env:
GITHUB_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
Expand All @@ -35,7 +36,7 @@ concurrency:
cancel-in-progress: true

jobs:
ruff:
Ruff:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -83,25 +84,19 @@ jobs:
python-version: "3.11"
steps:
- uses: actions/checkout@v4
# region https://github.com/pyinstaller/pyinstaller/issues/9012
- name: Set up uv for Python ${{ matrix.python-version }}
if: ${{ matrix.os == 'windows-latest' }}
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.python-version }}
# https://github.com/pyinstaller/pyinstaller/issues/9012
- name: Set up uv
if: ${{ matrix.os == 'ubuntu-22.04' }}
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ !startsWith(matrix.os, 'ubuntu') && matrix.python-version || null }}
- name: Set up Python for PyInstaller tk issue
if: ${{ matrix.os == 'ubuntu-22.04' }}
if: ${{ startsWith(matrix.os, 'ubuntu') }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# endregion
- run: scripts/install.ps1
shell: pwsh
- run: scripts/build.ps1
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- id: pretty-format-ini
args: [--autofix]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.5 # Must match requirements-dev.txt
rev: v0.9.6 # Must match requirements-dev.txt
hooks:
- id: ruff
args: [--fix]
Expand Down
24 changes: 12 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies = [
"Levenshtein >=0.25",
"PyAutoGUI >=0.9.52",
"PyWinCtl >=0.0.42", # py.typed
"keyboard",
"keyboard", # [see tool.uv.sources]
"numpy >=2.1", # Python 3.13 support
"opencv-python-headless >=4.10", # NumPy 2 support
"packaging >=20.0", # py.typed
Expand All @@ -21,7 +21,7 @@ dependencies = [

#
# Build and compile resources
"pyinstaller >=6.10.0", # Python 3.13 support
"pyinstaller >=6.12.0", # Build fix for built-in _tkinter (splash screen)

#
# https://peps.python.org/pep-0508/#environment-markers
Expand Down Expand Up @@ -51,19 +51,19 @@ dev = [
"qt6-applications >=6.5.0",
#
# Linters & Formatters
"mypy >=1.14",
"mypy[faster-cache] >=1.14",
"pyright[nodejs] >=1.1",
"ruff >=0.8.5",
"ruff >=0.9.6",
#
# Types (pins based on implementation version)
# Types
"scipy-stubs >=1.14.1.1",
"types-PyAutoGUI >=0.9.3",
"types-PyScreeze >=1.0.0; sys_platform == 'linux'",
"types-keyboard >=0.13.2",
"types-psutil >=6.0.0",
"types-pyinstaller >=6.10.0",
"types-python-xlib >=0.33; sys_platform == 'linux'",
"types-pywin32 >=307; sys_platform == 'win32'",
"types-PyAutoGUI",
"types-PyScreeze; sys_platform == 'linux'",
"types-keyboard",
"types-psutil",
"types-pyinstaller",
"types-python-xlib; sys_platform == 'linux'",
"types-pywin32 >=306.0.0.20240130; sys_platform == 'win32'",
]
[tool.uv]
dependency-metadata = [
Expand Down
1 change: 0 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ ignore = [
# Conflict with formatter (you can remove this section if you don't use Ruff as a formatter)
###
"COM812", # missing-trailing-comma
"ISC001", # single-line-implicit-string-concatenation
"RUF028", # invalid-formatter-suppression-comment, Is meant for the formatter, but false-positives

###
Expand Down
17 changes: 8 additions & 9 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
& "$PSScriptRoot/compile_resources.ps1"

$SupportsSplashScreen = [System.Convert]::ToBoolean($(uv run python -c "import _tkinter; print(hasattr(_tkinter, '__file__'))"))

$arguments = @(
"$PSScriptRoot/../src/AutoSplit.py",
'--onefile',
'--windowed',
'--additional-hooks-dir=Pyinstaller/hooks',
'--icon=res/icon.ico',
'--splash=res/splash.png')
'--icon=res/icon.ico')
if ($SupportsSplashScreen) {
# https://github.com/pyinstaller/pyinstaller/issues/9022
$arguments += @('--splash=res/splash.png')
}
if ($IsWindows) {
$arguments += @(
# Hidden import by winrt.windows.graphics.imaging.SoftwareBitmap.create_copy_from_surface_async
'--hidden-import=winrt.windows.foundation')
}
if ($IsLinux) {
$arguments += @(
# Required on the CI for PyWinCtl
'--hidden-import pynput.keyboard._xorg',
'--hidden-import pynput.mouse._xorg')
}

Start-Process -Wait -NoNewWindow uv -ArgumentList $(@("run", "pyinstaller")+$arguments)
Start-Process -Wait -NoNewWindow uv -ArgumentList $(@('run', 'pyinstaller') + $arguments)

If ($IsLinux) {
Move-Item -Force $PSScriptRoot/../dist/AutoSplit $PSScriptRoot/../dist/AutoSplit.elf
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ else {
Write-Host "`nRunning Ruff format ..."
uv run ruff format

$pyrightVersion = $(uv run pyright --version).replace("pyright ", "")
$pyrightVersion = $(uv run pyright --version).replace('pyright ', '')
Write-Host "`nRunning Pyright $pyrightVersion ..."
$Env:PYRIGHT_PYTHON_FORCE_VERSION = $pyrightVersion
uv run pyright src/
Expand Down
8 changes: 4 additions & 4 deletions src/menu_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
)


class __AboutWidget(QtWidgets.QWidget, about.Ui_AboutAutoSplitWidget): # noqa: N801 # Private class
class __AboutWidget(QtWidgets.QWidget, about.Ui_AboutAutoSplitWidget):
"""About Window."""

def __init__(self):
Expand All @@ -65,7 +65,7 @@ def open_about(autosplit: "AutoSplit"):
autosplit.AboutWidget = __AboutWidget()


class __UpdateCheckerWidget(QtWidgets.QWidget, update_checker.Ui_UpdateChecker): # noqa: N801 # Private class
class __UpdateCheckerWidget(QtWidgets.QWidget, update_checker.Ui_UpdateChecker):
def __init__(
self,
latest_version: str,
Expand Down Expand Up @@ -119,7 +119,7 @@ def view_help():
webbrowser.open(f"https://github.com/{GITHUB_REPOSITORY}/blob/main/docs/tutorial.md")


class __CheckForUpdatesThread(QtCore.QThread): # noqa: N801 # Private class
class __CheckForUpdatesThread(QtCore.QThread):
def __init__(self, autosplit: "AutoSplit", *, check_on_open: bool):
super().__init__()
self._autosplit_ref = autosplit
Expand Down Expand Up @@ -159,7 +159,7 @@ def check_for_updates(autosplit: "AutoSplit", *, check_on_open: bool = False):
autosplit.CheckForUpdatesThread.start()


class __SettingsWidget(QtWidgets.QWidget, settings_ui.Ui_SettingsWidget): # noqa: N801 # Private class
class __SettingsWidget(QtWidgets.QWidget, settings_ui.Ui_SettingsWidget):
def __init__(self, autosplit: "AutoSplit"):
super().__init__()
self.__video_capture_devices: list[CameraInfo] = []
Expand Down
Loading

0 comments on commit 0e6a682

Please sign in to comment.