singlestore-labs / python-wasi

Utilities for building CPython for the WASI platform
Apache License 2.0
96 stars 14 forks source link

No module named 'math' #7

Closed Tails closed 2 years ago

Tails commented 2 years ago

I'm trying to prepare the Docker image but I'm getting stuck in the run.sh step. It seems the compilation of one of the core libs is failing. Is there pre-configured Docker image available, or a specific Python commit that for sure can be used?

CHECKOUT_PATH=/tmp/python-wasi

checkout:
    -git clone https://github.com/singlestore-labs/python-wasi/ ${CHECKOUT_PATH}

docker-build: checkout
    cd ${CHECKOUT_PATH} && \
    docker build \
        -f docker/Dockerfile \
        -t wasi-build:latest docker

docker-init:
    docker run \
            -it \
            -v ${CHECKOUT_PATH}:/app \
            -w /app \
        wasi-build:latest \
        bash -c "./run.sh"
# stderr after running ./run.sh 
...
clang --target=wasm32-wasi   -z stack-size=524288 -Wl,--stack-first -Wl,--initial-memory=10485760   -o python.wasm Programs/python.o Modules/getbuildinfo.o Parser/token.o  Parser/pegen.o Parser/pegen_errors.o Parser/action_helpers.o Parser/parser.o Parser/string_parser.o Parser/peg_api.o Parser/myreadline.o Parser/tokenizer.o Objects/abstract.o Objects/boolobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/bytesobject.o Objects/call.o Objects/capsule.o Objects/cellobject.o Objects/classobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genericaliasobject.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/interpreteridobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/odictobject.o Objects/memoryobject.o Objects/methodobject.o Objects/moduleobject.o Objects/namespaceobject.o Objects/object.o Objects/obmalloc.o Objects/picklebufobject.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/unicodeobject.o Objects/unicodectype.o Objects/unionobject.o Objects/weakrefobject.o  Python/_warnings.o Python/Python-ast.o Python/Python-tokenize.o Python/asdl.o Python/ast.o Python/ast_opt.o Python/ast_unparse.o Python/bltinmodule.o Python/ceval.o Python/codecs.o Python/compile.o Python/context.o Python/dynamic_annotations.o Python/errors.o Python/frame.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getplatform.o Python/getversion.o Python/ceval_gil.o Python/hamt.o Python/hashtable.o Python/import.o Python/importdl.o Python/initconfig.o Python/marshal.o Python/modsupport.o Python/mysnprintf.o Python/mystrtoul.o Python/pathconfig.o Python/preconfig.o Python/pyarena.o Python/pyctype.o Python/pyfpe.o Python/pyhash.o Python/pylifecycle.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/pytime.o Python/bootstrap_hash.o Python/specialize.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/thread.o Python/traceback.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/pystrhex.o Python/dtoa.o Python/formatter_unicode.o Python/fileutils.o Python/suggestions.o Python/perf_trampoline.o Python/dynload_stub.o Python/dup2.o    Modules/config.o Modules/main.o Modules/gcmodule.o Modules/arraymodule.o  Modules/_asynciomodule.o  Modules/_bisectmodule.o  Modules/_contextvarsmodule.o  Modules/_csv.o  Modules/_heapqmodule.o  Modules/_json.o  Modules/_lsprof.o Modules/rotatingtree.o  Modules/_opcode.o  Modules/_pickle.o  Modules/_queuemodule.o  Modules/_randommodule.o  Modules/_struct.o  Modules/_typingmodule.o  Modules/_zoneinfo.o  Modules/audioop.o  Modules/mathmodule.o  Modules/cmathmodule.o  Modules/_statisticsmodule.o  Modules/_datetimemodule.o  Modules/_decimal/_decimal.o  Modules/binascii.o  Modules/_bz2module.o  Modules/_lzmamodule.o  Modules/zlibmodule.o  Modules/md5module.o  Modules/sha1module.o  Modules/sha256module.o  Modules/sha512module.o  Modules/_sha3/sha3module.o  Modules/_blake2/blake2module.o Modules/_blake2/blake2b_impl.o Modules/_blake2/blake2s_impl.o  Modules/pyexpat.o  Modules/_elementtree.o  Modules/cjkcodecs/_codecs_cn.o  Modules/cjkcodecs/_codecs_hk.o  Modules/cjkcodecs/_codecs_iso2022.o  Modules/cjkcodecs/_codecs_jp.o  Modules/cjkcodecs/_codecs_kr.o  Modules/cjkcodecs/_codecs_tw.o  Modules/cjkcodecs/multibytecodec.o  Modules/unicodedata.o  Modules/_cryptmodule.o  Modules/selectmodule.o  Modules/socketmodule.o  Modules/_sqlite/blob.o Modules/_sqlite/connection.o Modules/_sqlite/cursor.o Modules/_sqlite/microprotocols.o Modules/_sqlite/module.o Modules/_sqlite/prepare_protocol.o Modules/_sqlite/row.o Modules/_sqlite/statement.o Modules/_sqlite/util.o  Modules/xxsubtype.o  Modules/_xxtestfuzz/_xxtestfuzz.o Modules/_xxtestfuzz/fuzzer.o  Modules/_testbuffer.o  Modules/_testinternalcapi.o  Modules/_testcapimodule.o Modules/_testcapi/vectorcall.o Modules/_testcapi/vectorcall_limited.o Modules/_testcapi/heaptype.o Modules/_testcapi/unicode.o  Modules/atexitmodule.o  Modules/faulthandler.o  Modules/posixmodule.o  Modules/signalmodule.o  Modules/_tracemalloc.o  Modules/_codecsmodule.o  Modules/_collectionsmodule.o  Modules/errnomodule.o  Modules/_io/_iomodule.o Modules/_io/iobase.o Modules/_io/fileio.o Modules/_io/bytesio.o Modules/_io/bufferedio.o Modules/_io/textio.o Modules/_io/stringio.o  Modules/itertoolsmodule.o  Modules/_sre/sre.o  Modules/_threadmodule.o  Modules/timemodule.o  Modules/_weakref.o  Modules/_abc.o  Modules/_functoolsmodule.o  Modules/_localemodule.o  Modules/_operator.o  Modules/_stat.o  Modules/symtablemodule.o Python/deepfreeze/deepfreeze.o Modules/getpath.o Python/frozen.o -L/opt/lib -L/app/wasix -lwasix -L/opt/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi -lwasi-emulated-signal -L/app/docker/lib --sysroot=/opt/wasi-sdk/share/wasi-sysroot -lwasi-emulated-signal -lwasi-emulated-getpid -lwasi-emulated-process-clocks -lpthread                -lm -lm -lm -lm -lm -lm Modules/_decimal/libmpdec/libmpdec.a -lz -lbz2 -llzma -lz       -lm Modules/expat/libexpat.a             -lsqlite3                           -lm 
Traceback (most recent call last):
  File "/app/cpython/./Tools/build/check_extension_modules.py", line 25, in <module>
    import pathlib
  File "/app/cpython/Lib/pathlib.py", line 21, in <module>
    from urllib.parse import quote_from_bytes as urlquote_from_bytes
  File "/app/cpython/Lib/urllib/parse.py", line 32, in <module>
    import math
ModuleNotFoundError: No module named 'math'
make: *** [Makefile:1030: checksharedmods] Error 1
ERROR: No Python build was found.
kesmit13 commented 2 years ago

You could try checking out a specific version of Python in the clone (e.g., git checkout 3.11) rather than using the current state of the code.

Tails commented 2 years ago

I think this worked!

Would be good to optionally specify the branch name to clone/checkout using an ENV var in run.sh.

image
jgentes commented 1 year ago

To be clear for others who find this thread:

/python-wasi# cd cpython
/python-wasi/cpython# git checkout -b 3.11 origin/3.11
kesmit13 commented 1 year ago

The main branch issues should be fixed now (a799a658120b6826166ae19b31e357bcddeb327c).