ambuda-org / vidyut

Infrastructure for Sanskrit software. For Python bindings, see `vidyut-py`.
48 stars 21 forks source link

prakriya demo: Set up instructions #32

Closed shreevatsa closed 1 year ago

shreevatsa commented 1 year ago

I tried to work on the demo web app, but things are broken:

➜  ~/w/ambuda/vidyut/vidyut-prakriya git:(main) βœ— make debugger 
wasm-pack build --target web
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: πŸŒ€  Compiling to Wasm...
    Finished release [optimized + debuginfo] target(s) in 0.05s
[INFO]: License key is set in Cargo.toml but no LICENSE file(s) were found; Please add the LICENSE file(s) to your project directory
[INFO]: ⬇️  Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: ✨   Done in 0.96s
[INFO]: πŸ“¦   Your wasm pkg is ready to publish at /Users/shreevatsa/w/ambuda/vidyut/vidyut-prakriya/pkg.
cp pkg/* www/static/wasm
cp: www/static/wasm is not a directory
make: *** [debugger] Error 1

After creating that directory:

➜  ~/w/ambuda/vidyut/vidyut-prakriya git:(main) βœ— mkdir -p www/static/wasm
➜  ~/w/ambuda/vidyut/vidyut-prakriya git:(main) βœ— make debugger           
wasm-pack build --target web
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: πŸŒ€  Compiling to Wasm...
    Finished release [optimized + debuginfo] target(s) in 0.05s
[INFO]: License key is set in Cargo.toml but no LICENSE file(s) were found; Please add the LICENSE file(s) to your project directory
[INFO]: ⬇️  Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: ✨   Done in 0.97s
[INFO]: πŸ“¦   Your wasm pkg is ready to publish at /Users/shreevatsa/w/ambuda/vidyut/vidyut-prakriya/pkg.
cp pkg/* www/static/wasm
cp data/* www/static/data
cp: www/static/data is not a directory
make: *** [debugger] Error 1

Ok, creating that one too:

➜  ~/w/ambuda/vidyut/vidyut-prakriya git:(main) βœ— mkdir -p www/static/data
➜  ~/w/ambuda/vidyut/vidyut-prakriya git:(main) βœ— make debugger           
wasm-pack build --target web
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: πŸŒ€  Compiling to Wasm...
    Finished release [optimized + debuginfo] target(s) in 0.05s
[INFO]: License key is set in Cargo.toml but no LICENSE file(s) were found; Please add the LICENSE file(s) to your project directory
[INFO]: ⬇️  Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: ✨   Done in 0.96s
[INFO]: πŸ“¦   Your wasm pkg is ready to publish at /Users/shreevatsa/w/ambuda/vidyut/vidyut-prakriya/pkg.
cp pkg/* www/static/wasm
cp data/* www/static/data
cd www && source env/bin/activate && python app.py
/bin/sh: env/bin/activate: No such file or directory
make: *** [debugger] Error 1

Indeed there's no env/bin/activate inside www so maybe it needs to be done in the other order?

➜  ~/w/ambuda/vidyut/vidyut-prakriya git:(main) βœ— source env/bin/activate
(env) ➜  ~/w/ambuda/vidyut/vidyut-prakriya git:(main) βœ— cd www && python app.py
Traceback (most recent call last):
  File "/Users/shreevatsa/w/ambuda/vidyut/vidyut-prakriya/www/app.py", line 1, in <module>
    from flask import Flask, render_template
ModuleNotFoundError: No module named 'flask'

Maybe there needs to be a requirements.txt and all that, as this app is no longer just a standalone index.html file :-)

shreevatsa commented 1 year ago

(Seems to work after pip3 install flask and pip3 install indic_transliteration but not sure whether that's all that needed starting with a clean system…)

shreevatsa commented 1 year ago

Oh actually I see there's already a requirements.txt file. Will add it to the Makefile.

shreevatsa commented 1 year ago

(Wondering why the Python app exists, BTW? It looks like it does transliteration on the backend, but I'm confused because (1) it could be done in the frontend, and also (2) I thought GithHub pages only serves static content? Actually now I see https://github.com/ambuda-org/ambuda-org.github.io/tree/master/vidyullekha and I'm confused whether the app is supposed to be worked on this repo or there.)

shreevatsa commented 1 year ago

I see https://github.com/ambuda-org/ambuda-org.github.io/blob/master/build.sh which clears it up, somewhat.

shreevatsa commented 1 year ago

The change to the Makefile in https://github.com/ambuda-org/vidyut/pull/33 should help with the errors in the initial comment.

akprasad commented 1 year ago

Wondering why the Python app exists, BTW?

Mainly so I can use Jinja's macro tag to better organize the HTML for the demo, since it's quite complex. GitHub pages is indeed just serving a static file.

akprasad commented 1 year ago

Closing since this has improved. I'm also resolving a wasm-pack issue that @vipranarayan14 mentioned.