wasmerio / wasmer

🚀 The leading Wasm Runtime supporting WASIX and WASI
https://wasmer.io
MIT License
18.97k stars 812 forks source link

Something error with the standard library of package `python/python@0.2.0` #5251

Open miraclejzd opened 3 hours ago

miraclejzd commented 3 hours ago

Describe the bug

I am trying to run a python application which uses module couchdb with the module errno as the dependency. When I try to run the package locally, it turns out the error AttributeError: module 'errno' has no attribute 'EHOSTDOWN'. Did you mean: 'ENETDOWN'?

Is there something wrong with the standard library of package python/python@0.2.0

$ wasmer -vV; rustc -vV

wasmer 5.0.0 (49b1fcc 2024-10-29)
binary: wasmer-cli
commit-hash: 49b1fcc98e739b4cf5b9d6200397a472d9233de9
commit-date: 2024-10-29
host: x86_64-unknown-linux-gnu
compiler: singlepass,cranelift,llvm
c_api backend: 
rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.6

Steps to reproduce

  1. run the command wasmer run python/python@0.2.0 to enter the interactive shell.
  2. run the command import errno to import the module
  3. run the command print(errno.EHOSTDOWN) to get the error message

Expected behavior

No error.

Actual behavior

The output will be as follow:

$ wasmer run python/python@0.2.0
Type "help", "copyright", "credits" or "license" for more information.
>>> import errno
>>> print(errno.EHOSTDOWN)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'errno' has no attribute 'EHOSTDOWN'. Did you mean: 'ENETDOWN'?
>>> 

Additional context

None.

maminrayej commented 3 hours ago

I guess CPython source code detects whether EHOSTDOWN is defined on the target system or not. Since we do not define it in the wasix-libc, it won't be included in the final compiled errno module.

miraclejzd commented 2 hours ago

That's really a bad news. So it means all the applications that use errno.EHOSTDOWN will not work?

maminrayej commented 2 hours ago

Unfortunately no. The solution is simple though. We could include the definition in the libc, if it makes sense, and recompile python and re-publish the package. I'll discuss this with the team.

Thanks for reporting the issue.