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-
83This module provides a seamless integration between JavaScript (Deno/Bun) and
94Python 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.
2015Import 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
2520const np = python .import (" numpy" );
2621const plt = python .import (" matplotlib.pyplot" );
@@ -32,15 +27,11 @@ plt.plot(xpoints, ypoints);
3227plt .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
4637You can import from the `bunpy` NPM package to use this module in Bun.
@@ -56,7 +47,7 @@ const ypoints = np.array([3, 10]);
5647
5748plt.plot(xpoints, ypoints);
5849plt.show();
59- ```
50+ ```-->
6051
6152### Dependencies
6253
@@ -83,7 +74,7 @@ the provided `import` or `install` methods. The rest is handled automatically
8374for 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
8879const np = await pip .import (" numpy" );
8980const 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
116106the Python dynamic library, which is like ` python310.dll ` (Windows),
117107` libpython310.dylib ` (macOS) and ` libpython310.so ` (Linux) depending on
118108platform.
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.
0 commit comments