spin icon indicating copy to clipboard operation
spin copied to clipboard

hello-python not working

Open abzou7275 opened this issue 1 year ago • 12 comments

  • Spin version (spin --version) spin 2.6.0 (a4ddd39 2024-06-20)
  • Installed plugin versions (spin plugins list --installed) No plugins found

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)

abzou7275 avatar Jun 25 '24 16:06 abzou7275

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

calebschoepp avatar Jun 25 '24 16:06 calebschoepp

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 avatar Jun 25 '24 17:06 dicej

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.

dicej avatar Jun 25 '24 17:06 dicej

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.

alanzou avatar Jun 25 '24 17:06 alanzou

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.

dicej avatar Jun 25 '24 17:06 dicej

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)

alanzou avatar Jun 25 '24 17:06 alanzou

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

dicej avatar Jun 25 '24 17:06 dicej

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

dicej avatar Jun 25 '24 17:06 dicej

yes, I am using componentize-py 0.13.4

alanzou avatar Jun 25 '24 17:06 alanzou

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

dicej avatar Jun 25 '24 18:06 dicej

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 avatar Jun 25 '24 18:06 dicej

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

dicej avatar Jun 25 '24 20:06 dicej

I believe we've now verified the fix with another user - is it okay to close this issue?

itowlson avatar Jul 19 '24 01:07 itowlson