diff --git a/.gitignore b/.gitignore index 60c2171b..a2af19e3 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,10 @@ plugins/godot/godot-cpp/ src/_generated.h profile.sh test + +.coverage +APPS/ +main.obj +pocketpy.exe +pocketpy.lib +pocketpy.exp \ No newline at end of file diff --git a/README.md b/README.md index f446940f..0325dc3a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PocketPy +# pocketpy `v0.9.3` LTS
-PocketPy is a lightweight(~5000 LOC) Python interpreter for game engines. - - -**English |** [**简体中文**](README_zh.md) +pocketpy is a lightweight(~5000 LOC) Python interpreter. +And this branch is a long-term support version based on `v0.9.3`. It is extremely easy to embed. Including a compiler, optimizer and bytecode virtual machine. All of them are available in a single header file `pocketpy.h`, without external dependencies. @@ -79,80 +77,6 @@ int main(){ } ``` -#### Unity Engine - -PocketPy for Unity can be installed via Unity Asset Store. - -https://assetstore.unity.com/packages/slug/241120 - -```csharp -using UnityEngine; - -public class Test01 : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - // Create a virtual machine - pkpy.VM vm = new pkpy.VM(); - - // Create a list - vm.exec("a = [1, 2, 3]"); - - // Eval the sum of the list - string result = vm.eval("sum(a)"); - Debug.Log(result); // 6 - - // Print to the standard output - vm.exec("print(a)"); - pkpy.PyOutput o = vm.read_output(); - Debug.Log(o.stdout); // [1, 2, 3] - - // Create a binding - vm.bind("builtins", "test", (double x) => x+1); - Debug.Log(vm.eval("test(3.14)")); // '4.14' - } -} -``` - -#### Flutter - -Run the following script to install this plugin. - -``` -flutter pub add pocketpy -``` - -See https://pocketpy.dev/getting-started/flutter/ - -#### Pre-compiled Libs - -You can download `artifact.zip` from [Github Release](https://github.com/blueloveTH/pocketpy/releases/latest) page. In this archive, there are pre-compiled libraries for many platforms. The file structure is as follows. - -``` -- android/ - - arm64-v8a/ - - libpocketpy.so - - armeabi-v7a/ - - libpocketpy.so - - x86_64/ - - libpocketpy.so -- linux/ - - x86_64/ - - pocketpy - - pocketpy.so -- macos/ - - pocketpy.bundle/ -- web/ - - lib/ - - pocketpy.js - - pocketpy.wasm -- windows/ - - x86_64/ - - pocketpy.dll - - pocketpy.exe -``` - ## Contribution All kinds of contributions are welcome. @@ -179,4 +103,4 @@ Check our [Coding Style Guide](https://pocketpy.dev/coding_style_guide/) if you ## License -PocketPy is licensed under the [MIT License](http://opensource.org/licenses/MIT). +pocketpy is licensed under the [MIT License](http://opensource.org/licenses/MIT). diff --git a/README_zh.md b/README_zh.md deleted file mode 100644 index 355accd4..00000000 --- a/README_zh.md +++ /dev/null @@ -1,157 +0,0 @@ -# PocketPy - - - -PocketPy是一个轻量级的Python解释器,为嵌入至游戏引擎而设计。 - -它包含一个编译器和基于字节码的虚拟机,以及交互式命令窗的实现。所有功能均集成在单个头文件`pocketpy.h`中,不包含外部依赖项,能很方便地嵌入至你的应用。 - -你可以 [在浏览器中体验](https://blueloveth.github.io/pocketpy) PocketPy的交互式界面(REPL)。 - - - -## 支持的语法特性 - -| 特性 | 示例 | 支持 | -| ------------ | ------------------------------- | ---- | -| 分支 | `if..else..elif` | YES | -| 循环 | `for/while/break/continue` | YES | -| 函数 | `def f(x,*args,y=1):` | YES | -| 类与继承 | `class A(B):` | YES | -| 列表 | `[1, 2, 'a']` | YES | -| 列表生成式 | `[i for i in range(5)]` | YES | -| 切片 | `a[1:2], a[:2], a[1:]` | YES | -| 元组 | `(1, 2, 'a')` | YES | -| 字典 | `{'a': 1, 'b': 2}` | YES | -| 格式化字符串 | `f'value is {x}'` | YES | -| 序列解包 | `a, b = 1, 2` | YES | -| 异常 | `raise/try..catch` | YES | -| 动态分发 | `eval()/exec()` | YES | -| 反射 | `hasattr()/getattr()/setattr()` | YES | -| 导入模块 | `import/from..import` | YES | -| 上下文管理器 | `with