Skip to content

Commit f0ee950

Browse files
committed
cleanup
1 parent 076ab4c commit f0ee950

6 files changed

Lines changed: 28 additions & 75 deletions

File tree

README.md

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# Python Bridge
22

3-
[![Tags](https://img.shields.io/github/release/denosaurs/deno_python)](https://github.com/denosaurs/deno_python/releases)
4-
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/python/mod.ts)
5-
[![checks](https://github.com/denosaurs/deno_python/actions/workflows/checks.yml/badge.svg)](https://github.com/denosaurs/deno_python/actions/workflows/checks.yml)
6-
[![License](https://img.shields.io/github/license/denosaurs/deno_python)](https://github.com/denosaurs/deno_python/blob/master/LICENSE)
7-
83
This module provides a seamless integration between JavaScript (Deno/Bun) and
94
Python by integrating with the
105
[Python/C API](https://docs.python.org/3/c-api/index.html). It acts as a bridge
@@ -20,7 +15,7 @@ simply using the existing python installation.
2015
Import any locally installed Python package, for example, `matplotlib`:
2116

2217
```ts
23-
import { python } from "https://deno.land/x/python/mod.ts";
18+
import { python } from "@sigma/python"; // or jsr:@sigma/python directly with deno
2419

2520
const np = python.import("numpy");
2621
const plt = python.import("matplotlib.pyplot");
@@ -32,15 +27,11 @@ plt.plot(xpoints, ypoints);
3227
plt.show();
3328
```
3429

35-
When running, you **must** specify `--allow-ffi`, `--allow-env` and
36-
`--unstable-ffi` flags. Alternatively, you may also just specify `-A` instead of
37-
specific permissions since enabling FFI effectively escapes the permissions
38-
sandbox.
39-
4030
```shell
41-
deno run -A --unstable-ffi <file>
31+
deno run -A <file>
4232
```
4333

34+
<!--TODO
4435
### Usage in Bun
4536
4637
You can import from the `bunpy` NPM package to use this module in Bun.
@@ -56,7 +47,7 @@ const ypoints = np.array([3, 10]);
5647
5748
plt.plot(xpoints, ypoints);
5849
plt.show();
59-
```
50+
```-->
6051

6152
### Dependencies
6253

@@ -83,7 +74,7 @@ the provided `import` or `install` methods. The rest is handled automatically
8374
for you! Just take a look!
8475

8576
```ts
86-
import { pip } from "https://deno.land/x/python/ext/pip.ts";
77+
import { pip } from "@sigma/python/pip"; // or "jsr:@sigma/python/pip" directly in Deno
8778

8879
const np = await pip.import("numpy");
8980
const plt = await pip.import("matplotlib", "matplotlib.pyplot");
@@ -97,8 +88,7 @@ plt.show();
9788

9889
## Documentation
9990

100-
Check out the docs
101-
[here](https://doc.deno.land/https://deno.land/x/python/mod.ts).
91+
Check out the docs [here](https://jsr.io/@sigma/python).
10292

10393
## Python Installation
10494

@@ -116,44 +106,3 @@ If the module fails to find Python, you can add the path to the Python in the
116106
the Python dynamic library, which is like `python310.dll` (Windows),
117107
`libpython310.dylib` (macOS) and `libpython310.so` (Linux) depending on
118108
platform.
119-
120-
## Usage with docker
121-
122-
Usage with docker is easiest done using the
123-
[`denoland/deno:bin` image](https://github.com/denoland/deno_docker?tab=readme-ov-file#using-your-own-base-image)
124-
along with the [official `python` image](https://hub.docker.com/_/python/).
125-
126-
```Dockerfile
127-
ARG DENO_VERSION=1.38.2
128-
ARG PYTHON_VERSION=3.12
129-
130-
FROM denoland/deno:bin-$DENO_VERSION AS deno
131-
FROM python:$PYTHON_VERSION
132-
133-
# Copy and configure deno
134-
COPY --from=deno /deno /usr/local/bin/deno
135-
ENTRYPOINT ["/usr/local/bin/deno"]
136-
137-
# Copy your project source
138-
COPY . .
139-
140-
RUN ["run", "-A", "--unstable", "https://deno.land/x/python@0.4.2/examples/hello_python.ts"]
141-
```
142-
143-
## Maintainers
144-
145-
- DjDeveloper ([@DjDeveloperr](https://github.com/DjDeveloperr))
146-
- Elias Sjögreen ([@eliassjogreen](https://github.com/eliassjogreen))
147-
148-
## Other
149-
150-
### Contribution
151-
152-
Pull request, issues and feedback are very welcome. Code style is formatted with
153-
`deno fmt` and commit messages are done following Conventional Commits spec.
154-
155-
### Licence
156-
157-
Copyright 2021, DjDeveloperr.
158-
159-
Copyright 2023, the Denosaurs team. All rights reserved. MIT license.

deno.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
"./ext/pip": "./ext/pip.ts"
77
},
88
"tasks": {
9-
"check": "deno task check:mod && deno task check:ext && deno task check:examples",
10-
"check:mod": "deno check --unstable-ffi mod.ts",
11-
"check:ext": "deno check --unstable-ffi ext/*.ts",
12-
"check:examples": "deno check --unstable-ffi examples/*.ts",
13-
"test": "deno test --unstable-ffi -A test/test.ts && deno test -A --v8-flags=--expose-gc test/test_with_gc.ts",
14-
"example:hello_python": "deno run -A --unstable-ffi examples/hello_python.ts",
15-
"example:matplotlib": "deno run -A --unstable-ffi examples/matplotlib.ts",
16-
"example:pip_import": "deno run -A --unstable-ffi examples/pip_import.ts",
17-
"example:run_code": "deno run -A --unstable-ffi examples/run_code.ts",
18-
"example:tensorflow": "deno run -A --unstable-ffi examples/tensorflow.ts"
19-
}
9+
"test": "deno test -A && deno test -A --v8-flags=--expose-gc test/test_with_gc.ts"
10+
},
11+
"exclude": [
12+
"./test/bench.ts",
13+
"./plugin.ts",
14+
"./mod.bun.ts",
15+
"./test/bun.test.js"
16+
],
17+
"nodeModulesDir": "auto"
2018
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
],
2323
"keywords": [],
2424
"author": "DjDeveloperr",
25-
"license": "MIT"
25+
"license": "MIT",
26+
"devDependencies": {}
2627
}

test/deno.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"nodeModulesDir": "auto"
3+
}

test/gtk.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { kw, NamedArgument, type PyObject, python } from "../mod.ts";
1+
import { kw, type PyObject, python } from "../mod.ts";
22

33
import {
44
type Adw1_ as Adw_,
5+
type Callback,
56
DenoGLibEventLoop,
67
type Gtk4_ as Gtk_,
8+
NamedArgument,
79
// deno-lint-ignore no-import-prefix
810
} from "jsr:@sigma/gtk-py@0.7.0";
911

@@ -39,7 +41,7 @@ class MainWindow extends Gtk.ApplicationWindow {
3941
const button = Gtk.ToggleButton(
4042
new NamedArgument("label", "OFF"),
4143
);
42-
const f = python.callback(this.onClick);
44+
const f = python.callback(this.onClick) as Callback;
4345
button.connect("clicked", f);
4446
const vbox = Gtk.Box(
4547
new NamedArgument("orientation", Gtk.Orientation.VERTICAL),
@@ -59,14 +61,14 @@ class App extends Adw.Application {
5961
#win: MainWindow | undefined;
6062
constructor(kwArg: NamedArgument) {
6163
super(kwArg);
62-
this.connect("activate", this.onActivate);
64+
this.connect("activate", this.onActivate as Callback);
6365
}
6466
onActivate = python.callback((_kwarg, app: Gtk_.Application) => {
6567
new MainWindow(new NamedArgument("application", app)).present();
6668
});
6769
}
6870

69-
const app = new App(kw`application_id=${"com.example.com"}`);
71+
const app = new App(kw`application_id=${"com.example.com"}` as NamedArgument);
7072
app.register();
7173
app.activate();
7274
el.start();

test/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"keywords": [],
1010
"author": "",
1111
"license": "ISC",
12-
"dependencies": {
13-
"mitata": "^0.1.6"
12+
"devDependencies": {
13+
"mitata": "^1.0.34"
1414
}
1515
}

0 commit comments

Comments
 (0)