包详细信息

@kiralearning/react-py-kira

tofergregg1.8kMIT1.10.22

Effortlessly run Python code in your React apps (fork)

react, python, pyodide

自述文件

react-py react-py

Effortlessly run Python code in your React apps. Try it out!

CI CodeQL MIT License NPM Version NPM Bundle Size


PyRepl.io is a Python interpreter in your browser. Embed interactive Python examples in your documentation, blog posts, presentations and more. Get started for free.

Quickstart

Install react-py with:

npm install react-py

Then, wrap your app in a PythonProvider component.

import { PythonProvider } from 'react-py'

function App() {
  return (
    // Add the provider to your app
    <PythonProvider>
      <Codeblock />
    </PythonProvider>
  )
}

render(<App />, document.getElementById('root'))

Using the usePython hook, you can run code and access both stdout and stderr. For full usage instructions and framework specific guides, see the usage docs.

Documentation

For full documentation, visit elilambnz.github.io/react-py.

Examples

Basic Example

REPL

Interrupting Execution

Using Packages

File System

Custom Modules

Making API Calls

User Input

Data Visualisation

Limitations

Most of the Python standard library is functional, except from some modules. The following modules can be imported, but are not functional due to the limitations of the WebAssembly VM:

  • multiprocessing
  • threading
  • sockets

Learn more about the limitations here.

License

react-py is available under the MIT License.

Contact

Eli Lamb - elilambnz
James Ansley - James-Ansley

Acknowledgments

This project uses Pyodide, a Python distribution for the browser and Node.js based on WebAssembly.

Contributing

If you're interested in contributing, please read our contributing docs before submitting a pull request.

更新日志

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.10.7 (2024-02-13)

1.10.6 (2023-09-21)

1.10.5 (2023-07-23)

1.10.4 (2023-07-23)

Features

  • Support for external service workers

1.10.3 (2023-07-23)

Bug fixes

  • Fixed input patch code for Safari bug

1.10.2 (2023-07-23)

Bug fixes

  • Fixed an issue where Webpack would not resolve the service worker URL correctly

1.10.1 (2023-07-22)

Features

  • Update Pyodide to 0.23.3

1.10.0 (2023-07-22)

Features

  • Patch default stdin behaviour (#212)

1.9.0 (2023-07-04)

Features

  • Update Pyodide to 0.23.3 (#202)

1.8.5 (2023-02-10)

Bug fixes

  • Fix runPython is causing an infinite loop (#92)

1.8.0 (2023-01-10)

Features

  • Added interactive console (#61)

1.7.0 (2023-01-08)

Features

  • Update Pyodide to 0.22.0

1.5.0 (2022-12-31)

Features

  • Added file system support (#36)

1.4.0 (2022-12-30)

Bug fixes

  • Removed sourcemap from build (#51)

1.3.0 (2022-12-10)

Features

  • Added support for packages

1.1.0 (2022-11-27)

Features

  • Implemented web workers

1.0.4 (2022-08-08)

Bug fixes

  • Fix stdout is not returned when output does not end with newline (#1)

0.0.1 (2022-08-07)

Features

  • Removed the need to manually import Pyodide CDN