Skip to content

Source build skipped due to platform-agnostic native artifact check #307

@holodorum

Description

@holodorum

Bug

When installing kson-lang from an sdist, the native library for the target platform may not be built, resulting in a runtime error:

  File "cffi/api.py", line 829, in _load_backend_lib
    raise OSError(msg)
OSError: cannot load library '.../site-packages/kson/libkson.so':
  libkson.so: cannot open shared object file: No such file or directory.

Root cause

The build backend checks whether native artifacts already exist before building from source (lib-python/build_backend.py:21-23):

native_files = ["kson.dll", "libkson.dylib", "libkson.so", "kson_api.h"]
artifacts_exist = any((src_kson_dir / f).exists() for f in native_files)

This check is platform-agnostic — any() returns True if any of the listed files exist, regardless of whether that file is usable on the current platform. If a stale artifact from a
different OS is present (e.g. libkson.dylib from macOS), the check passes, the Gradle build is skipped, and the actually needed native library is never compiled.

Fix

Make the check platform-aware: only verify the native artifact relevant to the current OS:

  • Linux: libkson.so
  • macOS: libkson.dylib
  • Windows: kson.dll
  1. Ensure cross-platform artifacts are not accidentally included in published sdists so stale binaries from one platform don't end up
    triggering the skip on another.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions