-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: cleanup code #17
Conversation
While this change is technically correct, this also makes it impossible to build wheels for Windows by just adding Sadly, MinGW Python is not a thing since version 3.5. Since it is not supported by the upstream at all, it is not possible to publish and distribute wheels for it. Ideally, the standard Windows Python DLL name should be used when cross-compiling, and the MinGW one should be selected only when building things for the MinGW distribution on Windows, i.e. when What do you think? |
src/lib.rs
Outdated
if self.env == "msvc" { | ||
format!("python{}{}{}", major, minor, impllib_ext) | ||
} else { | ||
// https://packages.msys2.org/base/mingw-w64-python | ||
format!("python{}.{}{}", major, minor, impllib_ext) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need something less surprising for the users here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wonder whether this link is strictly necessary: I have been building extensions using MinGW but targeting the libraries from the MSVC-based upstream CPython releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I just noticed that you explained all of this in #17 (comment). Sorry for noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been building extensions using MinGW but targeting the libraries from the MSVC-based upstream CPython releases.
Same here actually 😅
At a first glance, this sounds reasonable to me. It should definitely be documented though as it does feel a bit brittle. |
Yes, this looks super convoluted, but it's my best guess wrt what the users would expect to get when they type |
Admittedly I don't quite understand the issue here since personally I don't build wheels using mingw64. I've checked locally on Ubuntu that this works with PyO3/pyo3#2364, all of the following commands succeeded # abi3
cargo build --manifest-path examples/maturin-starter/Cargo.toml --features abi3 --target x86_64-pc-windows-gnu
cargo xwin build --manifest-path examples/maturin-starter/Cargo.toml --features abi3 --target x86_64-pc-windows-msvc
# non-abi3
export PYO3_CROSS_PYTHON_VERSION=3.9
cargo build --manifest-path examples/maturin-starter/Cargo.toml --features generate-import-lib --target x86_64-pc-windows-gnu
cargo xwin build --manifest-path examples/maturin-starter/Cargo.toml --features generate-import-lib --target x86_64-pc-windows-msvc Another idea, can we change it to generate both |
I think the problem would manifest when loading such an extension using the official CPython builds under Windows (providing |
This will not work because on Windows, the import library name and the DLL library name do not actually have to match (crazy!). python3-dll-a/src/python39.def Line 6 in ac9a080
|
Yes, this is what I'm worrying about, given that 3 out of 4 commenters in this thread have been using the MinGW cross target to build Python wheels for Windows, not for MSYS2. I double checked and found out that the MSYS2 Python build actually provides https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=mingw-w64-python-bin#n54 On the up side, it looks like the distributions that use So my proposal here is to change the PyO3 defaults instead to always assume |
OK, I've repurposed this PR as a code cleanup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Done in PyO3/pyo3@ea37acb |
See https://github.com/PyO3/pyo3/blob/f5357f9395f8ac3632ad0e32ea4c0b2ea6a14b07/pyo3-build-config/src/impl_.rs#L1522-L1524