-
Notifications
You must be signed in to change notification settings - Fork 778
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
Generate python3.dll
import libraries for Windows targets in the build script
#2231
Comments
See also PyO3/maturin#830 |
I'm also open for integrating it into maturin. It should be doable. |
I'm happy for it to go in either place. You might find it a bit easier to put it in |
Thanks! I'll try to go with |
Automatically generate `python3.dll` import libraries for Windows compile targets in the build script. Adds a new PyO3 crate feature `auto-abi3-import-lib` enabling automatic import library generation. Closes PyO3#2231
Automatically generate `python3.dll` import libraries for Windows compile targets in the build script. Adds a new PyO3 crate feature `generate-abi3-import-lib` enabling automatic import library generation. Closes PyO3#2231
Automatically generate `python3.dll` import libraries for Windows compile targets in the build script. Adds a new PyO3 crate feature `generate-abi3-import-lib` enabling automatic import library generation. Closes PyO3#2231
on Windows targets. see PyO3/pyo3#2231 for more info
on Windows targets. see PyO3/pyo3#2231 for more info
Automatically generate `python3.dll` import libraries for Windows compile targets in the build script. Adds a new PyO3 crate feature `generate-abi3-import-lib` enabling automatic import library generation. Closes PyO3#2231
I'm routinely cross-compiling Python extension modules for Windows from a Linux host using the well-supported
x86_64-pc-windows-gnu
rustc target. The main issue I'm having is finding a suitablepython3.dll
import library (forabi3
extensions) to use withPYO3_CROSS_LIB_DIR
.MinGW and MSVC compilers use incompatible import library object formats, so downloading a Windows Python distribution does not work, and compiling Python with MinGW compiler is not supported by the upstream and requires about a hundred patches to work.
I've been working around this by using shell scripts to generate the MinGW-compatible
python3.dll
import library usingdlltool
from MinGW binutils. Luckily, the CPython project maintains a list of the stable ABI symbols in a machine-readable format, which can be used to generate a DLL module definition (.def) file and the DLL import library from it.A few weeks ago I decided to ditch the shell script hacks and package everything into a self-contained Rust crate called
python3-dll-a
. I'm currently using it in my own projects viabuild.rs
, and the Windows cross-compile command is just this (no Windows Python files required):Ideally, I'd like to integrate it into
pyo3-build-config
, so that cross-compilingabi3
extension modules for Windows would just work out of the box without messing with anyPYO3_CROSS*
environment variables. This should be already the case for Unix-like platforms where linking extension modules does not require a Python shared library.The current
python3-dll-a
version can generatepython3.dll
import libraries forx86_64-pc-windows-gnu
,i686-pc-windows-gnu
,x86_64-pc-windows-msvc
,i686-pc-windows-msvc
andaarch64-pc-windows-msvc
compile targets and can support both cross and native compilation setting. As a limitation of this approach, targeting the-msvc
environment ABI requires LLVM binutils to be installed on the compile host.If there is an interest in integrating this solution, I can start working on a PR for PyO3.
This will be feature-gated at the
pyo3
crate level, of course.The text was updated successfully, but these errors were encountered: