forked from pygame/pygame
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pygame:main' into Poly_Fix
- Loading branch information
Showing
25 changed files
with
338 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: MSYS2 Windows | ||
|
||
on: | ||
release: | ||
types: [created] | ||
push: | ||
branches: main | ||
paths-ignore: | ||
- "docs/**" | ||
- "examples/**" | ||
- ".gitignore" | ||
- "*.rst" | ||
- "*.md" | ||
- ".github/workflows/*.yml" | ||
# re-include current file to not be excluded | ||
- "!.github/workflows/build-msys2.yml" | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
- "v**" | ||
paths-ignore: | ||
- "docs/**" | ||
- "examples/**" | ||
- ".gitignore" | ||
- "*.rst" | ||
- "*.md" | ||
- ".github/workflows/*.yml" | ||
# re-include current file to not be excluded | ||
- "!.github/workflows/build-msys2.yml" | ||
|
||
jobs: | ||
build: | ||
name: ${{ matrix.sys }} [${{ matrix.env }}] | ||
runs-on: windows-latest | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- { sys: mingw64, env: x86_64 } | ||
# - { sys: mingw32, env: i686 } | ||
# - { sys: ucrt64, env: ucrt-x86_64 } | ||
# - { sys: clang64, env: clang-x86_64 } | ||
steps: | ||
- uses: actions/checkout@v3.0.2 | ||
- name: Install MSYS2 | ||
uses: msys2/setup-msys2@v2 | ||
with: | ||
# update: true | ||
msystem: ${{matrix.sys}} | ||
install: >- | ||
mingw-w64-${{matrix.env}}-python | ||
- name: Install deps | ||
shell: msys2 {0} | ||
run: | | ||
python buildconfig/download_msys2_prebuilt.py | ||
- name: Compile Python Extension using MSYS2 | ||
shell: msys2 {0} | ||
run: | | ||
mkdir -p ./wheelhouse | ||
# export PIP_CONFIG_FILE=buildconfig/pip_config.ini | ||
echo "\nBuilding pygame wheel\n" | ||
python setup.py docs | ||
python -m pip wheel . --wheel-dir ./wheelhouse -vvv | ||
echo "\nInstalling wheel\n" | ||
python -m pip install --force-reinstall ./wheelhouse/pygame*.whl | ||
echo "\nRun tests\n" | ||
export SDL_VIDEODRIVER=dummy | ||
export SDL_AUDIODRIVER=disk | ||
python -m test -v --exclude opengl,music,timing --time_out 300 | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: pygame-msys2-wheels | ||
path: ~/wheelhouse/*.whl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,134 @@ | ||
""" | ||
This script install prebuilt dependencies for MSYS2. | ||
It uses pacman to install the dependencies. | ||
See documentation about different environments here: | ||
https://www.msys2.org/docs/environments/ | ||
""" | ||
import logging | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
|
||
def install_pacman_package(pkg_name): | ||
""" This installs a package in the current MSYS2 environment | ||
"""This installs a package in the current MSYS2 environment | ||
Does not download again if the package is already installed | ||
and if the version is the latest available in MSYS2 | ||
""" | ||
output = subprocess.run(['pacman', '-S', '--noconfirm', pkg_name], | ||
capture_output=True, text=True) | ||
output = subprocess.run( | ||
["pacman", "-S", "--noconfirm", pkg_name], capture_output=True, text=True | ||
) | ||
if output.returncode != 0: | ||
logging.error( | ||
"Error {} while downloading package {}: \n{}". | ||
format(output.returncode, pkg_name, output.stderr)) | ||
"Error {} while downloading package {}: \n{}".format( | ||
output.returncode, pkg_name, output.stderr | ||
) | ||
) | ||
|
||
return output.returncode != 0 | ||
|
||
|
||
def get_packages(x86=True, x64=True): | ||
def get_packages(arch: str) -> list: | ||
""" | ||
Returns a list of package names formatted with the specific architecture prefix. | ||
:param arch: The architecture identifier string, e.g., "mingw64", "clang32", etc. | ||
It is used to select the appropriate prefix for package names. | ||
:return: A list of fully formatted package names based on the given architecture. | ||
Example: | ||
If the 'arch' parameter is "mingw32", the return value will be a list like: | ||
[ | ||
'mingw-w64-i686-SDL2', | ||
'mingw-w64-i686-SDL2_ttf', | ||
'mingw-w64-i686-SDL2_image', | ||
... | ||
] | ||
""" | ||
deps = [ | ||
'mingw-w64-{}-SDL2', | ||
'mingw-w64-{}-SDL2_ttf', | ||
'mingw-w64-{}-SDL2_image', | ||
'mingw-w64-{}-SDL2_mixer', | ||
'mingw-w64-{}-portmidi', | ||
'mingw-w64-{}-libpng', | ||
'mingw-w64-{}-libjpeg-turbo', | ||
'mingw-w64-{}-libtiff', | ||
'mingw-w64-{}-zlib', | ||
'mingw-w64-{}-libwebp', | ||
'mingw-w64-{}-libvorbis', | ||
'mingw-w64-{}-libogg', | ||
'mingw-w64-{}-flac', | ||
'mingw-w64-{}-libmodplug', | ||
'mingw-w64-{}-mpg123', | ||
'mingw-w64-{}-opus', | ||
'mingw-w64-{}-opusfile', | ||
'mingw-w64-{}-freetype' | ||
"{}-SDL2", | ||
"{}-SDL2_ttf", | ||
"{}-SDL2_image", | ||
"{}-SDL2_mixer", | ||
"{}-portmidi", | ||
"{}-libpng", | ||
"{}-libjpeg-turbo", | ||
"{}-libtiff", | ||
"{}-zlib", | ||
"{}-libwebp", | ||
"{}-libvorbis", | ||
"{}-libogg", | ||
"{}-flac", | ||
"{}-libmodplug", | ||
"{}-mpg123", | ||
"{}-opus", | ||
"{}-opusfile", | ||
"{}-freetype", | ||
"{}-python-build", | ||
"{}-python-installer", | ||
"{}-python-setuptools", | ||
"{}-python-wheel", | ||
"{}-python-pip", | ||
"{}-python-numpy", | ||
"{}-python-sphinx", | ||
"{}-cmake", | ||
"{}-cc", | ||
"{}-cython", | ||
] | ||
|
||
packages = [] | ||
if x86: | ||
packages.extend([x.format('i686') for x in deps]) | ||
if x64: | ||
packages.extend([x.format('x86_64') for x in deps]) | ||
return packages | ||
full_arch_names = { | ||
"clang32": "mingw-w64-clang-i686", | ||
"clang64": "mingw-w64-clang-x86_64", | ||
"mingw32": "mingw-w64-i686", | ||
"mingw64": "mingw-w64-x86_64", | ||
"ucrt64": "mingw-w64-ucrt-x86_64", | ||
"clangarm64": "mingw-w64-clang-aarch64", | ||
} | ||
|
||
return [x.format(full_arch_names[arch]) for x in deps] | ||
|
||
def install_prebuilts(x86=True, x64=True): | ||
""" For installing prebuilt dependencies. | ||
""" | ||
|
||
def install_prebuilts(arch): | ||
"""For installing prebuilt dependencies.""" | ||
errors = False | ||
print("Installing pre-built dependencies") | ||
for pkg in get_packages(x86=x86, x64=x64): | ||
for pkg in get_packages(arch): | ||
print(f"Installing {pkg}") | ||
error = install_pacman_package(pkg) | ||
errors = errors or error | ||
if errors: | ||
raise Exception("Some dependencies could not be installed") | ||
|
||
|
||
def update(x86=True, x64=True): | ||
install_prebuilts(x86=x86, x64=x64) | ||
def detect_arch(): | ||
"""Returns one of: "clang32", "clang64", "mingw32", "mingw64", "ucrt64", "clangarm64". | ||
Based on the MSYSTEM environment variable with a fallback. | ||
""" | ||
msystem = os.environ.get("MSYSTEM", "") | ||
if msystem.startswith("MINGW32"): | ||
return "mingw32" | ||
elif msystem.startswith("MINGW64"): | ||
return "mingw64" | ||
elif msystem.startswith("UCRT64"): | ||
return "ucrt64" | ||
elif msystem.startswith("CLANG32"): | ||
return "clang32" | ||
elif msystem.startswith("CLANGARM64"): | ||
return "clangarm64" | ||
elif msystem.startswith("CLANG64"): | ||
return "clang64" | ||
else: | ||
if sys.maxsize > 2**32: | ||
return "mingw64" | ||
else: | ||
return "mingw32" | ||
|
||
|
||
def update(arch=None): | ||
install_prebuilts(arch if arch else detect_arch()) | ||
|
||
|
||
if __name__ == '__main__': | ||
if __name__ == "__main__": | ||
update() |
Oops, something went wrong.