From 85da039341bfeb0d0b79fcd6114ff98bd1fc4a72 Mon Sep 17 00:00:00 2001 From: Ali Goodfellow <122373543+aligfellow@users.noreply.github.com> Date: Mon, 16 Mar 2026 11:59:01 +0000 Subject: [PATCH 1/6] Added macos build support --- .github/workflows/release.yml | 6 +++++- .github/workflows/wheels.yml | 9 +++++++-- .gitignore | 1 + python/setup.py | 32 +++++++++++++++++++++++++++++++- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 528f981..3d69139 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,10 +24,14 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, macos-latest] steps: + - name: Install X11 dependencies (macOS) + if: runner.os == 'macOS' + run: brew install libx11 libxpm pkg-config + - name: install X11 dependencies if: ${{ runner.os == 'Linux' }} run: | diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index b13b176..6709eb4 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -26,8 +26,11 @@ on: jobs: build_wheels: - name: Build wheels - runs-on: ubuntu-latest + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] steps: @@ -56,6 +59,8 @@ jobs: env: CIBW_BUILD: ${{ inputs.cibw-build }} CIBW_SKIP: ${{ inputs.cibw-skip }} + CIBW_BEFORE_ALL_MACOS: | + brew install libx11 libxpm pkg-config CIBW_BEFORE_ALL_LINUX: | if [ -f /etc/alpine-release ]; then # musllinux (Alpine) apk add --no-cache libx11-dev libxpm-dev pkgconf diff --git a/.gitignore b/.gitignore index 9c6ac0f..b5f9e8a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ vmol.egg-info/ python/build python/dist python/src +wheelhouse/ diff --git a/python/setup.py b/python/setup.py index 6da5c76..ade1d46 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,6 +1,7 @@ from setuptools import setup, Extension import subprocess import os +import sys import tempfile import shutil from pathlib import Path @@ -29,6 +30,32 @@ def rel_posix(path): return os.path.relpath(path, start=setup_dir).replace(os.sep, "/") +def get_x11_config(): + # On Linux, X11 headers/libs are in standard system paths — nothing extra needed. + # On macOS, Homebrew installs them to non-default locations, so we probe for them. + if sys.platform != 'darwin': + return [], [] + try: + inc = subprocess.run( + ['pkg-config', '--cflags-only-I', 'x11', 'xpm'], + check=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True, + ).stdout.split() + lib = subprocess.run( + ['pkg-config', '--libs-only-L', 'x11', 'xpm'], + check=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True, + ).stdout.split() + return [f[2:] for f in inc if f.startswith('-I')], \ + [f[2:] for f in lib if f.startswith('-L')] + except Exception: + pass + for prefix in ['/opt/homebrew', '/usr/local']: + if Path(f'{prefix}/include/X11/Xlib.h').exists(): + return [f'{prefix}/include'], [f'{prefix}/lib'] + raise RuntimeError( + 'X11 headers not found. Install with: brew install libx11 libxpm pkg-config' + ) + + setup_dir = Path(__file__).parent src_dir = setup_dir.parent / "src" @@ -45,12 +72,15 @@ def rel_posix(path): f'-DBUILD_USER="{os.getenv("USER")}@{os.getenv("HOSTNAME")}"', f'-DBUILD_DIRECTORY="{os.getcwd()}"'] +x11_inc, x11_lib = get_x11_config() + setup( version=get_git_version_hash(), include_package_data=True, ext_modules=[Extension('vmol.v', sources=c_files, - include_dirs=include_dirs, + include_dirs=include_dirs + x11_inc, + library_dirs=x11_lib, libraries = ['X11', 'Xpm'], extra_compile_args=['-std=gnu11', '-O2', ] + VERSION_FLAGS, From c54a61ccaabf2906d28225ac9987069f3ff2e55c Mon Sep 17 00:00:00 2001 From: Ali Goodfellow <122373543+aligfellow@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:18:32 +0000 Subject: [PATCH 2/6] Add manual dispatch in wheels --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 6709eb4..49efee5 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -1,6 +1,7 @@ name: Build wheels on: + workflow_dispatch: workflow_call: inputs: package-dir: From 03debdc1fd9efb217115275c82d55a43dd3f41f9 Mon Sep 17 00:00:00 2001 From: Ali Goodfellow <122373543+aligfellow@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:22:08 +0000 Subject: [PATCH 3/6] Add manual dispatch in wheels --- .github/workflows/wheels.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 49efee5..5058a0d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -2,6 +2,27 @@ name: Build wheels on: workflow_dispatch: + inputs: + package-dir: + type: string + required: false + default: ./python + output-dir: + type: string + required: false + default: wheelhouse + cibw-build: + type: string + required: false + default: "" + cibw-skip: + type: string + required: false + default: "*-musllinux_*" + upload-artifact: + type: boolean + required: false + default: true workflow_call: inputs: package-dir: From 7ccd25d0a47bd772a82991bdcf85c979e49a6838 Mon Sep 17 00:00:00 2001 From: Ali Goodfellow <122373543+aligfellow@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:27:15 +0000 Subject: [PATCH 4/6] Update wheels --- .github/workflows/wheels.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5058a0d..418057b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -83,6 +83,9 @@ jobs: CIBW_SKIP: ${{ inputs.cibw-skip }} CIBW_BEFORE_ALL_MACOS: | brew install libx11 libxpm pkg-config + CIBW_REPAIR_WHEEL_COMMAND_MACOS: > + DYLD_LIBRARY_PATH=$(brew --prefix)/lib + delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} CIBW_BEFORE_ALL_LINUX: | if [ -f /etc/alpine-release ]; then # musllinux (Alpine) apk add --no-cache libx11-dev libxpm-dev pkgconf From c0a99f9237b7ee310391b27ea154e7e2df36307f Mon Sep 17 00:00:00 2001 From: Ali Goodfellow <122373543+aligfellow@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:30:59 +0000 Subject: [PATCH 5/6] Update wheels --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 418057b..7d4e1dd 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -83,6 +83,7 @@ jobs: CIBW_SKIP: ${{ inputs.cibw-skip }} CIBW_BEFORE_ALL_MACOS: | brew install libx11 libxpm pkg-config + CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=15.0 CIBW_REPAIR_WHEEL_COMMAND_MACOS: > DYLD_LIBRARY_PATH=$(brew --prefix)/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} From 0fee467eb20dbd8599efb0e57903dcb269a3f783 Mon Sep 17 00:00:00 2001 From: Ali Goodfellow <122373543+aligfellow@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:02:20 +0000 Subject: [PATCH 6/6] Allow multiple os for publish wheels to twine --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3d69139..f8c9808 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -94,7 +94,8 @@ jobs: - name: Download build artifacts from this run uses: actions/download-artifact@v4 with: - name: vmol-wheels-${{ runner.os }}-${{ github.ref_name }}-${{ github.run_number }} + pattern: vmol-wheels-*-${{ github.ref_name }}-${{ github.run_number }} + merge-multiple: true path: dist - name: Publish to TestPyPI