extism / cli

The extism CLI is used to generate plugin scaffolding and manage Extism installations
BSD 3-Clause "New" or "Revised" License
21 stars 7 forks source link

Error when running `extism call` #24

Closed k33g closed 1 year ago

k33g commented 1 year ago

Hello, I get an error when I run:

extism call ./simple.wasm \
  say_hello --input "Bob" \
  --wasi

Error:

Traceback (most recent call last):
  File "/home/k33g/.local/bin/extism", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/k33g/.local/lib/python3.11/site-packages/extism_cli/__init__.py", line 598, in main
    plugin = libextism.Plugin(manifest, wasi=args.wasi, config=config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/k33g/.local/lib/python3.11/site-packages/extism/extism.py", line 210, in __init__
    self.plugin = _lib.extism_plugin_new(
                  ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: initializer for ctype 'ExtismContext *' must be a cdata pointer, not bytes

Traceback (most recent call last):
  File "/home/k33g/.local/bin/extism", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/k33g/.local/lib/python3.11/site-packages/extism_cli/__init__.py", line 598, in main
    plugin = libextism.Plugin(manifest, wasi=args.wasi, config=config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/k33g/.local/lib/python3.11/site-packages/extism/extism.py", line 210, in __init__
    self.plugin = _lib.extism_plugin_new(
                  ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: initializer for ctype 'ExtismContext *' must be a cdata pointer, not bytes

My plugin is very simple:

package main

import (
    "github.com/extism/go-pdk"
)

//export say_hello
func say_hello() int32 {

    input := pdk.Input()
    output := "👋 (From Go) Hello " + string(input)
    mem := pdk.AllocateString(output)
    pdk.OutputMemory(mem)
    return 0
}

func main() {}

Extism info:

Prefix  /usr/local
Version v0.5.0
nilslice commented 1 year ago

This might be a Python SDK issue used by the CLI, being out of sync with libextism.

Can you try updating the Python SDK via:

pip install extism_cli --upgrade
k33g commented 1 year ago

same problem

but it's probably because of my linux setup (Ubuntu 23.04)

I need to install like this:

sudo apt-get install python3-pip -y

pip3 install poetry --break-system-packages
pip3 install git+https://github.com/extism/cli --break-system-packages
extism --prefix=/usr/local install latest
pip3 install extism --break-system-packages

pip3 install extism_cli --upgrade --break-system-packages

if I don't use --break-system-packages I get this:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
nilslice commented 1 year ago

Ok, interesting... we intend to ship a new CLI for our v1.0 release later this year -- and not in Python to help avoid some of this kind of packaging issue.

if I don't use --break-system-packages I get this

if you do use that flag, then you're able to install ok?

k33g commented 1 year ago

yes

I will wait for the new CLI (in the meantime I'm going to practice making one https://github.com/bots-garden/golab-demos/blob/main/minism/main.go#L74) 😄

nilslice commented 1 year ago

Awesome. I love the name!!!