- Notifications
You must be signed in to change notification settings - Fork3.9k
setup: Fix some MSCisms so MSYS2 can work better#4042
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
7 commits Select commitHold shift + click to select a range
aa58a87 setup: Fix some MSCisms so MSYS2 can work better
illume5202f6b camera: On mingw set Win8.1 minimum platform SDK
illume80b8c60 buildconfig/config_msys2: Fix for many types of prefix
illume006b7a8 buildconfig/download_msys2_prebuilt: Fix for multiple arches
illumea62cfd9 buildconfig/config_msys2: Try to detect the arch better
illume73c2ccd buildconfig/download_msys2_prebuilt: Add more build dependencies
illume4bf32d7 github/workflows/build-msys2: Add msys2 test bot
illumeFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
77 changes: 77 additions & 0 deletions.github/workflows/build-msys2.yml
This file contains hidden or 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 |
15 changes: 2 additions & 13 deletionsbuildconfig/config_msys2.py
This file contains hidden or 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
139 changes: 102 additions & 37 deletionsbuildconfig/download_msys2_prebuilt.py
This file contains hidden or 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 | ||
| 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 | ||
| ) | ||
| if output.returncode != 0: | ||
| logging.error( | ||
| "Error {} while downloading package {}: \n{}".format( | ||
| output.returncode, pkg_name, output.stderr | ||
| ) | ||
| ) | ||
| return output.returncode != 0 | ||
| 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 = [ | ||
| "{}-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", | ||
| ] | ||
| 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(arch): | ||
| """For installing prebuilt dependencies.""" | ||
| errors = False | ||
| print("Installing pre-built dependencies") | ||
| 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 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__": | ||
| update() |
15 changes: 6 additions & 9 deletionssetup.py
This file contains hidden or 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
6 changes: 6 additions & 0 deletionssrc_c/camera.h
This file contains hidden or 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
8 changes: 8 additions & 0 deletionssrc_c/camera_windows.c
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.