diff --git a/README.md b/README.md index b56ccc7..bc0fec9 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ Python interpreter bindings for Deno. +## Example + +Import any locally installed Python package, for example, `matplotlib`: + ```ts import { python } from "https://deno.land/x/python@0.2.0/mod.ts"; @@ -20,6 +24,14 @@ plt.plot(xpoints, ypoints); plt.show(); ``` +When running, you **must** specify `--allow-ffi`, `--allow-env` and `--unstable` +flags. Alternatively, you may also just specify `-A` instead of specific +permissions since enabling FFI effectively escapes the permissions sandbox. + +```shell +deno run -A --unstable +``` + ## Documentation Check out the docs @@ -29,7 +41,7 @@ Check out the docs This module uses FFI to interface with the Python interpreter's C API. So you must have an existing Python installation (with the shared library), which is -something like `python39.dll`, etc. +something like `python310.dll`, etc. Python installed from Microsoft Store does not work, as it does not contain shared library for interfacing with Python interpreter. @@ -37,21 +49,16 @@ shared library for interfacing with Python interpreter. If the module fails to find Python, you can add the path to the Python in the `DENO_PYTHON_PATH` environment variable. +`DENO_PYTHON_PATH` if set, must point to full path including the file name of +the Python dynamic library, which is like `python310.dll` (Windows), +`libpython310.dylib` (macOS) and `libpython310.so` (Linux) depending on +platform. + ## Maintainers - DjDeveloper ([@DjDeveloperr](https://github.com/DjDeveloperr)) - Elias Sjögreen ([@eliassjogreen](https://github.com/eliassjogreen)) -## Permission Table - -| Permission Needed | Reason | -| ----------------- | ---------------------------------------------- | -| `--allow-env` | For finding the location of the python library | -| `--allow-run` | For finding the location of the python library | -| `--allow-read` | For reading the library | -| `--allow-ffi` | It uses FFI to interact with python | -| `--unstable` | It's unstable because it uses FFI | - ## Other ### Contribution diff --git a/src/python.ts b/src/python.ts index f8745f6..11dccda 100644 --- a/src/python.ts +++ b/src/python.ts @@ -135,7 +135,7 @@ export function kw( * ``` */ export class Callback { - unsafe: Deno.UnsafeCallback; + unsafe; constructor(public callback: PythonJSCallback) { this.unsafe = new Deno.UnsafeCallback(