Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/monkeycz/python.js

Call python code from node.js
https://github.com/monkeycz/python.js

Last synced: 9 days ago
JSON representation

Call python code from node.js

Lists

README

        

# python.js

Call python code from node.js.

## Usage

```javascript
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

```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);
});
```

## 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.js\src
cl /O2 /MT /LD -Febinding.node binding.cc py_object_wrapper.cc utils.cc \.node-gyp\\\node.lib \Python27\libs\python27.lib /I\.node-gyp\\src /I\.node-gyp\\deps\uv\include /I\.node-gyp\\deps\v8\include /I\Python27\include
copy binding.node \python.js\compiled\\win32\
```

```bash
# for node-webkit
cd python.js\src
cl /O2 /MT /LD -Febinding.node binding.cc py_object_wrapper.cc utils.cc \.nw-gyp\\\nw.lib \Python27\libs\python27.lib /I\.nw-gyp\\src /I\.nw-gyp\\deps\uv\include /I\.nw-gyp\\deps\v8\include /I\Python27\include
copy binding.node \python.js\compiled\\win32\
```

## Install

```bash
npm install python.js
```

or

```bash
npm install ://@//python.js.git
# eg: npm install git+ssh://[email protected]/projects/python.js.git
```

## Test

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

## Thanks

* [Jean-Sébastien Tremblay](https://github.com/JeanSebTr/node-python)
* [Chris Dickinson](https://github.com/chrisdickinson/node-python)