Skip to content

publish: build pycvc/pycvc-gl with the cvcpkg SWIG only; version-independent scene_reader.open_verified - #523

Merged
transfix merged 2 commits into
masterfrom
fix/publish-pycvc-hermetic-swig
Oct 2, 2026
Merged

transfix merged 2 commits into
masterfrom
fix/publish-pycvc-hermetic-swig

Conversation

@transfix

@transfix transfix commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Breakage: since #511 (pycvc LOD bindings) the native publish (publish-cvcpkg.yml) failed on its required Linux x86_64 lanes (runs 36916445101 at cvc.14 and 36946706107 at cvc.15), so Linux x86_64 libcvc/pycvc did not publish at cvc.14/15:

Found SWIG: /usr/bin/swig4.0 (found suitable version "4.0.2" ...)
pycvcPYTHON_wrap.cxx:92180: error: use of deleted function 'cvc::lod::scene_reader::scene_reader(const cvc::lod::scene_reader&)'

Root cause: the build job never installed the cvcpkg swig (only build-cuda did), so CMake's FindSWIG picked the runner image's /usr/bin/swig4.0 — FindSWIG searches versioned names (swig4.0, …) in every directory before a plain swig, so even a cvcpkg prefix on CMAKE_PREFIX_PATH would lose. SWIG 4.0.2 copies by-value results (new T(static_cast<const T&>(result))), which the move-only scene_reader returned by scene_reader::open_verified cannot do. This also violated the hermetic-toolchain rule (CI build tools come from cvcpkg only).

Fix:

  • New composite action .github/actions/install-cvcpkg-swig: installs swig from the cvcpkg catalog (no source fallback), finds exactly one share/swig/<ver>, requires 4.4.x, exports CVC_SWIG_EXECUTABLE / SWIG_LIB / CVC_SWIG_VERSION.
  • publish-cvcpkg.yml: every lane that builds bindings (Linux cp311/312/313 + arm64, Windows when windows_pycvc, the CUDA job — now via the shared action) installs it and passes -DSWIG_EXECUTABLE -DSWIG_DIR -DCVC_PYCVC_REQUIRE_SWIG_VERSION to every pycvc / pycvc-gl configure; each refuses to run if they are unset. Windows steps check cmake exit codes.
  • bindings/pycvc/CMakeLists.txt: optional CVC_PYCVC_REQUIRE_SWIG_VERSION guard (asks the executable itself, so a reused build dir cannot vouch for a different binary); a plain swig in the CMake prefixes is preferred over system versioned names; SWIG_DIR derived beside the executable, failing if several versions are present; the SWIG in use is always printed.
  • pycvc_lod.i: scene_reader.open_verified is an %extend static factory returning a Python-owned heap scene_reader (same Python name/signature, bytes handling, GIL release, keep-alive), independent of any SWIG's move support. Audit: no other non-copyable by-value return in pycvc/pycvc_gl (the SwigValueWrapper types on that path are all copyable).
  • test_pycvc_lod.py: readers are Python-owned and keep their app alive.

Release impact: the previously published Linux pycvc-cp31X / pycvc-gl packages were generated by SWIG 4.0.2 (runtime v4); from this publish on they are generated by the cvcpkg SWIG 4.4.1 (runtime v5). Downstream %import consumers (vrhost and any out-of-tree bindings) must be rebuilt with the cvcpkg swig 4.4.1 to share the runtime (grep -ao swig_runtime_data[0-9] on each .so).

Verification: locally with the cvcpkg swig 4.4.1 only: pycvc + pycvc_gl build, pycvc_lod / pycvc_gl_lod pass (30/33 binding tests; the 3 failures are local config — mesher/SDF off, no yaml-cpp — identical on master); the generated wrapper makes no copy of scene_reader; the version guard passes for 4.4 and fails for 4.5 in a reused build dir. Workflow YAML checked by parse + bash -n + shellcheck of every bash step. Not yet run on GitHub — after merge, a dry_run=true windows_pycvc=true publish_cuda=true dispatch will confirm every lane before the real publish. Independently reviewed (adversarial): ship; its low findings are addressed in the second commit.

…_reader copy

The Linux pycvc-cp311/312/313 lanes of publish-cvcpkg have failed since the
LOD bindings (#511) landed (runs 36916445101 at +cvc.14, 36946706107 at
+cvc.15):

    pycvcPYTHON_wrap.cxx: use of deleted function
      'cvc::lod::scene_reader::scene_reader(const cvc::lod::scene_reader&)'

The `build` job never installed a swig, so CMake found the image's
/usr/bin/swig4.0 (SWIG 4.0.2). FindSWIG asks find_program for the versioned
names (swig4.0, ...) before a plain `swig`, and find_program tries one name in
every directory before the next, so a distro swig4.0 wins even over a prefix
swig on CMAKE_PREFIX_PATH. SWIG < 4.1 boxes a by-value return of a type with
no public default ctor as `new T(static_cast<const T&>(result))`, a copy that
the move-only scene_reader (static open_verified factory) cannot make.

