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
- Host: GitHub
- URL: https://github.com/monkeycz/python.js
- Owner: monkeycz
- License: bsd-3-clause
- Created: 2015-03-20T08:06:40.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-16T10:33:27.000Z (about 9 years ago)
- Last Synced: 2024-06-02T15:49:54.807Z (25 days ago)
- Language: C++
- Size: 129 KB
- Stars: 192
- Watchers: 12
- Forks: 34
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.bsd
Lists
- awesome-github-star - python.js
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)