Skip to content

Comments

Centralize cibuildwheel config and pin macOS deployment target#330

Open
holodorum wants to merge 4 commits intokson-org:mainfrom
holodorum:centralize-cibuildwheel-config
Open

Centralize cibuildwheel config and pin macOS deployment target#330
holodorum wants to merge 4 commits intokson-org:mainfrom
holodorum:centralize-cibuildwheel-config

Conversation

@holodorum
Copy link
Collaborator

Summary

  • Move all cibuildwheel configuration from Gradle environment() calls to pyproject.toml under [tool.cibuildwheel], the canonical location for this config
  • Pin MACOSX_DEPLOYMENT_TARGET to 11.0 so builds don't fail when the host macOS is newer than what the Python packaging tools recognize
  • Gitignore lib-python/LICENSE (build artifact copied from project root by the copyLicense Gradle task)

The build backend checked for native artifacts using `any()` across all
platforms (win32, darwin, linux), so a stale artifact from a different OS
(e.g. `libkson.dylib` left over on a Linux builder) would skip the
Gradle build, leaving the actually-needed native library uncompiled.

Additionally, the artifact check included `kson_api.h` which is not
produced by the build—the Gradle `CopyNativeArtifactsTask` produces
`jni_simplified.h` and the runtime loads `jni_simplified.h`. This would
have caused fresh wheel builds to always trigger a rebuild attempt.

Finally, when both artifacts and `kson-sdist` were absent, the function
silently returned, producing broken wheels with no error.

Fixes:
- Check only the native library for *this* platform, plus
  `jni_simplified.h` (the header actually produced and loaded at
  runtime)
- Add a post-condition that errors clearly when required artifacts are
  missing, guiding users to install from a pre-built wheel or ensure a
  JDK is available
- Use `subprocess.run(cwd=...)` instead of `os.chdir` for thread safety
- Log both stdout and stderr on Gradle build failure for easier
  debugging
- Exclude platform-specific native binaries from `prepareSdistBuildEnvironment`
  in build.gradle.kts so sdists don't bundle stale cross-platform
  artifacts

Fixes kson-org#307
PixiExecTask only declares inputs (command strings, env vars) but no
outputs, so Gradle always considered this task out-of-date and re-ran
the full native-image build every time.

Add explicit input/output declarations so Gradle can properly cache
the task: the project JAR, runtime classpath, and JNI config as inputs,
and the native binary as the output. The output is the specific binary
file rather than the whole directory, since krossover's
generateJniBindingsJvm also writes into that directory.
Move all cibuildwheel configuration from environment variables in the
Gradle buildWheel task to pyproject.toml under [tool.cibuildwheel].
This is the canonical location for cibuildwheel config, and centralizing
it means the settings apply regardless of how cibuildwheel is invoked.

Also pin MACOSX_DEPLOYMENT_TARGET to 11.0 (Big Sur, the first
ARM-native macOS) so that builds don't fail when the host macOS
version is newer than what the Python packaging tools recognize.
This file is copied from the project root by the copyLicense Gradle
task at wheel-build time.  It's a build artifact, not a source file.
@holodorum holodorum force-pushed the centralize-cibuildwheel-config branch from 1a04517 to edbefb3 Compare February 21, 2026 12:44
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.

1 participant