Workflow (hermetic toolchain: SWIG comes from cvcpkg, never the image):
* New composite action .github/actions/install-cvcpkg-swig: `cvcpkg install
  swig` into a host-tools prefix (no source fallback), locate
  share/swig/<ver>, verify `swig -version` is 4.4.x, and export
  CVC_SWIG_EXECUTABLE, SWIG_LIB (mandatory: the packaged binary bakes its
  builder's dead -swiglib) and CVC_SWIG_VERSION.
* build job: install it for every lane that builds bindings (linux release,
  incl. the cp312/cp313 columns and the experimental arm64 lane; windows
  release behind windows_pycvc). Placed after the libcvc publish so a swig
  problem cannot block libcvc/cvcgl.
* build-cuda: the inline swig step is replaced by the same action.
* Every bindings configure (pycvc + pycvc-gl, CPU linux, CPU windows, CUDA
  linux) passes -DSWIG_EXECUTABLE, -DSWIG_DIR and
  -DCVC_PYCVC_REQUIRE_SWIG_VERSION, refuses to start without them, and only
  runs when the swig step succeeded. The windows step now also checks each
  cmake exit code (pwsh does not stop on a failing native command).

bindings/pycvc/CMakeLists.txt:
* CVC_PYCVC_REQUIRE_SWIG_VERSION (default empty = unchanged behaviour): any
  other SWIG is a FATAL configure error. The found SWIG is always logged.
* Without -DSWIG_EXECUTABLE, a `swig` in a CMAKE_PREFIX_PATH prefix is taken
  before FindSWIG searches the system, and its share/swig/<ver> becomes
  SWIG_DIR, so a cvcpkg prefix (e.g. a recipe's CVC_DEPS_PREFIX) can no
  longer lose to a distro swig4.0.

pycvc_lod.i: scene_reader.open_verified no longer depends on how a SWIG
version boxes by-value returns. The header's static by-value factory is
%ignore'd and an %extend static factory, renamed to the same Python name
with the same arguments, returns `new scene_reader(open_verified(...))`
(constructed from the prvalue: no copy, no move) under %newobject. The
bytes-like typemap, GIL release, OSError/RuntimeError mapping and the
%pythonappend app keep-alive all apply to it; the generated Python proxy is
unchanged. test_pycvc_lod asserts every reader is Python-owned and keeps
its app alive.

Audit: in the 4.4.1-generated pycvc and pycvc_gl wrappers (also with
CVC_USING_CUDA / CVC_ENABLE_MESHER / CVC_PYCVCGL_VTK_BRIDGE defined), the
only types still held in SwigValueWrapper (the path SWIG < 4.1 copies) are
cvc::volume, std::vector<unsigned char> and std::allocator<...>, all
copy-constructible; scene_reader was the only non-copyable one.
…IG_DIR

From review of the hermetic-swig fix:
- CVC_PYCVC_REQUIRE_SWIG_VERSION now runs `${SWIG_EXECUTABLE} -version` itself.
  FindSWIG caches SWIG_VERSION and does not re-query when SWIG_EXECUTABLE
  changes in a reused build directory, so the guard could vouch for a binary
  other than the one generating the wrappers.
- The SWIG_DIR fallback beside the executable fails when share/swig holds
  several versions instead of pairing the binary with the first one found.
@transfix
transfix merged commit 48091b8 into master Oct 2, 2026
13 checks passed
transfix added a commit that referenced this pull request Oct 2, 2026
…ext)

Every cvcGL test that renders through a GL context now takes the CTest
resource lock cvcgl_gl_context, so ctest never runs two of them at once;
the 23 headless tests (listed by name) keep running in parallel. The lock
is assigned by exclusion -- every test in the directory minus the headless
list -- so a GL test added later is locked unless someone lists it as
headless.

Why: on the macOS runners every failed attempt of cvcgl_shadow_casters
(4 of the 12 attempts across the 8 package-macos jobs of #521-#523) ran
alongside cvcgl_shadow_caster_growth and other GL tests under ctest
--parallel; no passing attempt overlapped growth, and each retry passed.
That is a correlation, not a reproduction -- no Mac reproduced the flake.

On every platform, on purpose: the cost is wall time only. On macOS Debug
the GL tests' own times summed to ~370 s (cvcgl_volren_node 230 s of it)
where they overlapped into ~250 s, so that ctest step can grow by up to
~2 minutes of ~9.
transfix added a commit that referenced this pull request Oct 2, 2026
…ext)

Every cvcGL test that renders through a GL context now takes the CTest
resource lock cvcgl_gl_context, so ctest never runs two of them at once;
the 23 headless tests (listed by name) keep running in parallel. The lock
is assigned by exclusion -- every test in the directory minus the headless
list -- so a GL test added later is locked unless someone lists it as
headless.

Why: on the macOS runners every failed attempt of cvcgl_shadow_casters
(4 of the 12 attempts across the 8 package-macos jobs of #521-#523) ran
alongside cvcgl_shadow_caster_growth and other GL tests under ctest
--parallel; no passing attempt overlapped growth, and each retry passed.
That is a correlation, not a reproduction -- no Mac reproduced the flake.

On every platform, on purpose: the cost is wall time only. On macOS Debug
the GL tests' own times summed to ~370 s (cvcgl_volren_node 230 s of it)
where they overlapped into ~250 s, so that ctest step can grow by up to
~2 minutes of ~9.
@transfix
transfix deleted the fix/publish-pycvc-hermetic-swig branch October 29, 2026 20:53
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