Skip to content

Commit 4e09800

Browse files
authored
Pyglet 2.0 migration (#43)
* Modernize CI, update dependencies, and add security policy Replaces Travis CI with GitHub Actions workflows, adds CodeQL analysis, and introduces Dependabot configuration for automated dependency updates. Updates Python support to 3.8+ in setup.py and pyproject.toml, modernizes pre-commit hooks, and expands .gitignore for better cross-platform and tool coverage. Adds SECURITY.md and .python-version, removes .travis.yml, and makes minor docstring and formatting improvements throughout the codebase. * Update build config and linting, fix widget style dict Added build-system section to pyproject.toml for setuptools and wheel. Updated GitHub Actions workflow to install setuptools separately. Modified tox.ini to include setuptools as a dependency. Improved .pylintrc init-hook and disabled too-many-positional-arguments warning. Fixed style dict usage in widgets.py for pyglet text document. * Refactor drawing to use pyglet.shapes and improve macOS support Replaces low-level pyglet.graphics drawing calls with pyglet.shapes primitives for lines, circles, and rectangles in graphics and widgets modules. Adds platform-specific handling for PyObjC dependencies and pyglet options for better compatibility on macOS, including PyPy support. Updates setup.py to install PyObjC only on CPython/macOS, and improves documentation for macOS and PyPy users. * Update type annotations and suppress type warning Changed the return type of TilingGui.on_resize to Literal[True] for more precise typing. Added a type: ignore comment when instantiating TilingGui in main.py to suppress a type checker warning. * Update UI colors and font sizes for improved appearance Increased the top bar height and font sizes in the menu for better readability. Updated text box and background colors in the menu for a lighter appearance. Standardized color usage in tplot by applying scale_to_01 to all color constants. * Increase UI dimensions and improve widget scaling Updated initial window and UI bar sizes for a larger interface. Increased font sizes in menu components for better readability. Improved text and button image positioning and scaling in widgets for more consistent appearance. Fixed a typo in ButtonGrid's rect assignment and adjusted padding. * Exit on PyPy/macOS due to pyglet incompatibility Replace disabling of pyglet's shadow window with an explicit warning and exit when running on PyPy with macOS, as this configuration is not supported. This prevents users from encountering subtle runtime issues. * Cast width and height to float for scaling Explicitly cast button width and height to float when calculating scale factors to ensure correct aspect ratio scaling and avoid integer division issues. * Improve sprite scaling for Button widget Updated the Button widget to handle both AbstractImage and Animation types when scaling sprites. The code now checks for width and height attributes on the image, falling back to sprite dimensions if necessary, ensuring correct scaling for different image types. * Refactor color conversion logic and cleanup dependencies Moved RGB-to-RGBA color conversion into a new Color.scale_to_255 method and updated all usages in graphics.py and widgets.py to use this utility. Removed platform-specific dependencies from setup.py for a simpler install_requires. * Clarify PyPy incompatibility with macOS GUI frameworks Expanded comments to document the fundamental incompatibility between PyPy's ctypes and macOS GUI frameworks, affecting all major Python GUI libraries. Updated runtime check to print a more explicit error and exit if PyPy is detected on macOS, advising users to use CPython or try PyPy on other platforms.
1 parent 6a1718d commit 4e09800

60 files changed

Lines changed: 500 additions & 222 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ indent_size = 4
1212
indent_size = 2
1313

1414
[*.{md,rst}]
15-
trim_trailing_whitespace = false
15+
trim_trailing_whitespace = false

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[flake8]
22
max-line-length = 88
3-
extend-ignore = E203
3+
extend-ignore = E203

.gitattribute

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ LICENSE text eol=lf
1818
.gitignore text eol=lf
1919
.gitattribute text eol=lf
2020
.flake8 text eol=lf
21-
.pylintrc text eol=lf
21+
.pylintrc text eol=lf

.github/dependabot.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Python dependencies
4+
- package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "04:00"
10+
open-pull-requests-limit: 10
11+
reviewers:
12+
- "PermutaTriangle"
13+
assignees:
14+
- "PermutaTriangle"
15+
commit-message:
16+
prefix: "deps"
17+
include: "scope"
18+
19+
# Enable version updates for GitHub Actions
20+
- package-ecosystem: "github-actions"
21+
directory: "/"
22+
schedule:
23+
interval: "weekly"
24+
day: "monday"
25+
time: "04:00"
26+
open-pull-requests-limit: 5
27+
reviewers:
28+
- "PermutaTriangle"
29+
assignees:
30+
- "PermutaTriangle"
31+
commit-message:
32+
prefix: "ci"
33+
include: "scope"

.github/workflows/codeql.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
pull_request:
7+
branches: [ master ]
8+
schedule:
9+
- cron: '30 2 * * 1' # Weekly on Mondays at 02:30 UTC
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ 'python' ]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v3
31+
with:
32+
languages: ${{ matrix.language }}
33+
34+
- name: Autobuild
35+
uses: github/codeql-action/autobuild@v3
36+
37+
- name: Perform CodeQL Analysis
38+
uses: github/codeql-action/analyze@v3
39+
with:
40+
category: "/language:${{matrix.language}}"

.github/workflows/test.yml

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,21 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
include:
12-
- python: 3.8
12+
# Linting and type checking (run on Python 3.11)
13+
- python: "3.11"
1314
toxenv: flake8
1415
os: ubuntu-latest
15-
- python: 3.8
16+
- python: "3.11"
1617
toxenv: mypy
1718
os: ubuntu-latest
18-
- python: 3.8
19+
- python: "3.11"
1920
toxenv: pylint
2021
os: ubuntu-latest
21-
- python: 3.8
22+
- python: "3.11"
2223
toxenv: black
2324
os: ubuntu-latest
2425

