Skip to content

Upgrade to latest swig 4.1.1#1354

Merged
schaubh merged 8 commits into
developfrom
feature/swig_upgrade
Apr 13, 2026
Merged

Upgrade to latest swig 4.1.1#1354
schaubh merged 8 commits into
developfrom
feature/swig_upgrade

Conversation

@schaubh
Copy link
Copy Markdown
Contributor

@schaubh schaubh commented Apr 12, 2026

  • Tickets addressed: bsk-1201
  • Review: By commit
  • Merge strategy: Merge (no squash)

Description

This PR updates Basilisk test and build infrastructure for cleaner Python 3.14 support.

First, the branch updates SWIG dependency handling so Basilisk supports the latest working SWIG release. Local development requirements now allow current SWIG versions while explicitly excluding swig==4.4.0, which produced compile failures in testing. SWIG 4.4.1 was verified with a clean Basilisk build and unit test run. The canary CI requirements continue to use the latest available SWIG so future compatibility issues are detected early.

Second, this PR removes obsolete SWIG runtime warning suppression that was previously hiding Python warnings such as swigvarlink has no __module__ attribute. With SWIG 4.4.1, those warnings no longer appear in the clean build/test path, so the suppression is no longer needed.

Finally, this PR cleans up Python test-suite ResourceWarning messages observed when running pytest -n auto from src. The warnings were traced to pytest infrastructure rather than Basilisk simulation code. The SPICE thread-safety test now closes multiprocessing queue and process resources explicitly. The pytest configuration also closes the optional reportconf.py file handle after loading it.

The remaining socket warnings were isolated to the interaction between pytest-xdist and pytest-rerunfailures 16.1. Since there is not yet a newer released pytest-rerunfailures version that fixes this cleanup path, src/conftest.py now performs a narrow local cleanup: it closes the plugin-owned rerun status socket during pytest shutdown and wraps the plugin’s server-side connection handler so accepted sockets are closed when each handler exits.

The commits are organized by infrastructure topic: SWIG version support, removal of obsolete SWIG warning suppression, SPICE multiprocessing cleanup, pytest file-handle cleanup, and pytest-rerunfailures socket cleanup.

Verification

SWIG 4.4.1 was verified with a clean Basilisk build. The previous SWIG runtime warnings were not observed in the clean build log, and the unit tests completed successfully. SWIG 4.4.0 was tested separately and produced compile failures, so that specific version is excluded from the pinned development dependency range.

Validated the ResourceWarning cleanup with warning tracing enabled:

env PYTHONTRACEMALLOC=25 PYTHONWARNINGS=always::ResourceWarning .venv/bin/pytest -q src/simulation/environment/spiceInterface/_UnitTest/test_spiceThreadSafety.py

Also verified the full parallel test suite from src:

pytest -n auto
The full run completed without the previously reported unclosed socket ResourceWarning.

No new tests were added because these changes update build/test infrastructure cleanup behavior rather than Basilisk runtime behavior. Existing build and test coverage was used to confirm the changes.

Documentation

No user-facing Basilisk documentation was invalidated. This change affects developer/test infrastructure and SWIG dependency compatibility.

Reviewers should check the requirements updates, the removed SWIG warning suppression, src/conftest.py for the local pytest-rerunfailures socket cleanup shim, and src/simulation/environment/spiceInterface/_UnitTest/test_spiceThreadSafety.py for multiprocessing queue/process cleanup behavior.

Future work

If pytest-rerunfailures releases an upstream fix for closing its xdist coordination sockets, the local cleanup shim in src/conftest.py can be removed after updating the pinned dependency range.

@schaubh schaubh self-assigned this Apr 12, 2026
@schaubh schaubh added the build Build system or compilation enhancement label Apr 12, 2026
@schaubh schaubh requested a review from a team as a code owner April 12, 2026 17:19
@schaubh schaubh added this to Basilisk Apr 12, 2026
@schaubh schaubh moved this to 👀 In review in Basilisk Apr 12, 2026
@schaubh schaubh linked an issue Apr 12, 2026 that may be closed by this pull request
schaubh added 7 commits April 12, 2026 11:20
Removes some system wide swig warning suppressions
Update the canary requirements to install the latest available `swig` package instead of the previously pinned 4.3.1 range.

Also extend the shared build action's pip cache dependency paths to include the `.github/workflows` requirement files so canary dependency changes correctly invalidate the pip cache and are reflected in CI.
We now support swig 4.4.1 which eliminates the need for this.
This version had some regressions that caused the BSK build to fail.  This is fixed in swig 4.4.1
Add local pytest cleanup for ResourceWarning messages emitted when running the
test suite with pytest-xdist and pytest-rerunfailures.  The rerunfailures plugin
creates localhost sockets to coordinate rerun state between the xdist controller
and workers, but version 16.1 does not close all of those sockets before Python
interpreter shutdown.

Update src/conftest.py to close the plugin-owned failures_db socket during
pytest_unconfigure().  Also wrap pytest-rerunfailures ServerStatusDB connection
handling so accepted server-side sockets are closed when their handler exits.
This preserves rerunfailures behavior while preventing unclosed socket warnings
during parallel pytest runs.

Also keep reportconf.py loading inside a context manager so pytest-html report
configuration does not leave an open file handle.

Verified with:
- pytest -q -n 2 src/architecture/messaging/_UnitTest/test_CMsgTimeWritten.py
- pytest -q -n 2 src/simulation/environment/spiceInterface/_UnitTest/test_spiceThreadSafety.py
- pytest -n auto from src
@schaubh schaubh force-pushed the feature/swig_upgrade branch from 4541895 to 377e546 Compare April 12, 2026 17:23
schaubh added a commit that referenced this pull request Apr 12, 2026
@schaubh schaubh requested a review from ReeceHumphreys April 12, 2026 19:54
Copy link
Copy Markdown
Contributor

@ReeceHumphreys ReeceHumphreys left a comment

Choose a reason for hiding this comment

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

Looks good. For users on the bad swig version should we document anywhere that they should run pip install --upgrade swig to fix it? Maybe in the release notes?

@schaubh schaubh force-pushed the feature/swig_upgrade branch from 377e546 to bd4a7a5 Compare April 12, 2026 22:27
@schaubh schaubh merged commit 4f64aba into develop Apr 13, 2026
7 checks passed
schaubh added a commit that referenced this pull request Apr 13, 2026
Removes some system wide swig warning suppressions
schaubh added a commit that referenced this pull request Apr 13, 2026
Update the canary requirements to install the latest available `swig` package instead of the previously pinned 4.3.1 range.

Also extend the shared build action's pip cache dependency paths to include the `.github/workflows` requirement files so canary dependency changes correctly invalidate the pip cache and are reflected in CI.
@schaubh schaubh deleted the feature/swig_upgrade branch April 13, 2026 00:27
schaubh added a commit that referenced this pull request Apr 13, 2026
We now support swig 4.4.1 which eliminates the need for this.
schaubh added a commit that referenced this pull request Apr 13, 2026
This version had some regressions that caused the BSK build to fail.  This is fixed in swig 4.4.1
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Basilisk Apr 13, 2026
schaubh added a commit that referenced this pull request Apr 13, 2026
Add local pytest cleanup for ResourceWarning messages emitted when running the
test suite with pytest-xdist and pytest-rerunfailures.  The rerunfailures plugin
creates localhost sockets to coordinate rerun state between the xdist controller
and workers, but version 16.1 does not close all of those sockets before Python
interpreter shutdown.

Update src/conftest.py to close the plugin-owned failures_db socket during
pytest_unconfigure().  Also wrap pytest-rerunfailures ServerStatusDB connection
handling so accepted server-side sockets are closed when their handler exits.
This preserves rerunfailures behavior while preventing unclosed socket warnings
during parallel pytest runs.

Also keep reportconf.py loading inside a context manager so pytest-html report
configuration does not leave an open file handle.

Verified with:
- pytest -q -n 2 src/architecture/messaging/_UnitTest/test_CMsgTimeWritten.py
- pytest -q -n 2 src/simulation/environment/spiceInterface/_UnitTest/test_spiceThreadSafety.py
- pytest -n auto from src
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Build system or compilation enhancement

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

lots of swig warnings running pytest

2 participants