Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into Surface-Attributes
  • Loading branch information
oddbookworm committed May 20, 2024
2 parents efa35d8 + fdcbd7a commit cf91362
Show file tree
Hide file tree
Showing 153 changed files with 1,204 additions and 125,404 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- run:
name: Build the Linux wheels.
command: |
pip3 install --user cibuildwheel==2.16.4
pip3 install --user cibuildwheel==2.17.0
PATH="$HOME/.local/bin:$PATH" cibuildwheel --output-dir wheelhouse
- store_artifacts:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-debian-multiarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ env:
INSTALL_CMD: |
apt-get update --fix-missing
apt-get upgrade -y
apt-get install build-essential meson -y
apt-get install build-essential meson cython3 -y
apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev -y
apt-get install libfreetype6-dev libportmidi-dev fontconfig -y
apt-get install python3-dev python3-pip python3-wheel python3-sphinx -y
Expand All @@ -65,7 +65,7 @@ jobs:
- { arch: armv7, base_image: 'balenalib/raspberrypi3-debian:bookworm' }

steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- name: Build sources and run tests
uses: uraimo/run-on-arch-action@v2.7.2
Expand Down
27 changes: 3 additions & 24 deletions .github/workflows/build-emsdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,12 @@ jobs:
SDK_ARCHIVE: python3.11-wasm-sdk-Ubuntu-22.04.tar.lz4
SDKROOT: /opt/python-wasm-sdk

# use the most recent cython from github, but pin on a commit for CI
# stability. This is also needed to benefit from caching cython installs
LATEST_CYTHON_COMMIT: 2f3a781dcca092ce95fbfef2736b12b0d1ab50dd # cython 3.0.0

WHEELHOUSE_CYTHON: /tmp/wheelhouse/cython

steps:
- uses: actions/checkout@v4.1.3

- name: Cache Cython
id: cache-cython
uses: actions/cache@v4.0.2
with:
path: ${{ env.WHEELHOUSE_CYTHON }}
key: wasm-ubuntu-cython-${{ env.LATEST_CYTHON_COMMIT }}-path-${{ env.WHEELHOUSE_CYTHON }}

# This builds the cython wheel and stores it in cache too
- name: Download and build cython on cache miss
if: steps.cache-cython.outputs.cache-hit != 'true'
run: |
mkdir -p $WHEELHOUSE_CYTHON
pip wheel --wheel-dir $WHEELHOUSE_CYTHON git+https://github.com/cython/cython.git@$LATEST_CYTHON_COMMIT
- uses: actions/checkout@v4.1.6

- name: Install latest cython and regen
- name: Regen with latest cython (using system python3)
run: |
pip install --no-index --find-links $WHEELHOUSE_CYTHON --pre cython
touch $(find | grep pxd$)
pip3 install cython==3.0.10
python3 setup.py cython_only
- name: Install python-wasm-sdk
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ concurrency:
jobs:
deps:
name: ${{ matrix.macarch }} deps
runs-on: macos-12
runs-on: ${{ matrix.os }}
strategy:
matrix:
# make arm64 deps and x86_64 deps
macarch: [arm64, x86_64]
include:
- { macarch: arm64, os: macos-14 }
- { macarch: x86_64, os: macos-13 }

steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- name: Test for Mac Deps cache hit
id: macdep-cache
Expand All @@ -54,7 +56,7 @@ jobs:
path: ${{ github.workspace }}/pygame_mac_deps_${{ matrix.macarch }}
# The hash of all files in buildconfig manylinux-build and macdependencies is
# the key to the cache. If anything changes here, the deps are built again
key: macdep-${{ hashFiles('buildconfig/manylinux-build/**') }}-${{ hashFiles('buildconfig/macdependencies/*.sh') }}-${{ matrix.macarch }}
key: macdep-${{ hashFiles('buildconfig/manylinux-build/**') }}-${{ hashFiles('buildconfig/macdependencies/*.sh') }}-${{ matrix.macarch }}-${{ matrix.os }}
lookup-only: true

