Skip to content

Make build-cpython-ghuser-components work on macOS#14

Merged
gonzalocasas merged 1 commit into
mainfrom
fix-macos-cpython-ghuser-components
Jun 4, 2026
Merged

Make build-cpython-ghuser-components work on macOS#14
gonzalocasas merged 1 commit into
mainfrom
fix-macos-cpython-ghuser-components

Conversation

@gonzalocasas

Copy link
Copy Markdown
Member

Run the componentizer as a direct subprocess (sys.executable) instead of through a shell, and on macOS force the Mono runtime and add the Homebrew library dirs to DYLD_LIBRARY_PATH.

The componentizer loads GH_IO.dll via pythonnet, so no Rhino/Windows is required — only a .NET runtime. On macOS that's Mono, which needs the native libgdiplus to embed component icons. Two things broke this off Windows:

  • The Mono that pythonnet embeds doesn't search the Homebrew prefix the way the mono CLI does, so libgdiplus wasn't found. Setting DYLD_LIBRARY_PATH to $(brew --prefix)/lib (plus the standard /opt/homebrew and /usr/local prefixes) fixes resolution.
  • macOS SIP strips DYLD_* when a command crosses the protected /bin/sh, which is what invoke's ctx.run spawns. Calling the interpreter directly via subprocess.run keeps the variable alive.

Windows behaviour is unchanged (env returned untouched).

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke lint).
  • I added new functions/classes and made them available on a second-level import, e.g. compas.datastructures.Mesh.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

Run the componentizer as a direct subprocess (sys.executable) instead of
through a shell, and on macOS force the Mono runtime and add the Homebrew
library dirs to DYLD_LIBRARY_PATH.

The componentizer loads GH_IO.dll via pythonnet, so no Rhino/Windows is
required — only a .NET runtime. On macOS that's Mono, which needs the native
libgdiplus to embed component icons. Two things broke this off Windows:

- The Mono that pythonnet embeds doesn't search the Homebrew prefix the way
  the `mono` CLI does, so libgdiplus wasn't found. Setting DYLD_LIBRARY_PATH
  to $(brew --prefix)/lib (plus the standard /opt/homebrew and /usr/local
  prefixes) fixes resolution.
- macOS SIP strips DYLD_* when a command crosses the protected /bin/sh, which
  is what invoke's ctx.run spawns. Calling the interpreter directly via
  subprocess.run keeps the variable alive.

Windows and Linux behaviour is unchanged (env returned untouched).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gonzalocasas gonzalocasas requested a review from chenkasirer June 4, 2026 14:41

@chenkasirer chenkasirer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMAZING! LGTM!

@gonzalocasas gonzalocasas merged commit 5258700 into main Jun 4, 2026
6 checks passed
@gonzalocasas gonzalocasas deleted the fix-macos-cpython-ghuser-components branch June 4, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants