Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
illume merged 7 commits intomainfrommsys2-fixes
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
77 changes: 77 additions & 0 deletions.github/workflows/build-msys2.yml
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -464,8 +464,6 @@ def setup_prebuilt_sdl2(prebuilt_dir):


def main(auto_config=False):
machine_type = get_machine_type()

# config MSYS2 always requires prebuilt dependencies, in the
# form of packages available in MSYS2.
download_prebuilt = 'PYGAME_DOWNLOAD_PREBUILT' in os.environ
Expand All@@ -479,25 +477,16 @@ def main(auto_config=False):
except ImportError:
import download_msys2_prebuilt

download_kwargs = {
'x86': False,
'x64': False,
}
download_kwargs[machine_type] = True
if download_prebuilt:
download_msys2_prebuilt.update(**download_kwargs)
download_msys2_prebuilt.update()

# MSYS2 config only supports setup with prebuilt dependencies
# The prebuilt dir is the MinGW root from the MSYS2
# installation path. Since we're currently running in a native
# binary, this Python has no notion of MSYS2 or MinGW paths, so
# we convert the prebuilt dir to a Windows absolute path.
# e.g. /mingw64 (MSYS2) -> C:/msys64/mingw64 (Windows)
prebuilt_msys_dir = {
'x86': '/mingw32',
'x64': '/mingw64'
}
prebuilt_dir = get_absolute_win_path(prebuilt_msys_dir[machine_type])
prebuilt_dir = get_absolute_win_path("/" + download_msys2_prebuilt.detect_arch())
return setup_prebuilt_sdl2(prebuilt_dir)


Expand Down
139 changes: 102 additions & 37 deletionsbuildconfig/download_msys2_prebuilt.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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()
15 changes: 6 additions & 9 deletionssetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,7 +133,7 @@ def spawn(self, cmd, **kwargs):
build_ext.get_export_symbols = lambda self, ext: []

IS_PYPY = '__pypy__' in sys.builtin_module_names

IS_MSC = sys.platform == "win32" and "MSC" in sys.version

def compilation_help():
""" On failure point people to a web page for help.
Expand DownExpand Up@@ -443,16 +443,14 @@ def run_install_headers(self):

e.extra_compile_args.extend(
# some warnings are skipped here
("/W3", "/wd4142", "/wd4996")
if sys.platform == "win32"
else ("-Wall", "-Wno-error=unknown-pragmas")
("/W3", "/wd4142", "/wd4996") if IS_MSC else ("-Wall", "-Wno-error=unknown-pragmas")
)

if "surface" in e.name and sys.platform == "darwin":
# skip -Werror on alphablit because sse2neon is used on arm mac
continue

if "rwobject" in e.name andsys.platform != "win32":
if "rwobject" in e.name andnot IS_MSC:
# because Py_FileSystemDefaultEncoding is deprecated in 3.12.0a7
e.extra_compile_args.append("-Wno-error=deprecated-declarations")

Expand All@@ -461,7 +459,7 @@ def run_install_headers(self):
if sysconfig.get_config_var("MAINCC") != "clang":
e.extra_compile_args.append("-Wno-error=unused-but-set-variable")

if "mask" in e.name andsys.platform == "win32":
if "mask" in e.name andIS_MSC:
# skip analyze warnings that pop up a lot in mask for now. TODO fix
e.extra_compile_args.extend(("/wd6385", "/wd6386"))

Expand All@@ -471,7 +469,7 @@ def run_install_headers(self):
and e.name not in ("pypm", "_sprite", "gfxdraw")
):
# Do -Werror only on CI, and exclude -Werror on Cython C files and gfxdraw
e.extra_compile_args.append("/WX" ifsys.platform == "win32"else "-Werror")
e.extra_compile_args.append("/WX" ifIS_MSCelse "-Wundef")

# if not building font, try replacing with ftfont
alternate_font = os.path.join('src_py', 'font.py')
Expand DownExpand Up@@ -742,8 +740,7 @@ def flag_filter(compiler, *flags):
return [flag for flag in flags if has_flag(compiler, flag)]


# Only on win32, not MSYS2
if 'MSYSTEM' not in os.environ:
if IS_MSC:
@add_command('build_ext')
class WinBuildExt(build_ext):
"""This build_ext sets necessary environment variables for MinGW"""
Expand Down
6 changes: 6 additions & 0 deletionssrc_c/camera.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,6 +59,12 @@
#if defined(__WIN32__)
#define PYGAME_WINDOWS_CAMERA 1

#ifdef __MINGW32__
#undef WINVER
/** _WIN32_WINNT_WINBLUE sets minimum platform SDK to Windows 8.1. */
#define WINVER _WIN32_WINNT_WINBLUE
#endif

#include <mfapi.h>
#include <mfobjects.h>
#include <mfidl.h>
Expand Down
8 changes: 8 additions & 0 deletionssrc_c/camera_windows.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,6 +48,14 @@

#include <math.h>

#ifdef __MINGW32__
#ifndef CLSID_VideoProcessorMFT
#include <initguid.h>
DEFINE_GUID(CLSID_VideoProcessorMFT, 0x88753b26, 0x5b24, 0x49bd, 0xb2, 0xe7,
0xc, 0x44, 0x5c, 0x78, 0xc9, 0x82);
#endif
#endif

#define RELEASE(obj) \
if (obj) { \
obj->lpVtbl->Release(obj); \
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp