Skip to content

Fix cargo test with extension-module feature. - #2135

Closed
aviramha wants to merge 1 commit into
PyO3:mainfrom
aviramha:rustc-link-arg-bins
Closed

Fix cargo test with extension-module feature. #2135
aviramha wants to merge 1 commit into
PyO3:mainfrom
aviramha:rustc-link-arg-bins

Conversation

@aviramha

@aviramha aviramha commented Jan 31, 2022

Copy link
Copy Markdown
Member

Fixes #1084
Fixes #771
Fixes #341
Fixes #340

@mejrs mejrs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That closes a lot of issues 🎉 Thanks for this.

Comment thread guide/src/faq.md Outdated
@davidhewitt

Copy link
Copy Markdown
Member

👍 thanks!

It would also be worth adding cargo test (and cargo run) n CI to one of the examples crates, so that we know this is working as expected!

@aviramha

aviramha commented Feb 1, 2022

Copy link
Copy Markdown
Member Author

Regarding current failure - in order to get Paramus I need interpreter config which currently is initialized only if derive configuration feature is enabled.
Not sure what's the best solution here..

@davidhewitt

Copy link
Copy Markdown
Member

add_extension_module_link_args should probably be #[cfg(feature = "resolve-config")] - and you can then pass &InterpreterConfig through to _add_extension_module_link_args.

@aviramha
aviramha force-pushed the rustc-link-arg-bins branch 4 times, most recently from 8aef9a0 to 9d1ffb1 Compare February 1, 2022 09:33
@aviramha
aviramha force-pushed the rustc-link-arg-bins branch from 9d1ffb1 to db53229 Compare February 1, 2022 09:54
@aviramha

aviramha commented Feb 1, 2022

Copy link
Copy Markdown
Member Author

Not sure about cargo run/test - they don't seem to have any. You suggest adding a sanity test there also and running it?

@davidhewitt

Copy link
Copy Markdown
Member

Yep exactly, can add something simple to prove it works 😊

@aviramha

aviramha commented Feb 1, 2022

Copy link
Copy Markdown
Member Author

I can't make an example fail on my setup for some reason (macOS, arm). Some help would be appreciated

@davidhewitt

Copy link
Copy Markdown
Member

See #2147

@aviramha

aviramha commented Feb 5, 2022

Copy link
Copy Markdown
Member Author

Thanks @davidhewitt. I can reproduce it using the example you made.
I'm now stuck at the compiler not letting it compile due to ignored flag -
invalid instructioncargo:rustc-link-arg-binsfrom build script ofmaturin-starter v0.1.0 (pyo3/examples/maturin-starter)The package maturin-starter v0.1.0 (maturin-starter) does not have a bin target.
I think we have to change the implementation on pyo3 build config to consider what it is compiling (test/binary). is that information available from a build script context tho?

@davidhewitt

Copy link
Copy Markdown
Member

Oh, yikes. I have to confess I don't know. Might be possible to extract it from the Cargo.toml?

@aviramha

aviramha commented Feb 5, 2022 via email

Copy link
Copy Markdown
Member Author

@adamreichold

Copy link
Copy Markdown
Member

But I don’t think we can extract what we’re compiling exactly?

Does checking the CARGO_BIN_NAME environment variable (whether it is empty or not) help with this?

@davidhewitt

Copy link
Copy Markdown
Member

I think we might be able to use CARGO_MANIFEST_DIR in conjunction with cargo metadata to figure out what the crate of the currently running build script contains (and maybe even which of those things depend on pyo3).

@007vasy

007vasy commented Mar 8, 2022

Copy link
Copy Markdown

when merge?

@aviramha

aviramha commented Mar 8, 2022

Copy link
Copy Markdown
Member Author

when merge?

The PR isn't ready yet because I didn't think it through enough. We need to find a way to set the flags only on specific builds, which isn't as easy as one would think. I'm currently swamped by work & life so if someone wants to keep this moving they're more than welcome.

@007vasy

007vasy commented Mar 8, 2022

Copy link
Copy Markdown

when merge?

The PR isn't ready yet because I didn't think it through enough. We need to find a way to set the flags only on specific builds, which isn't as easy as one would think. I'm currently swamped by work & life so if someone wants to keep this moving they're more than welcome.

no worries man, I don't have the expertise yet to help you out, I will try to figure out a workaround

@aviramha

Copy link
Copy Markdown
Member Author

I probably will never get back to it ;(

@aviramha aviramha closed this Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants