python.node

Call python code from node.js.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
python.node
501.0.45 years ago5 years agoMinified + gzip package size for python.node in KB

Readme

python.node
Call python code from node.js.

Usage

```javascript var python = require('python.node'); var os = python.import('os'); var path = require('path'); assert(os.path.basename(os.getcwd()) == path.basename(process.cwd())); ```

Feature

```python def test():
try:
## do samething
except Exception as e:
raise e
return 'done'
``` ```javascript PYMODULE.test.async = true; PYMODULE.test(function (result, error) {
if (!error)
console.log(result);
}); ``` If you need to pass keyword args, make the last argument an object with a sub-object kwArgs containing them: ```javascript PYMODULE.test("positionalArg", "anotherPositionalArg", { kwArgs: { arg1: "foo", arg2: 42} } ); ```

Build

Mac

```bash
for Node.js
node-gyp rebuild --arch=ia32/x64 --target=x.y.z
target nodejs version, eg: 0.10.28
``` ```bash
for node-webkit
nw-gyp rebuild --arch=ia32/x64 --target=x.y.z
target node-webkit version, eg: 0.8.6
```

Windows

```bash
for Node.js
cd python.node\src cl /O2 /MT /LD -Febinding.node binding.cc pyobjectwrapper.cc utils.cc GYPROOT>\.node-gyp\VERSION>\ARCH>\node.lib ROOT>\Python27\libs\python27.lib /IGYPROOT>\.node-gyp\VERSION>\src /IGYPROOT>\.node-gyp\VERSION>\deps\uv\include /IGYPROOT>\.node-gyp\VERSION>\deps\v8\include /IROOT>\Python27\include copy binding.node MODULESROOT>\python.js\compiled\VERSION>\win32\ARCH> ``` ```bash
for node-webkit
cd python.node\src cl /O2 /MT /LD -Febinding.node binding.cc py
objectwrapper.cc utils.cc GYPROOT>\.nw-gyp\WEBKITVERSION>\WEBKITARCH>\nw.lib ROOT>\Python27\libs\python27.lib /IGYPROOT>\.nw-gyp\WEBKITVERSION>\src /IGYPROOT>\.nw-gyp\WEBKITVERSION>\deps\uv\include /IGYP
ROOT>\.nw-gyp\WEBKITVERSION>\deps\v8\include /IROOT>\Python27\include copy binding.node MODULESROOT>\python.js\compiled\VERSION>\win32\WEBKITARCH> ```

Install

```bash npm install python.node ``` or ```bash npm install ://@//python.node.git
eg: npm install git+ssh://git@example.com/projects/python.node.git
```

Electron Install

```bash npm install python.node cd nodemodules\python.node npm run rebuild ```

Test

```bash node test/jstest.js ```

Thanks