Skip to content

pysimlin: rebuilding the extension by hand can keep a stale libsimlin.a #682

Open

Description

@bpowers

After a Rust-only change rebuilds libsimlin.a, rebuilding the pysimlin extension with python setup.py build_ext --inplace can report it is up to date and keep the extension linked against the old archive.
Python tests then run against the old engine, with no error.
The extension should relink whenever libsimlin.a changes.

Example

  1. Change engine behavior, run cargo build --release in src/libsimlin.
  2. In src/pysimlin: rm -f simlin/_clib.abi3.so && uv run python setup.py build_ext --inplace.
  3. Tests still show the old behavior; only build_ext --force picks up the change.

Seen by hand while validating an engine change through pysimlin.

Why it matters

The pre-commit hook and CI are not affected: scripts/pysimlin-tests.sh compares the archive's mtime with the .so, deletes build/, and pins the archive with SIMLIN_STATIC_LIB.
The hazard is the manual flow (DEVELOPMENT.md, make dev), where a developer can believe an engine change was checked through Python when it was not.

Fix

The archive is passed to cffi as extra_objects, which setuptools does not treat as a dependency of the extension.
Also pass it as depends=[...] in ffibuilder.set_source (a standard setuptools Extension argument) so setuptools relinks when the archive is newer.
Whether uv sync reuses a cached build in the same way is unverified; if it does, [tool.uv] cache-keys in pyproject.toml can name the archive.

Pointers

  • src/pysimlin/simlin/_ffi_build.py (_get_library_path, set_source)
  • scripts/pysimlin-tests.sh (the hook's working staleness check)
  • src/pysimlin/DEVELOPMENT.md, src/pysimlin/Makefile

Activity

  1. added
    ci
    on Jun 8, 2026
  2. changed the title [-]build/pysimlin: CFFI extension rebuild silently reuses a stale libsimlin.a (no static-lib dependency tracking)[/-] [+]pysimlin: rebuilding the extension by hand can keep a stale libsimlin.a[/+] on Oct 12, 2026
  3. added
    bug
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugci

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions