{"id":13611846,"url":"https://github.com/denosaurs/deno_python","last_synced_at":"2025-05-15T07:03:27.968Z","repository":{"id":37999025,"uuid":"442657340","full_name":"denosaurs/deno_python","owner":"denosaurs","description":"🐍 Python interpreter bindings for Deno and Bun.","archived":false,"fork":false,"pushed_at":"2025-02-10T09:49:04.000Z","size":113,"stargazers_count":725,"open_issues_count":17,"forks_count":23,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-10T19:31:07.140Z","etag":null,"topics":["bun","bun-ffi","bun-python","c-api","cpython","deno","deno-ffi","ffi","hacktoberfest","javascript","python","python-c-api","typescript"],"latest_commit_sha":null,"homepage":"https://deno.land/x/python","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denosaurs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"denosaurs","github":["denosaurs","djdeveloperr"]}},"created_at":"2021-12-29T04:15:45.000Z","updated_at":"2025-05-08T17:55:03.000Z","dependencies_parsed_at":"2023-12-18T05:06:58.437Z","dependency_job_id":"1a101a4e-171e-49e1-ab0a-83e44cf3d99a","html_url":"https://github.com/denosaurs/deno_python","commit_stats":{"total_commits":63,"total_committers":11,"mean_commits":"5.7272727272727275","dds":0.6031746031746033,"last_synced_commit":"cf7a8a1368f6d774b466f62276533c4b31d1e639"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Fdeno_python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Fdeno_python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Fdeno_python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Fdeno_python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denosaurs","download_url":"https://codeload.github.com/denosaurs/deno_python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253584658,"owners_count":21931550,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","bun-ffi","bun-python","c-api","cpython","deno","deno-ffi","ffi","hacktoberfest","javascript","python","python-c-api","typescript"],"created_at":"2024-08-01T19:02:13.502Z","updated_at":"2025-05-15T07:03:27.924Z","avatar_url":"https://github.com/denosaurs.png","language":"TypeScript","readme":"# Python Bridge\n\n[![Tags](https://img.shields.io/github/release/denosaurs/deno_python)](https://github.com/denosaurs/deno_python/releases)\n[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/python/mod.ts)\n[![checks](https://github.com/denosaurs/deno_python/actions/workflows/checks.yml/badge.svg)](https://github.com/denosaurs/deno_python/actions/workflows/checks.yml)\n[![License](https://img.shields.io/github/license/denosaurs/deno_python)](https://github.com/denosaurs/deno_python/blob/master/LICENSE)\n\nThis module provides a seamless integration between JavaScript (Deno/Bun) and\nPython by integrating with the\n[Python/C API](https://docs.python.org/3/c-api/index.html). It acts as a bridge\nbetween the two languages, enabling you to pass data and execute python code\nfrom within your JS applications. This enables access to the large and wonderful\n[python ecosystem](https://pypi.org/) while remaining native (unlike a runtime\nlike the wonderful [pyodide](https://github.com/pyodide/pyodide) which is\ncompiled to wasm, sandboxed and may not work with all python packages) and\nsimply using the existing python installation.\n\n## Example\n\nImport any locally installed Python package, for example, `matplotlib`:\n\n```ts\nimport { python } from \"https://deno.land/x/python/mod.ts\";\n\nconst np = python.import(\"numpy\");\nconst plt = python.import(\"matplotlib.pyplot\");\n\nconst xpoints = np.array([1, 8]);\nconst ypoints = np.array([3, 10]);\n\nplt.plot(xpoints, ypoints);\nplt.show();\n```\n\nWhen running, you **must** specify `--allow-ffi`, `--allow-env` and\n`--unstable-ffi` flags. Alternatively, you may also just specify `-A` instead of\nspecific permissions since enabling FFI effectively escapes the permissions\nsandbox.\n\n```shell\ndeno run -A --unstable-ffi \u003cfile\u003e\n```\n\n### Usage in Bun\n\nYou can import from the `bunpy` NPM package to use this module in Bun.\n\n```ts\nimport { python } from \"bunpy\";\n\nconst np = python.import(\"numpy\");\nconst plt = python.import(\"matplotlib.pyplot\");\n\nconst xpoints = np.array([1, 8]);\nconst ypoints = np.array([3, 10]);\n\nplt.plot(xpoints, ypoints);\nplt.show();\n```\n\n### Dependencies\n\nNormally deno_python follows the default python way of resolving imports, going\nthrough `sys.path` resolving them globally, locally or scoped to a virtual\nenvironment. This is ~~great~~ and allows you to manage your python dependencies\nfor `deno_python` projects in the same way you would any other python project\nusing your favorite package manager, be it\n[`pip`](https://pip.pypa.io/en/stable/),\n[`conda`](https://docs.conda.io/en/latest/) or\n[`poetry`](https://python-poetry.org/).\n\nThis may not be a good thing though, especially for something like a deno module\nwhich may depend on a python package. That is why the [`ext/pip`](./ext/pip.ts)\nutility exists for this project. It allows you to install python dependencies\nusing pip, scoped to either the global deno installation or if defined the\n`--location` passed to deno without leaking to the global python scope. It uses\nthe same caching location and algorithm as\n[plug](https://github.com/denosaurs/deno) and\n[deno cache](https://github.com/denoland/deno_cache).\n\nTo use [`ext/pip`](./ext/pip.ts) for python package management you simply use\nthe provided `import` or `install` methods. The rest is handled automatically\nfor you! Just take a look!\n\n```ts\nimport { pip } from \"https://deno.land/x/python/ext/pip.ts\";\n\nconst np = await pip.import(\"numpy\");\nconst plt = await pip.import(\"matplotlib\", \"matplotlib.pyplot\");\n\nconst xpoints = np.array([1, 8]);\nconst ypoints = np.array([3, 10]);\n\nplt.plot(xpoints, ypoints);\nplt.show();\n```\n\n## Documentation\n\nCheck out the docs\n[here](https://doc.deno.land/https://deno.land/x/python/mod.ts).\n\n## Python Installation\n\nThis module uses FFI to interface with the Python interpreter's C API. So you\nmust have an existing Python installation (with the shared library), which is\nsomething like `python310.dll`, etc.\n\nPython installed from Microsoft Store does not work, as it does not contain\nshared library for interfacing with Python interpreter.\n\nIf the module fails to find Python, you can add the path to the Python in the\n`DENO_PYTHON_PATH` environment variable.\n\n`DENO_PYTHON_PATH` if set, must point to full path including the file name of\nthe Python dynamic library, which is like `python310.dll` (Windows),\n`libpython310.dylib` (macOS) and `libpython310.so` (Linux) depending on\nplatform.\n\n## Usage with docker\n\nUsage with docker is easiest done using the\n[`denoland/deno:bin` image](https://github.com/denoland/deno_docker?tab=readme-ov-file#using-your-own-base-image)\nalong with the [official `python` image](https://hub.docker.com/_/python/).\n\n```Dockerfile\nARG DENO_VERSION=1.38.2\nARG PYTHON_VERSION=3.12\n\nFROM denoland/deno:bin-$DENO_VERSION AS deno\nFROM python:$PYTHON_VERSION\n\n# Copy and configure deno\nCOPY --from=deno /deno /usr/local/bin/deno\nENTRYPOINT [\"/usr/local/bin/deno\"]\n\n# Copy your project source\nCOPY . .\n\nRUN [\"run\", \"-A\", \"--unstable\", \"https://deno.land/x/python@0.4.2/examples/hello_python.ts\"]\n```\n\n## Maintainers\n\n- DjDeveloper ([@DjDeveloperr](https://github.com/DjDeveloperr))\n- Elias Sjögreen ([@eliassjogreen](https://github.com/eliassjogreen))\n\n## Other\n\n### Contribution\n\nPull request, issues and feedback are very welcome. Code style is formatted with\n`deno fmt` and commit messages are done following Conventional Commits spec.\n\n### Licence\n\nCopyright 2021, DjDeveloperr.\n\nCopyright 2023, the Denosaurs team. All rights reserved. MIT license.\n","funding_links":["https://opencollective.com/denosaurs","https://github.com/sponsors/denosaurs","https://github.com/sponsors/djdeveloperr"],"categories":["TypeScript","typescript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenosaurs%2Fdeno_python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenosaurs%2Fdeno_python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenosaurs%2Fdeno_python/lists"}