Skip to content

Commit

Permalink
chore: update readme to include run instructions (#23)
Browse files Browse the repository at this point in the history
* chore: update readme to include run instructions

* fix: type error on latest deno version
  • Loading branch information
DjDeveloperr authored Jul 2, 2022
1 parent 8156e2b commit 3f9e2f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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 <file>
```

## Documentation

Check out the docs
Expand All @@ -29,29 +41,24 @@ 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.

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
Expand Down
2 changes: 1 addition & 1 deletion src/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function kw(
* ```
*/
export class Callback {
unsafe: Deno.UnsafeCallback;
unsafe;

constructor(public callback: PythonJSCallback) {
this.unsafe = new Deno.UnsafeCallback(
Expand Down

0 comments on commit 3f9e2f8

Please sign in to comment.