{"id":18258721,"url":"https://github.com/maaarcocr/pyes","last_synced_at":"2025-04-04T19:32:01.382Z","repository":{"id":57679200,"uuid":"472965312","full_name":"Maaarcocr/pyes","owner":"Maaarcocr","description":"Running python in JS","archived":false,"fork":false,"pushed_at":"2022-04-21T08:24:19.000Z","size":12278,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-26T16:06:09.677Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Maaarcocr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-22T23:03:39.000Z","updated_at":"2022-11-11T06:20:07.000Z","dependencies_parsed_at":"2022-08-28T07:42:56.490Z","dependency_job_id":null,"html_url":"https://github.com/Maaarcocr/pyes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maaarcocr%2Fpyes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maaarcocr%2Fpyes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maaarcocr%2Fpyes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maaarcocr%2Fpyes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Maaarcocr","download_url":"https://codeload.github.com/Maaarcocr/pyes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223154360,"owners_count":17096733,"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":[],"created_at":"2024-11-05T10:34:07.467Z","updated_at":"2024-11-05T10:34:08.390Z","avatar_url":"https://github.com/Maaarcocr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyes\n\npyes is an ES module that allows you to run python from JavaScript\n\n# Example\n\n```js\nimport { pythonFunction, PythonInterpreter } from \"pyes\"\n\nconst addBody = `\ndef add_impl(a, b):\n  return a+b\n\ndef add(args):\n  return add_impl(args[0], args[1])\n`\n\nconst onReady = () =\u003e {console.log(\"Now the interpreter is ready\")}\nconst interpreter = new PythonInterpreter(onReady);\n\nconst add = pythonFunction(interpreter, \"add\", addBody)\nconsole.log(await add([1,2]));\ninterpreter.stop()\n```\n\n# How it works\n\nEvery time you define a new `PythonInterpreter`, pyes spins up a new web worker where a python interpreter is run. Then,\nwhen you define a function, it feeds the function definition to the interpreter (which is run in interactive mode).\nWhen you call the JS function that you get back the return value of `pythonFunction`, pyes\nencodes the argument you have passed as JSON and it then feeds some code to the python interpreter which:\n- parses the JSONified argument back into a python value using `json.loads`\n- calls your function with said parsed value\n- gets the output of your function and it JSONify it and prints it\n\nFrom JS, we then read the stdout and parse the JSON result and return it as the result of the function.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaaarcocr%2Fpyes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaaarcocr%2Fpyes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaaarcocr%2Fpyes/lists"}