25-
- python: 3.7
26-
toxenv: py37
27-
os: ubuntu-latest
26+
# Python version testing (Linux)
2827
- python: 3.8
2928
toxenv: py38
3029
os: ubuntu-latest
@@ -34,28 +33,47 @@ jobs:
3433
- python: "3.10"
3534
toxenv: py310
3635
os: ubuntu-latest
37-
- python: pypy-3.7
38-
toxenv: pypy37
36+
- python: "3.11"
37+
toxenv: py311
38+
os: ubuntu-latest
39+
- python: "3.12"
40+
toxenv: py312
41+
os: ubuntu-latest
42+
- python: "3.13"
43+
toxenv: py313
44+
os: ubuntu-latest
45+
- python: pypy-3.8
46+
toxenv: pypy38
47+
os: ubuntu-latest
48+
- python: pypy-3.9
49+
toxenv: pypy39
50+
os: ubuntu-latest
51+
- python: pypy-3.10
52+
toxenv: pypy310
3953
os: ubuntu-latest
4054

41-
- python: 3.8
42-
toxenv: py38
55+
# Cross-platform testing (Python 3.11)
56+
- python: "3.11"
57+
toxenv: py311
4358
os: macos-latest
44-
- python: 3.8
45-
toxenv: py38
59+
- python: "3.11"
60+
toxenv: py311
4661
os: windows-latest
4762

4863
runs-on: ${{ matrix.os }}
4964
steps:
50-
- uses: actions/checkout@v2
51-
- uses: actions/setup-python@v2
65+
- uses: actions/checkout@v4
66+
- uses: actions/setup-python@v5
5267
with:
53-
python-version: ${{ matrix.python }}
68+
python-version: ${{ matrix.python }}
69+
allow-prereleases: true
5470
- name: install dependencies
55-
run: python -m pip install --upgrade pip tox
71+
run: |
72+
python -m pip install --upgrade pip setuptools
73+
python -m pip install tox
5674
- name: run
5775
env:
5876
TOXENV: ${{ matrix.toxenv }}
5977
run: tox
6078
- name: setup
61-
run: python setup.py install
79+
run: python setup.py install

.gitignore

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ target/
8686
profile_default/
8787
ipython_config.py
8888

89-
# pyenv
90-
.python-version
89+
# pyenv (but we want to track our .python-version file)
90+
# .python-version
9191

9292
# pipenv
9393
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
@@ -142,4 +142,63 @@ dmypy.json
142142
.vscode/
143143

144144
# Program's output
145-
tilingsgui/exports/
145+
tilingsgui/exports/
146+
exports/
147+
148+
# macOS
149+
.DS_Store
150+
.DS_Store?
151+
._*
152+
.Spotlight-V100
153+
.Trashes
154+
ehthumbs.db
155+
Thumbs.db
156+
157+
# Windows
158+
*.stackdump
159+
160+
# Linux
161+
*~
162+
163+
# Temporary/backup files
164+
*.tmp
165+
*.temp
166+
*.bak
167+
*.swp
168+
*.swo
169+
*~
170+
171+
# IDE specific files (additional)
172+
.idea/
173+
*.iml
174+
*.ipr
175+
*.iws
176+
.vscode/settings.json
177+
.vscode/launch.json
178+
.vscode/tasks.json
179+
180+
# Pre-commit
181+
.pre-commit-config.yaml.bak
182+
183+
# Ruff cache (modern Python linter)
184+
.ruff_cache/
185+
186+
# Modern type checkers
187+
.pyright/
188+
189+
# Coverage.py
190+
.coverage.*
191+
coverage.xml
192+
htmlcov/
193+
194+
# Duplicate files (with version numbers or " 2" suffix)
195+
*" 2".*
196+
* 2.*
197+
198+
# Temporary export files
199+
*.json.tmp
200+
tilings_export.json
201+
202+
# Development files that shouldn't be committed
203+
hamstur.py
204+
2025-MODERNIZATION-PLAN.md

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ multi_line_output=3
55
include_trailing_comma=True
66
force_grid_wrap=0
77
use_parentheses=True
8-
line_length=88
8+
line_length=88

.pre-commit-config.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 22.10.0
3+
rev: 24.8.0
44
hooks:
5-
- id: black
5+
- id: black
6+
language_version: python3.11
7+
8+
- repo: https://github.com/pycqa/flake8
9+
rev: 7.1.1
10+
hooks:
11+
- id: flake8
12+
additional_dependencies: [flake8-isort]
13+
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v4.6.0
16+
hooks:
17+
- id: trailing-whitespace
18+
- id: end-of-file-fixer
19+
- id: check-yaml
20+
- id: check-added-large-files
21+
- id: check-merge-conflict

.pylintrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[MASTER]
22

33
ignore-patterns=test_.*?py
4-
init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc())+'/tilingsgui')"
4+
init-hook="import os, sys; sys.path.append(os.path.join(os.path.dirname(__file__), 'tilingsgui'))"
55
max-args=10
66
max-module-lines=1200
7-
disable=too-few-public-methods,too-many-lines
8-
good-names=r,c,x,y,h,w,i,j,k,n,x1,x2,y1,y2,g,b,dx,dy
7+
disable=too-few-public-methods,too-many-lines,too-many-positional-arguments
8+
good-names=r,c,x,y,h,w,i,j,k,n,x1,x2,y1,y2,g,b,dx,dy

0 commit comments

Comments
 (0)