From 01e7b84d8982b3b08efdb338e4197f5f27324ad3 Mon Sep 17 00:00:00 2001 From: saces Date: Thu, 9 Apr 2026 07:30:42 +0200 Subject: [PATCH] (re)enable windows build turning it off and on again seems to work here too ;) --- .github/workflows/build.yaml | 10 ++++++---- pygomx/.gitignore | 2 ++ pygomx/build_ffi.py | 11 ++++++++--- pygomx/libmxclient.def | 29 +++++++++++++++++++++++++++++ pygomx/pyproject.toml | 5 +++++ pygomx/setup.py | 29 ++++++++++++++++++++++++----- 6 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 pygomx/libmxclient.def diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 19a0da1..0825ff0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -78,13 +78,13 @@ jobs: needs: - changes - timestamp - if: ${{ needs.changes.outputs.pygomx == 'needsbuildfix' }} + if: ${{ needs.changes.outputs.pygomx == 'true' }} runs-on: ${{ matrix.os }} continue-on-error: true strategy: fail-fast: false matrix: - os: [windows-2022, windows-11-arm] + os: [windows-2022] steps: - uses: actions/checkout@v6 @@ -101,7 +101,9 @@ jobs: package-dir: pygomx env: SOURCE_DATE_EPOCH: ${{ needs.timestamp.outputs.sepoch }} - CIBW_SKIP: "*-win32" + CIBW_SKIP: "*-win32 *t-*" + PYGOMX_BUILD_MODE: shared + CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair --add-path ${{ github.workspace }}\\pygomx -w {dest_dir} {wheel}" - name: upload artifacts uses: actions/upload-artifact@v7 @@ -153,7 +155,7 @@ jobs: - changes - pygomx-wheel-mac - pygomx-wheel-linux - #- pygomx-wheel-win + - pygomx-wheel-win if: ${{ needs.changes.outputs.pygomx == 'true' }} runs-on: ubuntu-latest environment: diff --git a/pygomx/.gitignore b/pygomx/.gitignore index dc1a4fd..8e3da5b 100644 --- a/pygomx/.gitignore +++ b/pygomx/.gitignore @@ -8,3 +8,5 @@ build/ *.a __pycache__ .eggs/ +libmxclient.* +!libmxclient.def diff --git a/pygomx/build_ffi.py b/pygomx/build_ffi.py index a2919e1..bf9052c 100644 --- a/pygomx/build_ffi.py +++ b/pygomx/build_ffi.py @@ -4,9 +4,14 @@ import os from cffi import FFI -lib_list = [ - "mxclient", -] +if os.name == "nt": + lib_list = [ + "libmxclient", + ] +else: + lib_list = [ + "mxclient", + ] # keep defaults in sync with setup.py if ( diff --git a/pygomx/libmxclient.def b/pygomx/libmxclient.def new file mode 100644 index 0000000..9106dd6 --- /dev/null +++ b/pygomx/libmxclient.def @@ -0,0 +1,29 @@ +EXPORTS +FreeCString +apiv0_createclient +apiv0_createclient_pass +apiv0_createroom +apiv0_deinitialize +apiv0_discover +apiv0_getoptions +apiv0_initialize +apiv0_joinedrooms +apiv0_leaveroom +apiv0_listclients +apiv0_login +apiv0_removeclient +apiv0_sendmessage +apiv0_set_on_event_handler +apiv0_set_on_message_handler +apiv0_set_on_sys_handler +apiv0_setoptions +apiv0_startclient +apiv0_stopclient +cliv0_accountinfo +cliv0_clearaccount +cliv0_discoverhs +cliv0_genericrequest +cliv0_mkmxtoken +cliv0_mxpassitem +cliv0_serverinfo +cliv0_whoami diff --git a/pygomx/pyproject.toml b/pygomx/pyproject.toml index 92e519e..ab7b6d1 100644 --- a/pygomx/pyproject.toml +++ b/pygomx/pyproject.toml @@ -18,3 +18,8 @@ heimseite = "https://code.c-base.org/saces/pygomx" [tool.setuptools.package-dir] "pygomx" = "src/pygomx" + +# Use delvewheel on windows +[tool.cibuildwheel.windows] +before-build = "pip install delvewheel" +repair-wheel-command = "delvewheel repair --add-path . -w {dest_dir} {wheel}" diff --git a/pygomx/setup.py b/pygomx/setup.py index 4ca67a1..b30649d 100644 --- a/pygomx/setup.py +++ b/pygomx/setup.py @@ -43,10 +43,16 @@ class CustomCommand(Command): match os.getenv("PYGOMX_BUILD_MODE", "static"): case "static": build_mode_name = "c-archive" - build_mode_ext = ".a" + if os.name == "nt": + build_mode_ext = ".lib" + else: + build_mode_ext = ".a" case "shared": build_mode_name = "c-shared" - build_mode_ext = ".so" + if os.name == "nt": + build_mode_ext = ".dll" + else: + build_mode_ext = ".so" case _: raise ValueError("Invalid PYGOMX_BUILD_MODE.") @@ -73,9 +79,22 @@ class CustomCommand(Command): f"../pygomx/libmxclient{build_mode_ext}", ".", ] - ret = subprocess.call(go_call, cwd="../libmxclient") - if ret != 0: - raise Exception("Go build failed.") + # print(f"DEBUG: {' '.join(go_call) }") + subprocess.check_call(go_call, cwd="../libmxclient") + + if os.name == "nt" and os.getenv("PYGOMX_BUILD_MODE", "nope") == "shared": + from setuptools._distutils.compilers.C.msvc import Compiler + + comp = Compiler() + comp.initialize() + subprocess.check_call( + [ + comp.lib, + "/def:libmxclient.def", + "/machine:AMD64", + "/out:libmxclient.lib", + ] + ) class CustomBuild(build):