# build mac deps on cache miss
Expand All @@ -76,7 +78,7 @@ jobs:
build:
name: ${{ matrix.name }}
needs: deps
runs-on: macos-12
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # if a particular matrix build fails, don't skip the rest
matrix:
Expand All @@ -87,31 +89,36 @@ jobs:
- {
name: "x86_64 (CPython 3.9 - 3.12)",
macarch: x86_64,
os: macos-13,
pyversions: "cp3{9,10,11,12}-*",
}

- {
name: "x86_64 (Python 3.8)",
macarch: x86_64,
os: macos-13,
# CPython/PyPy 3.8
pyversions: "?p38-*",
}

- {
name: "x86_64 (PyPy 3.9 and 3.10)",
macarch: x86_64,
os: macos-13,
pyversions: "pp39-* pp310-*",
}

- {
name: "arm64 (CPython 3.8 - 3.10)",
macarch: arm64,
os: macos-14,
pyversions: "cp3{8,9,10}-*",
}

- {
name: "arm64 (CPython 3.11 - 3.12)",
macarch: arm64,
os: macos-14,
pyversions: "cp3{11,12}-*",
}

Expand All @@ -135,8 +142,6 @@ jobs:

CIBW_BUILD: ${{ matrix.pyversions }}

# Build arm64 and x86_64 wheels too on an Intel runner.
# Note that the arm64 wheels cannot be tested on CI in this configuration
CIBW_ARCHS: ${{ matrix.macarch }}

# Setup macOS dependencies
Expand All @@ -160,7 +165,7 @@ jobs:
CIBW_BUILD_VERBOSITY: 2

steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- name: pip cache
uses: actions/cache@v4.0.2
Expand All @@ -177,7 +182,7 @@ jobs:
fail-on-cache-miss: true

- name: Build and test wheels
uses: pypa/cibuildwheel@v2.16.4
uses: pypa/cibuildwheel@v2.17.0

- uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-manylinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
CIBW_BUILD_VERBOSITY: 2

steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- name: Log in to the Container registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
CIBW_MANYLINUX_I686_IMAGE: ghcr.io/${{ github.repository }}_i686:${{ steps.meta.outputs.version }}
CIBW_MANYLINUX_PYPY_I686_IMAGE: ghcr.io/${{ github.repository }}_i686:${{ steps.meta.outputs.version }}

uses: pypa/cibuildwheel@v2.16.4
uses: pypa/cibuildwheel@v2.17.0

# We upload the generated files under github actions assets
- name: Upload dist
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-on-msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
# - { sys: clangarm64, env: clang-aarch64 }

steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
Expand All @@ -61,6 +61,7 @@ jobs:
mingw-w64-${{ matrix.env }}-python-pip
mingw-w64-${{ matrix.env }}-python-sphinx
mingw-w64-${{ matrix.env }}-meson-python
mingw-w64-${{ matrix.env }}-cython
# mingw-w64-${{ matrix.env }}-SDL2
# mingw-w64-${{ matrix.env }}-SDL2_image
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-ubuntu-sdist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
os: [ubuntu-20.04, ubuntu-22.04]

steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- name: Install deps
# install numpy from pip and not apt because the one from pip is newer,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ jobs:
CIBW_BUILD_VERBOSITY: 2

steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- uses: TheMrMilchmann/setup-msvc-dev@v3 # this lets us use the developer command prompt on windows
with:
arch: ${{ matrix.msvc-dev-arch }}

- name: Build and test wheels
uses: pypa/cibuildwheel@v2.16.5
uses: pypa/cibuildwheel@v2.17.0

- uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- name: Install deps
# https://github.com/actions/runner-images/issues/7192
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/format-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: python3 setup.py lint

# Run lint CI on changes to main branch, or any PR to main. Do not run CI on
# any other branch.
# run only if there are changes on files that are linted (C, python and rst files)
# Run only if there are changes on files that are linted (C, Python and rst files)
on:
push:
branches: main
Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6
- uses: actions/setup-python@v5
with:
python-version: 3.x
Expand All @@ -40,13 +40,13 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- name: Install deps
run: python3 -m pip install pylint black clang-format sphinx"<7.2.0"
run: python3 -m pip install pylint sphinx"<7.2.0"

- name: Check code Formatting and Linting
run: python3 setup.py lint
- name: Check code linting
run: pylint src_py docs

- name: Check docs changes are checked in
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-gh-draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
needs: [manylinux-aarch64, manylinux, macos, windows, sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- name: Download all artifacts
uses: actions/download-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4.1.3
- uses: actions/checkout@v4.1.6

- name: Pull all release assets
uses: robinraju/release-downloader@v1.10
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ dist
*.so
__pycache__
_headers/*

# cython generated files
src_c/_sdl2/*.c
!/src_c/_sdl2/touch.c
src_c/pypm.c
18 changes: 6 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@
# Then in the project root directory run `pre-commit install`

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.3.0
hooks:
- id: black
exclude: |
(?x)^(
^buildconfig/.*$
| ^docs/reST/.*$
| setup.py
)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.2
hooks: # See pyproject.toml for configuration options.
- id: ruff-format # Run the formatter
types_or: [ python, pyi, jupyter ]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.2
rev: v18.1.4
hooks:
- id: clang-format
exclude: |
Expand Down
6 changes: 2 additions & 4 deletions buildconfig/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ def prepdep(dep, basepath):
if isinstance(dep.inc_dir, str):
incs.append(IPREFIX+dep.inc_dir[startind:])
else:
for dir in dep.inc_dir:
incs.append(IPREFIX+dir[startind:])
incs.extend(IPREFIX+dir[startind:] for dir in dep.inc_dir)
if dep.lib_dir:
if isinstance(dep.lib_dir, str):
lids.append(LPREFIX+dep.lib_dir[startind:])
else:
for dir in dep.lib_dir:
lids.append(LPREFIX+dir[startind:])
lids.extend(LPREFIX+dir[startind:] for dir in dep.lib_dir)
libs = ''
for lib in dep.libs:
libs += ' -l' + lib
Expand Down
8 changes: 4 additions & 4 deletions buildconfig/download_win_prebuilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def get_urls(x86=True, x64=True):
url_sha1 = []
url_sha1.extend([
[
'https://github.com/libsdl-org/SDL/releases/download/release-2.30.2/SDL2-devel-2.30.2-VC.zip',
'f354c841e99a9894ff0f5ba85ec306184316e7b6',
'https://github.com/libsdl-org/SDL/releases/download/release-2.30.3/SDL2-devel-2.30.3-VC.zip',
'2878b4b1fbe9e4b22a317ad52c9d751c70e8df62',
],
[
'https://github.com/pygame-community/SDL_image/releases/download/2.8.2-pgce/SDL2_image-devel-2.8.2-VCpgce.zip',
Expand Down Expand Up @@ -234,12 +234,12 @@ def copy(src, dst):
copy(
os.path.join(
temp_dir,
'SDL2-devel-2.30.2-VC/SDL2-2.30.2'
'SDL2-devel-2.30.3-VC/SDL2-2.30.3'
),
os.path.join(
move_to_dir,
prebuilt_dir,
'SDL2-2.30.2'
'SDL2-2.30.3'
)
)

Expand Down
27 changes: 26 additions & 1 deletion buildconfig/get_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,29 @@

version = ast.literal_eval(finds[0].strip())

print(version)

_splits = version.split(".")

# handle optional dev tag
if len(_splits) == 3:
_splits.append('""')
elif len(_splits) == 4:
_splits[3] = f'".{_splits[3]}"'
else:
raise ValueError("Invalid version!")

version_short = ".".join(_splits[:3])
version_macros = tuple(
zip(
("PG_MAJOR_VERSION", "PG_MINOR_VERSION", "PG_PATCH_VERSION", "PG_VERSION_TAG"),
_splits,
)
)


if __name__ == "__main__":
print(
"\n".join(f"-D{key}={value}" for key, value in version_macros)
if "--macros" in sys.argv
else version
)
Loading

0 comments on commit cf91362

Please sign in to comment.