diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml new file mode 100644 index 0000000..3f9fc69 --- /dev/null +++ b/.github/workflows/msys2.yml @@ -0,0 +1,46 @@ +name: MSYS2 Tests + +on: + push: + branches-ignore: + - "dependabot/**" + pull_request: + +jobs: + test: + name: Test with MSYS2 ${{ matrix.sys }} + runs-on: windows-2022 + strategy: + matrix: + include: + - { sys: msys, toolchain: "gcc" } + - { sys: mingw64, env: mingw-w64-x86_64- } + - { sys: ucrt64, env: mingw-w64-ucrt-x86_64- } + - { sys: clang64, env: mingw-w64-clang-x86_64- } + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: 'Setup MSYS2' + uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + update: true + install: >- + make + ${{matrix.env}}cmake + ${{matrix.env}}ninja + ${{matrix.env}}${{matrix.toolchain || 'toolchain' }} + ${{matrix.env}}python + ${{matrix.env}}python-pip + ${{matrix.env}}python-pytest + ${{matrix.env}}python-setuptools + ${{matrix.env}}python-typing_extensions + ${{matrix.env}}python-wheel + - name: "Run tests" + shell: msys2 {0} + env: + CIBUILDWHEEL: 1 + run: | + python -m pip install -v --no-build-isolation . + python -m pytest diff --git a/README.rst b/README.rst index ef48386..e0f0e67 100644 --- a/README.rst +++ b/README.rst @@ -123,6 +123,8 @@ Changelog ========= Future ------ +- Add MSYS2 support for C-extension +- Better logging on base64 build failure when C-extension build is optional - Drop python 3.6 support 1.3.2 diff --git a/setup.py b/setup.py index bfa8937..3fffc8e 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ ) -def get_cmake_extra_config(plat_name: str | None, build_type: str) -> list[str]: +def get_cmake_extra_config(plat_name: str | None, build_type: str) -> tuple[bool, list[str]]: log.info("getting cmake extra config") extra_config = [] machine = platform_module.machine().lower() @@ -80,13 +80,14 @@ def get_cmake_extra_config(plat_name: str | None, build_type: str) -> list[str]: log.info(" sysconfig LDFLAGS: %s", sysconfig.get_config_var("LDFLAGS")) platform = plat_name or platform + is_msvc = platform.startswith("win") - if not IS_WINDOWS: + if not is_msvc: extra_config.append(f"-DCMAKE_BUILD_TYPE={build_type}") - if IS_WINDOWS: - if not platform.startswith("win"): - msg = f"Building {platform} is not supported on Windows" + if is_msvc: + if not IS_WINDOWS: + msg = f"Building {platform} is only supported on Windows" raise ValueError(msg) # setup cross-compile # assumes VS2019 or VS2022 will be used as the default generator @@ -129,7 +130,7 @@ def get_cmake_extra_config(plat_name: str | None, build_type: str) -> list[str]: else: log.warning("`%s` is not a known value for CMAKE_OSX_ARCHITECTURES", arch) - return extra_config + return is_msvc, extra_config def cmake(*args: str) -> None: @@ -158,10 +159,11 @@ def base64_build(plat_name: str | None) -> Generator[bool, None, None]: try: try: cmake("--version") - config_options.extend(get_cmake_extra_config(plat_name, build_type)) + is_msvc, extra_config = get_cmake_extra_config(plat_name, build_type) + config_options.extend(extra_config) cmake(*config_options) cmake("--build", str(build_dir), "--config", build_type, "--verbose") - if IS_WINDOWS: + if is_msvc: shutil.copyfile(build_dir / build_type / "base64.lib", build_dir / "base64.lib") base64_built = True except Exception as e: