Fix local installation and wheel packaging (supersedes #59) - #77
Open
RewardGuard wants to merge 4 commits into
Open
Fix local installation and wheel packaging (supersedes #59)#77RewardGuard wants to merge 4 commits into
RewardGuard wants to merge 4 commits into
Conversation
The CMake/make build emits a generically named shared library (`libmagent.dylib` / `libmagent.so` / `magent.dll`), but setuptools expects the extension at the interpreter-specific path returned by `get_ext_fullpath()` (e.g. `magent2/libmagent.cpython-312-darwin.so`). Because nothing copied the build output to that path, `pip install -e .` failed with "can't copy ... doesn't exist" and wheels shipped without a loadable library. - setup.py: after the platform build, locate the produced library (handling multi-config generators) and copy it to `get_ext_fullpath(ext.name)`. Also raise on unsupported platforms instead of silently continuing. - c_lib.py: load the library from the same EXT_SUFFIX-based name, so the loader and the packaged file always agree across platforms. Verified on macOS: `pip install -e .`, `pip wheel .`, a fresh wheel install, and `pytest tests` (2 passed) all succeed. Supersedes Farama-Foundation#59. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Supersedes #59 (which had merge conflicts with
main). Rebased cleanly on currentmainand reworked so it is correct and verified on macOS as well as Linux/Windows.pip install -e .(and, in fact, wheel packaging) was broken: the CMake/make build emits a generically-named shared library (libmagent.dylib/libmagent.so/magent.dll), but setuptools expects the extension at the interpreter-specific path fromget_ext_fullpath()(e.g.magent2/libmagent.cpython-312-darwin.so). Nothing copied the build output there, so editable installs failed withcan't copy '.../libmagent.cpython-312-darwin.so': doesn't existand built wheels shipped without a loadable library.Changes
setup.py— after the platform-specific build, locate the produced library (via a small helper that also handles multi-config generators like MSVC'sRelease/subdir) and copy it toget_ext_fullpath(ext.name). Also raise on unsupported platforms instead of silently falling through.magent2/c_lib.py— load the library from the sameEXT_SUFFIX-based name (libmagent<EXT_SUFFIX>) on every platform, so the loader and the packaged file always agree. This removes the previous per-OS hard-coded filenames.Unlike #59, this works on macOS too: #59 loaded
libmagent.<SOABI>.dylibwhile setuptools produces a...darwin.sofile, so the names didn't match on macOS. Deriving both sides fromEXT_SUFFIXkeeps them consistent everywhere.Verification (macOS, CPython 3.12)
pip install -e .— succeeds, C library loads, environments run.pip wheel .— wheel containsmagent2/libmagent.cpython-312-darwin.so.pytest tests— 2 passed.Type of change
🤖 Generated with Claude Code