0.1.0 • Published 9 years ago

python-loader v0.1.0

Weekly downloads
3
License
BSD
Repository
github
Last release
9 years ago

python-loader binding

Load Python runtime from specified path.

Usage

var path = require('path');
var pythonHome;
if (process.platform === 'win32') {
	pythonHome = path.join(path.dirname(process.execPath), 'Python27');
} else if (process.platform === 'darwin') {
	pythonHome = '/System/Library/Frameworks/Python.framework/Versions/Current';
}
var pythonLoader = require('python-loader');
pythonLoader.load(pythonHome);

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-loader\src
cl /O2 /MT /LD -Febinding.node binding.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 /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE"
copy binding.node <NODE_MODULES_ROOT>\python-loader\compiled\<NODEJS_VERSION>\win32\<NODEJS_ARCH>
# for node-webkit
cd python-loader\src
cl /O2 /MT /LD -Febinding.node binding.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 /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE"
copy binding.node <NODE_MODULES_ROOT>\python-loader\compiled\<NODEJS_VERSION>\win32\<NODE_WEBKIT_ARCH>

Install

npm install python-loader

or

npm install <protocol>://<user>@<domain>/<projects>/python-loader.git
# eg: npm install git+ssh://git@example.com/projects/python-loader.git

Test

node test/test.js