Python.js
Call python code from node.js
Install / Use
/learn @monkeycz/Python.jsREADME
python.js
Call python code from node.js.
Usage
var python = require('python.js');
var os = python.import('os');
var path = require('path');
assert(os.path.basename(os.getcwd()) == path.basename(process.cwd()));
Feature
def test():
try:
## do samething
except Exception as e:
raise e
return 'done'
PYMODULE.test.async = true;
PYMODULE.test(function (result, error) {
if (!error)
console.log(result);
});
Build
Mac
# for Node.js
node-gyp rebuild --arch=[ia32/x64] --target=x.y.z
# target nodejs version, eg: 0.10.28
# for node-webkit
nw-gyp rebuild --arch=[ia32/x64] --target=x.y.z
# target node-webkit version, eg: 0.8.6
Windows
# for Node.js
cd python.js\src
cl /O2 /MT /LD -Febinding.node binding.cc py_object_wrapper.cc utils.cc <NODE_GYP_ROOT>\.node-gyp\<NODEJS_VERSION>\<NODEJS_ARCH>\node.lib <PYTHON_ROOT>\Python27\libs\python27.lib /I<NODE_GYP_ROOT>\.node-gyp\<NODEJS_VERSION>\src /I<NODE_GYP_ROOT>\.node-gyp\<NODEJS_VERSION>\deps\uv\include /I<NODE_GYP_ROOT>\.node-gyp\<NODEJS_VERSION>\deps\v8\include /I<PYTHON_ROOT>\Python27\include
copy binding.node <NODE_MODULES_ROOT>\python.js\compiled\<NODEJS_VERSION>\win32\<NODEJS_ARCH>
# for node-webkit
cd python.js\src
cl /O2 /MT /LD -Febinding.node binding.cc py_object_wrapper.cc utils.cc <NW_GYP_ROOT>\.nw-gyp\<NODE_WEBKIT_VERSION>\<NODE_WEBKIT_ARCH>\nw.lib <PYTHON_ROOT>\Python27\libs\python27.lib /I<NW_GYP_ROOT>\.nw-gyp\<NODE_WEBKIT_VERSION>\src /I<NW_GYP_ROOT>\.nw-gyp\<NODE_WEBKIT_VERSION>\deps\uv\include /I<NW_GYP_ROOT>\.nw-gyp\<NODE_WEBKIT_VERSION>\deps\v8\include /I<PYTHON_ROOT>\Python27\include
copy binding.node <NODE_MODULES_ROOT>\python.js\compiled\<NODEJS_VERSION>\win32\<NODE_WEBKIT_ARCH>
Install
npm install python.js
or
npm install <protocol>://<user>@<domain>/<projects>/python.js.git
# eg: npm install git+ssh://git@example.com/projects/python.js.git
Test
node test/jstest.js
Thanks
Related Skills
node-connect
351.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
