测试包含numpy模块的pocketpy:pocketpy-numpy
pocketpy是个便携式python解析器它不兼容cpython的模块为了使用numpy的功能需要用到特殊的pocketpy-numpy软件包它以cpython模块方式发布。也有单独的CLI。pypi地址 https://pypi.org/project/pocketpy-numpy/奇怪的是存储库地址 https://github.com/cubao/xtensor-numpy 似乎指向一个不同名的软件版本号也对不上。安装方法1:用pip安装whl文件先进入python虚拟环境aaakylin-pc:~/par/tpy314$ source myenv/bin/activate (myenv) aaakylin-pc:~/par/tpy314$ pip install pocketpy-numpy -i https://mirrors.aliyun.com/pypi/simple/ Looking in indexes: https://mirrors.aliyun.com/pypi/simple/ Collecting pocketpy-numpy Downloading https://mirrors.aliyun.com/pypi/packages/c0/a6/00cb5493363eb40249a9757d33c08442ca0f6f53b5b21d1c2a709ef36af4/pocketpy_numpy-0.1.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (1.8 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 3.5 MB/s 0:00:00 Installing collected packages: pocketpy-numpy Successfully installed pocketpy-numpy-0.1.0 [notice] A new release of pip is available: 26.0.1 - 26.1.1 [notice] To update, run: pip install --upgrade pip用一个自己包含numpy方法的脚本测试报错RuntimeError: no matching function found。看来不是所有numpy方法都支持。(myenv) aaakylin-pc:~/par/tpy314$ python3 -m pocketpy_numpy ../test-prime-np.txt Traceback (most recent call last): File ../test-prime-np.txt, line 136 quick_verify() File ../test-prime-np.txt, line 127, in quick_verify primes_era sieve_eratosthenes(limit) File ../test-prime-np.txt, line 72, in sieve_eratosthenes is_prime np.ones(limit 1, dtypebool) RuntimeError: no matching function found, function signature: (_: std::vectorint)安装方法2从源代码编译从pypi网站下载pocketpy_numpy-0.1.0.tar.gz登录进去gcc容器解压缩。aaakylin-pc:/tmp/pocketpy_numpy-0.1.0$ sudo docker start gcc142 输入密码 gcc142 aaakylin-pc:/tmp/pocketpy_numpy-0.1.0$ sudo docker exec -it gcc142 bash rootkylin-pc:~/par/# tar xf pocketpy_numpy-0.1.0.tar.gz rootkylin-pc:~/par/# cd pocketpy_numpy-0.1.0 ls 3rd build_wasm.sh CLAUDE.md CMakeLists.txt docs include LICENSE Makefile PKG-INFO pyproject.toml README.md src tests先单独把CLI的main.c 和pocketpy.c编译报错缺少数学函数添加链接参数-m编译成功了但是这个CLI没有包含numpy模块。rootkylin-pc:/par/pocketpy_numpy-0.1.0# gcc main.c pocketpy.c -o main /usr/bin/ld: /tmp/ccfu7E2I.o: in function number__pow__: pocketpy.c:(.text0x2f0cc): undefined reference to pow /usr/bin/ld: pocketpy.c:(.text0x2f1b0): undefined reference to pow /usr/bin/ld: /tmp/ccfu7E2I.o: in function cpy11__float_div_mod: collect2: error: ld returned 1 exit status rootkylin-pc:/par/pocketpy_numpy-0.1.0# gcc main.c pocketpy.c -o main -lm rootkylin-pc:/par/pocketpy_numpy-0.1.0# ./main pocketpy 2.1.8 (May 9 2026, 05:11:11) [64 bit] on linux https://github.com/pocketpy/pocketpy Type exit() to exit. import numpy Traceback (most recent call last): File stdin, line 1 import numpy ImportError: No module named numpy还是老老实实按文档的说明编译rootkylin-pc:/par/pocketpy_numpy-0.1.0# make build报错说没有pip模块gcc容器中确实没有平常都是用pip.pyz脚本操作不想纠结修改makefile退出gcc容器进入python容器重新编译。aaakylin-pc:/tmp$ sudo docker start python 输入密码 python aaakylin-pc:/tmp$ sudo docker exec -it python bash rootkylin-pc:/par/pocketpy_numpy-0.1.0# make build python3 -m pip install scikit_build_core pyproject_metadata pathspec pybind112.12,3 Looking in indexes: https://mirrors.aliyun.com/pypi/simple/ Collecting scikit_build_core Downloading https://mirrors.aliyun.com/pypi/packages/07/49/b2f0fbe3165d55c02e7f9eec6a10685d518af0ef6e919ff2f589c2d15c85/scikit_build_core-0.12.2-py3-none-any.whl (192 kB) Collecting pyproject_metadata Downloading https://mirrors.aliyun.com/pypi/packages/1d/0b/da4851b1e2d9c40c9bd74c0abd94510a7d797da9ccde0a90e8953751ed4a/pyproject_metadata-0.11.0-py3-none-any.whl (22 kB) Collecting pathspec Downloading https://mirrors.aliyun.com/pypi/packages/f1/d9/7fb5aa316bc299258e68c73ba3bddbc499654a07f151cba08f6153988714/pathspec-1.1.1-py3-none-any.whl (57 kB) Collecting pybind113,2.12 Downloading https://mirrors.aliyun.com/pypi/packages/13/2f/0f24b288e2ce56f51c920137620b4434a38fd80583dbbe24fc2a1656c388/pybind11-2.13.6-py3-none-any.whl (243 kB) Requirement already satisfied: packaging23.2 in /usr/local/lib/python3.14/site-packages (from scikit_build_core) (26.0) Installing collected packages: pyproject_metadata, pybind11, pathspec, scikit_build_core Successfully installed pathspec-1.1.1 pybind11-2.13.6 pyproject_metadata-0.11.0 scikit_build_core-0.12.2 CMAKE_BUILD_PARALLEL_LEVEL8 python3 -m pip install --no-build-isolation -Ceditable.rebuildtrue -Cbuild-dirbuild -ve. Using pip 25.3 from /usr/local/lib/python3.14/site-packages/pip (python 3.14) Looking in indexes: https://mirrors.aliyun.com/pypi/simple/ Obtaining file:///par/pocketpy_numpy-0.1.0 Running command Checking if build backend supports build_editable Checking if build backend supports build_editable ... done Running command Preparing editable metadata (pyproject.toml) Traceback (most recent call last): File /usr/local/lib/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py, line 389, in module main() ~~~~^^ File /usr/local/lib/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py, line 373, in main json_out[return_val] hook(**hook_input[kwargs]) ~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File /usr/local/lib/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py, line 209, in prepare_metadata_for_build_editable return hook(metadata_directory, config_settings) File /usr/local/lib/python3.14/site-packages/scikit_build_core/build/__init__.py, line 108, in prepare_metadata_for_build_editable return _build_wheel_impl( ~~~~~~~~~~~~~~~~~^ None, config_settings, metadata_directory, editableTrue ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ).wheel_filename # actually returns the dist-info directory ^ File /usr/local/lib/python3.14/site-packages/scikit_build_core/build/wheel.py, line 177, in _build_wheel_impl return _build_wheel_impl_impl( wheel_directory, ...5 lines... pyprojectpyproject, ) File /usr/local/lib/python3.14/site-packages/scikit_build_core/build/wheel.py, line 249, in _build_wheel_impl_impl cmake CMake.default_search(versionsettings.cmake.version, envos.environ) File /usr/local/lib/python3.14/site-packages/scikit_build_core/cmake.py, line 68, in default_search raise CMakeNotFoundError(msg) scikit_build_core.errors.CMakeNotFoundError: Could not find CMake with version 3.15成功调用pip下载了所有的依赖包但是提示缺少cmake可执行文件。将cmake可执行文件路径加入PATH环境变量。就make成功了。既生成了可执行二进制文件也生成了whl文件并且自动安装到cpython中了。rootkylin-pc:/par/pocketpy_numpy-0.1.0# export PATH/par/cmake-4.2.3-linux-aarch64/bin:$PATH rootkylin-pc:/par/pocketpy_numpy-0.1.0# make build CMAKE_BUILD_PARALLEL_LEVEL8 python3 -m pip install --no-build-isolation -Ceditable.rebuildtrue -Cbuild-dirbuild -ve. Using pip 25.3 from /usr/local/lib/python3.14/site-packages/pip (python 3.14) Looking in indexes: https://mirrors.aliyun.com/pypi/simple/ Obtaining file:///par/pocketpy_numpy-0.1.0 Running command Checking if build backend supports build_editable Checking if build backend supports build_editable ... done Running command Preparing editable metadata (pyproject.toml) *** scikit-build-core 0.12.2 using CMake 4.2.3 (metadata_editable) Preparing editable metadata (pyproject.toml) ... done Building wheels for collected packages: pocketpy_numpy Running command Building editable for pocketpy_numpy (pyproject.toml) *** scikit-build-core 0.12.2 using CMake 4.2.3 (editable) *** Configuring CMake... loading initial cache file build/CMakeInit.txt -- The CXX compiler identification is GNU 14.2.0 -- The C compiler identification is GNU 14.2.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/g - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Your build type: Release -- Found Python: /usr/local/bin/python3 (found version 3.14.3) found components: Interpreter Development.Module -- Performing Test HAS_FLTO -- Performing Test HAS_FLTO - Success -- Found pybind11: /usr/local/lib/python3.14/site-packages/pybind11/include (found version 2.13.6) -- Configuring done (0.9s) -- Generating done (0.0s) -- Build files have been written to: /par/pocketpy_numpy-0.1.0/build *** Building project with Unix Makefiles... gmake[1]: Entering directory /par/pocketpy_numpy-0.1.0/build ... [100%] Linking CXX executable pocketpy.exe [100%] Built target pocketpy_cli gmake[1]: Leaving directory /par/pocketpy_numpy-0.1.0/build *** Installing project into wheel... -- Install configuration: Release -- Installing: /tmp/tmp2lfs6aub/wheel/platlib/pocketpy_numpy/pocketpy.exe -- Installing: /tmp/tmp2lfs6aub/wheel/platlib/pocketpy_numpy/_core.cpython-314-aarch64-linux-gnu.so *** Making editable... *** Created pocketpy_numpy-0.1.0-cp314-cp314-linux_aarch64.whl Building editable for pocketpy_numpy (pyproject.toml) ... done Created wheel for pocketpy_numpy: filenamepocketpy_numpy-0.1.0-cp314-cp314-linux_aarch64.whl size1788798 sha25617bc644c24ab44a66029eb38ceb07df4c1835da8d8c907f0fc9d1bed316a84f5 Stored in directory: /tmp/pip-ephem-wheel-cache-tadifi8k/wheels/71/1e/2c/9547a7397c8453c8d1e2b0d0d3e3a4868deb11ca8dba446abe Successfully built pocketpy_numpy Installing collected packages: pocketpy_numpy Successfully installed pocketpy_numpy-0.1.0 rootkylin-pc:/par/pocketpy_numpy-0.1.0# python tests/test_numpy_simple.py rootkylin-pc:/par/pocketpy_numpy-0.1.0# pip list Package Version Editable project location -------------------- ----------- ------------------------- numpy 2.4.3 pocketpy_numpy 0.1.0 /par/pocketpy_numpy-0.1.0在cpython中用源代码自带的脚本测试通过但这不能说明问题因为系统中本来也安装了numpy模块。所以要用文档中的方法加入-m pocketpy_numpy再用自己的脚本测试报错说找不到二进制文件。rootkylin-pc:/par/pocketpy_numpy-0.1.0# python -m pocketpy_numpy ../test-prime-np.txt Running cmake --build --install in /par/pocketpy_numpy-0.1.0/build [ 15%] Built target lz4 [ 38%] Built target msgpack [ 53%] Built target pocketpy [ 69%] Built target numpy [ 84%] Built target pocketpy_cli [100%] Built target _core -- Install configuration: Release -- Up-to-date: /usr/local/lib/python3.14/site-packages/pocketpy_numpy/pocketpy.exe -- Installing: /usr/local/lib/python3.14/site-packages/pocketpy_numpy/_core.cpython-314-aarch64-linux-gnu.so Traceback (most recent call last): File frozen runpy, line 198, in _run_module_as_main File frozen runpy, line 88, in _run_code File /par/pocketpy_numpy-0.1.0/src/pocketpy_numpy/__main__.py, line 9, in module sys.exit(subprocess.call([exe, *args])) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^ File /usr/local/lib/python3.14/subprocess.py, line 395, in call with Popen(*popenargs, **kwargs) as p: ~~~~~^^^^^^^^^^^^^^^^^^^^^^ File /usr/local/lib/python3.14/subprocess.py, line 1038, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pass_fds, cwd, env, ^^^^^^^^^^^^^^^^^^^ ...5 lines... gid, gids, uid, umask, ^^^^^^^^^^^^^^^^^^^^^^ start_new_session, process_group) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File /usr/local/lib/python3.14/subprocess.py, line 1874, in _execute_child self._posix_spawn(args, executable, env, restore_signals, close_fds, ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ p2cread, p2cwrite, ^^^^^^^^^^^^^^^^^^ c2pread, c2pwrite, ^^^^^^^^^^^^^^^^^^ errread, errwrite) ^^^^^^^^^^^^^^^^^^ File /usr/local/lib/python3.14/subprocess.py, line 1818, in _posix_spawn self.pid os.posix_spawn(executable, args, env, **kwargs) ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: /par/pocketpy_numpy-0.1.0/src/pocketpy_numpy/pocketpy.exe根据编译过程输出的日志找到实际的二进制文件位置用它来执行。rootkylin-pc:/par/pocketpy_numpy-0.1.0# /par/pocketpy_numpy-0.1.0/build/pocketpy.exe ../test-prime-np.txt Traceback (most recent call last): File ../test-prime-np.txt, line 136 quick_verify() File ../test-prime-np.txt, line 127, in quick_verify primes_era sieve_eratosthenes(limit) File ../test-prime-np.txt, line 72, in sieve_eratosthenes is_prime np.ones(limit 1, dtypebool) RuntimeError: no matching function found, function signature: (_: std::vectorint) rootkylin-pc:/par/pocketpy_numpy-0.1.0# /par/pocketpy_numpy-0.1.0/build/pocketpy.exe tests/test_numpy.py ALL TESTS PASSED虽然自己的脚本还是报错但已经是第一种安装方法中的找不到函数错误而测试tests/test_numpy.py成功了此脚本包含pocketpy-numpy软件包已经实现的函数。这是可以接受的。至于为什么源代码安装方式指向的二进制文件位置错误还需要进一步研究。