Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

9 Commits

Repository files navigation

@orgsoft/py

A Deno Python wrapper that supports using virtual environments like from uv.

This lets you easily call Python modules from Deno code: in a portable, simple, and low setup way.

jsr:@orgsoft/py is based on jsr:@denosaurs/python and its native Python/C bindings. You can read more about that and further documentation on their GitHub repo.

Usage

There are two ways to use this module, either from code or command-line.

Typescript Usage

This is the recommended way to use this module.

import{getPython}from"jsr:@orgsoft/py";const{ python }=awaitgetPython();// Import a module and run a functionconstmodule=awaitpython.import("my_module");constresult=awaitmodule.main();console.log(result);// Run raw python codepython.run("print('hello world'));
// Continued...constnp=python.import("numpy");constplt=python.import("matplotlib.pyplot");constxpoints=np.array([1,8]);constypoints=np.array([3,10]);plt.plot(xpoints,ypoints);plt.show();

CLI Usage

This isn't particularly useful aside for testing, as you're better off using python run or uv run directly. But, maybe someone needs it..

deno run --allow-ffi --allow-env --allow-read --allow-run jsr:@orgsoft/py <python_module>

You could also install @orgsoft/py so it can be accessed quickly:

deno install -frAg --name denopy jsr:@orgsoft/py/mod.ts
denopy my_python_module

Replace denopy with any alias name you'd like.

Setup notes

Deno must be installed to use.

You should source a virtual environment to properly use @orgsoft/py:

source .venv/bin/activate

If you are using a different venv path, run:

source {MY_PYTHON_PROJECT_PATH}/.venv/bin/activate

We recommend using uv to create your virtual environment.

Then, run:

uv init
uv sync
source .venv/bin/activate

to create and activate your virtual environment.

Example

Go to example.

✌️

About

⚕ Run Python from Deno: fast, portable, low setup

Resources

Stars

7 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages