github.com/goplus/llgo@v0.8.3/py/README.md (about)

     1  Linking Python to Go
     2  =====
     3  
     4  TODO
     5  
     6  ## Demo
     7  
     8  The `_demo` directory contains our demos (it start with `_` to prevent the `go` command from compiling it):
     9  
    10  * [hellopy](_demo/hellopy/hello.go): link Python to Go and say `Hello world`
    11  * [clpy](_demo/clpy/cleval.go): compile Python code and eval.
    12  * [callpy](_demo/callpy/call.go): call Python standard library function `math.sqrt`.
    13  
    14  ### How to run demos
    15  
    16  To run the demos in directory `_demo`, you need to set the `LLGO_LIB_PYTHON` environment variable first. Assuming you use Python 3.12, and the `libpython3.12.so` (or `libpython3.12.dylib` or `python3.12.lib`) file is in the /foo/bar directory, then you need to set `LLGO_LIB_PYTHON` to:
    17  
    18  ```sh
    19  export LLGO_LIB_PYTHON=/foo/bar/python3.12
    20  ```
    21  
    22  For example, `/opt/homebrew/Frameworks/Python.framework/Versions/3.12/libpython3.12.dylib` is a typical python lib location under macOS. So we should set it like this:
    23  
    24  ```sh
    25  export LLGO_LIB_PYTHON=/opt/homebrew/Frameworks/Python.framework/Versions/3.12/python3.12
    26  ```
    27  
    28  Then you can run the demos in directory `_demo`:
    29  
    30  ```sh
    31  cd <demo-directory>  # eg. cd _demo/hellopy
    32  llgo run .
    33  ```