wasmer-python
wasmer-python copied to clipboard
The `wasmer_compiler_cranelift` package doesn't work on M1
Describe the bug
Trying to import the wasmer_compiler_cranelift
library (or any of the compilers) on an M1 will unconditionally trigger an ImportError
.
https://github.com/wasmerio/wasmer-python/blob/854ecacbf5026a767cb82e98dfe517b8d2e32f1a/packages/any-api/wasmer/init.py#L1
CC: @ayys
possible duplicate of #539
I was able to get wasmer running from python on my M1.
uname -a
Darwin Micu.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103 arm64
Previously, I was getting this error
In [1]: import wasmer
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import wasmer
File /opt/homebrew/lib/python3.10/site-packages/wasmer/__init__.py:1, in <module>
----> 1 raise ImportError("Wasmer is not available on this system")
ImportError: Wasmer is not available on this system
Using my locally compiled version of this repo, I can now import wasmer.
In [1]: import wasmer
In [2]: wasmer.Store
Out[2]: Store
To get this running, I went through the development setup guide in readme, except I made the following change
diff --git a/justfile b/justfile
index 22742a3..c2823d3 100644
--- a/justfile
+++ b/justfile
@@ -65,7 +65,7 @@ build package='api' rust_target=`rustc -vV | awk '/^host/ { print $2 }'`:
cd packages/{{package}}/
- maturin develop --binding-crate pyo3 --release --strip --cargo-extra-args="${build_args}"
+ maturin develop --binding-crate pyo3 --release --strip
# Build all the wheels.
build-all-wheels python_version rust_target:
If I keep the --cargo-extra-args
flag, I get the following error when running just build api
just build api
Build arguments: --target aarch64-apple-darwin
error: Found argument '--cargo-extra-args' which wasn't expected, or isn't valid in this context
If you tried to supply `--cargo-extra-args` as a value rather than a flag, use `-- --cargo-extra-args`
USAGE:
maturin develop --bindings <BINDINGS> --release --strip
For more information try --help
error: Recipe `build` failed with exit code 2
Hmm... it's really strange that everything worked after you recompiled. We've committed Cargo.lock
, so it's not like cargo
is using a different version of wasmer
.
I'm not too familiar with how the wasmer
package figures out which compiler to use, but I'm guessing a good place to start would be finding that logic, and in particular what makes it fall back to importing any-api
.
That --cargo-extra-args
thing is probably a red herring. From their changelog, it seems like --cargo-extra-args
was removed in Maturin 0.13.0.
I am seeing the same issue on M1.
- Saw the same error after doing
import wasmer
- Followed the instruction to compile and then no error after doing
import wasmer
.
Actually, according to README, Darwin + arm64 is not yet supported which makes sense for error.
I just tried installing wasmer-python 1.2.0 directly from master. It seems to work fine on my M2 machine.
Can we expect a release soon? @ayys
seems to work with python version 3.9 on Apple M1