fermyon / spin

Spin is the open source developer tool for building and running serverless applications powered by WebAssembly.
https://developer.fermyon.com/spin
Apache License 2.0
5.04k stars 242 forks source link

hello-python not working #2600

Open abzou7275 opened 1 week ago

abzou7275 commented 1 week ago

When I tried to build hello-python on my windows machine:

Building component hello-python with componentize-py -w spin-http componentize app -o app.wasm Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "D:\miniconda3\envs\spin\Scripts\componentize-py.exe__main__.py", line 7, in AssertionError: no WIT files found; please specify the directory or file containing the WIT world you wish to target

Caused by: 0: failed to read file "wit" 1: The system cannot find the file specified. (os error 2) Error: Build command for component hello-python failed with status Exited(1)

calebschoepp commented 1 week ago

CC @dicej might have more context about an issue like this.

dicej commented 1 week ago

Hi @abzou7275! I'm having trouble finding a hello-python example in either this repo or the spin-python-sdk repo. I also can't find a template with that name. Where did you get it from?

BTW, this is a good place to start if you're new to using Python with Spin: https://developer.fermyon.com/spin/v2/python-components

And since it looks like you're using Windows, please make sure you use componentize-py 0.13.4, which includes a recent fix for building components on Windows.

dicej commented 1 week ago

Ah, perhaps you're following the Python directions on https://developer.fermyon.com/spin/v2/quickstart ? If so, did you make sure to follow all the steps, including the pip3 install -r requirements.txt one? If so, and you're still having issues, please post a complete list of the steps you took from the beginning, and I'll try to reproduce the issue.

alanzou commented 1 week ago

I followed exact steps in the quick start https://developer.fermyon.com/spin/v2/quickstart. Except I used conda to create the virtual env. I tested in two windows machines, all have the same issue.

dicej commented 1 week ago

Would you mind trying it using python3 -m venv venv to create the virtual env? componentize-py doesn't know how to discover the site-packages directory in a conda-based venv, so I imagine that's the problem.

alanzou commented 1 week ago

Now, I am getting different error.

(venv) D:\project-spin\hello-python>spin build Building component hello-python with componentize-py -w spin-http componentize app -o app.wasm Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "D:\project-spin\hello-python\venv\Scripts\componentize-py.exe__main__.py", line 7, in AssertionError:

Caused by: ModuleNotFoundError: No module named 'spin_sdk\wit' Error: Build command for component hello-python failed with status Exited(1)

dicej commented 1 week ago

Can you double-check you're using componentize-py 0.13.4 by running componentize-py --version?

dicej commented 1 week ago

I'll try to repro this once I have access to a Windows machine later today.

alanzou commented 1 week ago

yes, I am using componentize-py 0.13.4

dicej commented 1 week ago

I was able to reproduce this; will debug and report back when I have a fix. Thanks for reporting it!

dicej commented 1 week ago

This fixes it: https://github.com/bytecodealliance/componentize-py/pull/95

I'll upload a new release once that's merged and CI finishes.

dicej commented 1 week ago

A 0.13.5 release is available with the fix. Please let me know if that works for you.