Closed UltraMachine closed 4 years ago
Sorry, I'm not sure it's possible now...
Hey is there any update on this one ?
I am trying to build a python library for windows with maturin using the same kind of setting by using cross : https://github.com/rust-embedded/cross
It is frustrating since the only problem is at link and normally everything is there.
I tried to pass some --rustc-extra-args="-l dylib=pythonXY:python38" to maturin in order to force the finding. But then maturin tell me I have no #[link(...)] in my crate, which is normal since it is pyo3 related and not user-defined crate related.
I have no insight how to make a workaround on that :/ and I want to avoid using travis and a windows vm. I prefer to stay in a full linux setting with cross-compilation for mac and win.
Do you have any advice for me to tweak something in my build setting or directly adding a feature in the code ?
@benoitbayol from what I read you're building a Python extension module, and have the extension_module
feature enabled?
In theory you shouldn't need linking at all for an extension module, so what pyo3 is doing here is definitely wrong. We have some open discussion around the extension_module
feature which I'd like to resolve soon - see #771 and #904
Maybe I will provide a patch later in the next week or so...
Yes I have extension_module.
A patch would be so great :)
@benoitbayol can you please have a go with https://github.com/PyO3/pyo3/pull/923 and let me know if this resolves your problem? Thanks.
Hey is there any updates on this? I'm having the same issue and it's really frustrating
@MahmoudFarouq can you try the branch in the PR I linked and let me know if that works for you?
@davidhewitt Just tried it now, didn't work. however, before the output contained
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lpythonXY
but now it's
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lpython3.6m
XY
became the python version.
Also notice i had to use a nightly build of rust.
This is my Cargo.toml
in case i'm doing something wrong
[dependencies]
pyo3 = { git = "https://github.com/davidhewitt/pyo3", branch = "fix-cross-compile" }
@MahmoudFarouq great, thanks for feedback. Can you please look in your PYO3_CROSS_LIB_DIR
and tell me the name of the python shared library in that directory? (I think it will be a .dll
file)
Also notice i had to use a nightly build of rust.
Ah yes that branch is quite old, I should probably rebase it π
@MahmoudFarouq great, thanks for feedback. Can you please look in your
PYO3_CROSS_LIB_DIR
and tell me the name of the python shared library in that directory? (I think it will be a.dll
file)
I don't have it set, can you please tell me to what should i set it?
I think it should should be the "libs" subdirectory of the w64-mingw32
Python install you're trying to link to with your cross-compile.
(There's a bit more detail on cross-compiling here: https://pyo3.rs/v0.11.1/building_and_distribution.html#cross-compiling)
A Python interpreter that's already been compiled for your target.
@davidhewitt I think this is what i'm missing, donno how to fix though.
TBH looking at https://wiki.python.org/moin/WindowsCompilers#GCC_-_MinGW-w64_.28x86.2C_x64.29 support for mingw might have stopped at Python 3.4?
Afraid I haven't tried to do this cross-compile myself, so also don't have any idea how you would get a suitable build of Python to link against with the mingw target.
What are you trying to do this cross-compile for? If it's to package a wheel to distribute for other users, then I think you want to be targeting windows-msvc
instead of windows-gnu
, because afaik most Python installs on windows are built against the msvc target.
FWIW, the python packaging docs suggest using Appveyor to build the package on a Windows host, rather than cross-compile (Github Actions also supports Windows hosts).
I didn't want to use windows and msvc because this would be a big install and setup for a really tiny package, but seems this is my only choice, Thanks man for your help :"D
π Bug Reports
When reporting a bug, please provide the following information. If this is not a bug report you can just discard this template.
π Environment
rustc --version
): 1.40.0-nightly (95f437b3c 2019-10-27)version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3")?
yesπ₯ Reproducing
I'm trying to compile this lib on linux for windows.
Running with
cargo build --release --target "x86_64-pc-windows-gnu" -v
, I'm getting this error: