Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.13 #298

Merged
merged 27 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
83e7dab
Bump versions
Avasam Oct 7, 2024
d107efc
Migrate from winsdk to PyWinRT
Avasam Oct 7, 2024
ec5fc62
move hack
Avasam Oct 7, 2024
de78265
-dev
Avasam Oct 7, 2024
aa4b399
Temp disable comtypes code paths for Python 3.13 https://github.com/e…
Avasam Oct 7, 2024
7255662
Running commands w/ Ruff
Avasam Oct 8, 2024
f206024
pillow from github
Avasam Oct 8, 2024
7a43ef6
Merge branch 'dev' into Python-3.13
Avasam Oct 8, 2024
d5c6a7d
Merge branch 'dev' into Python-3.13
Avasam Oct 9, 2024
f66ff52
Bump pillow, use non-dev 3.13
Avasam Oct 15, 2024
bf59638
typed-D3DShot
Avasam Oct 16, 2024
be9acdd
Update scripts/requirements.txt
Avasam Oct 16, 2024
3c0c512
Update comtypes thanks to new pyinstaller-hooks-contrib release
Avasam Oct 16, 2024
aa644a3
comtypes isn't even a direct dependency...
Avasam Oct 16, 2024
1137802
Update scripts/requirements.txt
Avasam Oct 17, 2024
9ada46f
Apply suggestions from code review
Avasam Oct 17, 2024
57f8e8c
Update scripts/install.ps1
Avasam Oct 17, 2024
7eaac33
Bump comtypes
Avasam Oct 20, 2024
6e0bb89
Discard changes to .gitignore
Avasam Oct 20, 2024
2799922
Discard changes to pyproject.toml
Avasam Oct 20, 2024
52050c7
Discard changes to src/utils.py
Avasam Oct 20, 2024
f375c0b
Discard changes to src/capture_method/__init__.py
Avasam Oct 20, 2024
f0f787a
Merge branch 'dev' into Python-3.13
Avasam Oct 20, 2024
8eac7c0
Update scripts/requirements.txt
Avasam Oct 21, 2024
d7d7a99
Update some comments
Avasam Oct 21, 2024
ecda468
Merge branch 'Python-3.13' of https://github.com/Toufool/AutoSplit in…
Avasam Oct 21, 2024
5882529
Bump PySide6-Essentials to 6.8.0.2
Avasam Oct 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
# Ruff is version and platform sensible
matrix:
os: [windows-latest, ubuntu-22.04]
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v4
Expand All @@ -66,7 +66,7 @@ jobs:
# Pyright is version and platform sensible
matrix:
os: [windows-latest, ubuntu-22.04]
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v4
Expand Down Expand Up @@ -99,7 +99,10 @@ jobs:
# Only the Python version we plan on shipping matters.
matrix:
os: [windows-latest, ubuntu-22.04]
python-version: ["3.11", "3.12"]
python-version: ["3.12", "3.13"]
include:
- os: ubuntu-22.04
python-version: "3.11" # I had some Qt Wayland issues on 3.12 for ubuntu-22.04 iirc. TODO: test it
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env/
build/
dist/
*.prof
*.lock
# Generated
**/gen/*.py
!**/gen/*.pyi
Expand Down
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"configurations": [
{
"name": "Python: AutoSplit (debug non-user code)",
"type": "python",
"type": "debugpy",
"request": "launch",
"preLaunchTask": "Compile resources",
"program": "src/AutoSplit.py",
Expand All @@ -15,7 +15,7 @@
},
{
"name": "Python: AutoSplit",
"type": "python",
"type": "debugpy",
"request": "launch",
"preLaunchTask": "Compile resources",
"program": "src/AutoSplit.py",
Expand All @@ -24,7 +24,7 @@
},
{
"name": "Python: AutoSplit --auto-controlled",
"type": "python",
"type": "debugpy",
"request": "launch",
"preLaunchTask": "Compile resources",
"program": "src/AutoSplit.py",
Expand Down
1 change: 1 addition & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
; We don't run mypy in the CI. This is just to help anyone who would like to use it manually.
; Namely, the mypy_primer tool.
[mypy]
python_version = 3.11
show_column_numbers = true
mypy_path = $MYPY_CONFIG_FILE_DIR/typings
implicit_reexport = true
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[project]
name = "AutoSplit"
dynamic = ["version"]

# https://github.com/microsoft/pyright/blob/main/docs/configuration.md#sample-pyprojecttoml-file
[tool.pyright]
typeCheckingMode = "strict"
Expand Down
8 changes: 7 additions & 1 deletion scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ If ($IsLinux) {
&"$python" -m pip install wheel pip setuptools --upgrade
# Upgrading QT to 6.6.2 w/o first uninstalling shiboken6 can lead to issues
# https://bugreports.qt.io/browse/PYSIDE-2616?focusedId=777285&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-777285
&"$python" -m pip uninstall shiboken6 -y
# Updating from D3DShot to typed-D3DShot w/o uninstalling can cause issues (keep until version bump on PyPI)
&"$python" -m pip uninstall shiboken6 d3dshot types-D3DShot -y
&"$python" -m pip install -r "$PSScriptRoot/requirements$dev.txt" --upgrade
# Temporary hack to test install for Python 3.13
&"$python" -m pip install `
PySide6-Essentials>=6.8.0.1 ; python_version >= '3.13'" `
shiboken6>=6.8.0.1 ; python_version >= '3.13'" `
Avasam marked this conversation as resolved.
Show resolved Hide resolved
--ignore-requires-python
# These libraries install extra requirements we don't want
# Open suggestion for support in requirements files: https://github.com/pypa/pip/issues/9948 & https://github.com/pypa/pip/pull/10837
# PyAutoGUI: We only use it for hotkeys
Expand Down
19 changes: 9 additions & 10 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,27 @@
# Dependencies:
git+https://github.com/boppreh/keyboard.git#egg=keyboard # Fix install on macos and linux-ci https://github.com/boppreh/keyboard/pull/568
Levenshtein>=0.25
# Some modules used by OpenCV are not compiled for Numpy 2 yet on Linux. Error happens on import at runtime
numpy>=1.26,<2.0 # Python 3.12 support
opencv-python-headless>=4.9.0.80 # Typing fixes
numpy>=2.1 # Python 3.13 support
opencv-python-headless>=4.10 # NumPy 2 support
packaging
psutil>=5.9.6 # Python 3.12 fixes
psutil>=6.0.0 # Python 3.13 support
# PyAutoGUI # See install.ps1
PyWinCtl>=0.0.42 # py.typed
# When needed, dev builds can be found at https://download.qt.io/snapshots/ci/pyside/dev?C=M;O=D
PySide6-Essentials>=6.6.0 # Python 3.12 support
scipy>=1.11.2 # Python 3.12 support
PySide6-Essentials>=6.8.0.1 ; python_version <= '3.12' # Python 3.13 support
scipy>=1.14.1 # Python 3.13 support
tomli-w>=1.1.0 # Typing fixes
typing-extensions>=4.4.0 # @override decorator support
#
# Build and compile resources
pyinstaller>=5.13 # Python 3.12 support
pyinstaller>=6.10.0 # Python 3.13 support
#
# https://peps.python.org/pep-0508/#environment-markers
#
# Windows-only dependencies:
comtypes<1.4.5 ; sys_platform == 'win32' # https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/807
typed-D3DShot[numpy] >= 1.0.1; sys_platform == 'win32'
pygrabber>=0.2 ; sys_platform == 'win32' # Completed types
pywin32>=301 ; sys_platform == 'win32'
pywin32>=307 ; sys_platform == 'win32' # Python 3.13 support
winrt-Windows.AI.MachineLearning>=2.2.0 ; sys_platform == 'win32' # Python 3.13 support
winrt-Windows.Foundation>=2.2.0 ; sys_platform == 'win32' # Python 3.13 support
winrt-Windows.Graphics.Capture>=2.2.0 ; sys_platform == 'win32' # Python 3.13 support
Expand All @@ -40,5 +39,5 @@ typed-D3DShot[numpy]>=1.0.1 ; sys_platform == 'win32'
#
# Linux-only dependencies
PyScreeze ; sys_platform == 'linux'
pillow ; sys_platform == 'linux' # Necessary for PyScreeze. For unknown reasons it's not pulled in on CI
pillow>=11.0 ; sys_platform == 'linux' # Python 3.13 support # Necessary for PyScreeze. For unknown reasons it's not pulled in on CI
python-xlib ; sys_platform == 'linux'
15 changes: 10 additions & 5 deletions src/capture_method/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
if sys.platform == "win32":
from _ctypes import COMError # noqa: PLC2701 # comtypes is untyped

from pygrabber.dshow_graph import FilterGraph

from capture_method.BitBltCaptureMethod import BitBltCaptureMethod
from capture_method.DesktopDuplicationCaptureMethod import DesktopDuplicationCaptureMethod
from capture_method.ForceFullContentRenderingCaptureMethod import (
ForceFullContentRenderingCaptureMethod,
)
from capture_method.WindowsGraphicsCaptureMethod import WindowsGraphicsCaptureMethod

if sys.version_info < (3, 13):
# https://github.com/enthought/comtypes/issues/618
from capture_method.DesktopDuplicationCaptureMethod import DesktopDuplicationCaptureMethod

if sys.platform == "linux":
import pyscreeze
from PIL import UnidentifiedImageError, features
Expand Down Expand Up @@ -137,7 +138,8 @@ def get(self, key: CaptureMethodEnum, default: object = None, /):
import d3dshot

d3dshot.create(capture_output="numpy")
except (ModuleNotFoundError, COMError):
except (ModuleNotFoundError, COMError, NameError):
# NameError: https://github.com/enthought/comtypes/issues/618
pass
else:
CAPTURE_METHODS[CaptureMethodEnum.DESKTOP_DUPLICATION] = DesktopDuplicationCaptureMethod
Expand Down Expand Up @@ -182,7 +184,10 @@ class CameraInfo:


def get_input_devices():
if sys.platform == "win32":
if sys.platform == "win32" and sys.version_info < (3, 13):
# https://github.com/enthought/comtypes/issues/618
from pygrabber.dshow_graph import FilterGraph # noqa: PLC0415

return FilterGraph().get_input_devices()

cameras: list[str] = []
Expand Down
7 changes: 5 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import win32gui
import win32ui
from pygrabber.dshow_graph import FilterGraph
from winrt.windows.ai.machinelearning import LearningModelDevice, LearningModelDeviceKind
from winrt.windows.media.capture import MediaCapture

Expand Down Expand Up @@ -159,8 +158,12 @@ def get_window_bounds(hwnd: int) -> tuple[int, int, int, int]:
# Note: maybe reorganize capture_method module to have
# different helper modules and a methods submodule
def get_input_device_resolution(index: int) -> tuple[int, int] | None:
if sys.platform != "win32":
if sys.platform != "win32" or sys.version_info >= (3, 13):
return (0, 0)

# https://github.com/enthought/comtypes/issues/618
from pygrabber.dshow_graph import FilterGraph # noqa: PLC0415

filter_graph = FilterGraph()
try:
filter_graph.add_video_input_device(index)
Expand Down
Loading