python: make the feature's test harness build, link and run (ibx#381) - #393
Open
userFRM wants to merge 1 commit into
Open
python: make the feature's test harness build, link and run (ibx#381)#393userFRM wants to merge 1 commit into
userFRM wants to merge 1 commit into
Conversation
No Rust-side test under the `python` feature had ever run. The harness failed in two stages, and `cargo check --lib --features python` passes, which is why neither was visible. It did not compile: a test called `EWrapper::new()` with no arguments, and the PyO3 constructor takes the tuple and dict it is handed from Python, so that call had been wrong since the signature was introduced. It then did not link. `extension-module` tells PyO3 not to link libpython, which is correct for the wheel and wrong for a test binary — every Python symbol came back undefined. The feature is split so the wheel asks for both and a test build asks only for `python`; `pyproject.toml` passes the pair. Linking is not enough on its own: the loader has to find the library at run time. A build script emits the interpreter's own library directory as an rpath, and only for a build that is not the extension module, so the wheel is untouched. `cargo test --features python` now needs no environment set up around it. Two tests were waiting to run and did not pass. `contract_default_values` asserted ibapi's empty contract defaults, while this crate presents `STK`, `SMART` and `USD` — the values its own constructor signature declares. The test is corrected to the defaults the code actually has. The stale wrapper test is replaced by one that asserts what the type presents to a subclass, which is the thing worth pinning: the callback methods a consumer overrides. That the type is constructible is what the compiler already checks. Closes deepentropy#381.
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.
Problem
No Rust-side test under the
pythonfeature had ever run. The harness failed in two stages, andcargo check --lib --features pythonpasses, which is why neither was visible.It did not compile. A test called
EWrapper::new()with no arguments; the PyO3 constructor takes the tuple and dict it is handed from Python, so that call had been wrong since the signature was introduced.It then did not link.
extension-moduletells PyO3 not to link libpython — correct for the wheel, wrong for a test binary. Every Python symbol came back undefined.What this changes
The feature is split: the wheel asks for
python,extension-module(set inpyproject.toml), a test build asks only forpython.Linking is not enough on its own — the loader has to find the library at run time. A build script emits the interpreter's own library directory as an rpath, and only for a build that is not the extension module, so the wheel is untouched.
cargo test --features pythonnow needs nothing set up around it.Two tests were waiting to run, and did not pass
contract_default_valuesasserted ibapi's empty contract defaults, while this crate presentsSTK,SMARTandUSD— the values its own#[new]signature declares. Corrected to the defaults the code actually has.The stale wrapper test is replaced by one asserting what the type presents to a subclass: the callback methods a consumer overrides. That the type is constructible is what the compiler already checks.
Result
cargo test --offline --lib --features python— 818 passed, with only the two knownconfig::expiry_teststzdata failures. Previously that command did not produce a binary at all.Verified that the wheel configuration (
--features python,extension-module) still builds the cdylib, and that a default build is unaffected.Closes #381.