Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to pass custom path to the node_python_bridge.py #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Also inherits the following from [`child_process.spawn([options])`](https://node
* `options.stdio` - Array Child's stdio configuration. Defaults to `['pipe', process.stdout, process.stderr]`
* `options.uid` - Number Sets the user identity of the process.
* `options.gid` - Number Sets the group identity of the process.
* `options.pythonBridgeScriptPath` - String Path to the `node_python_bridge.py` file.

```javascript
var python = pythonBridge({
Expand Down
1 change: 1 addition & 0 deletions README.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Also inherits the following from [`child_process.spawn([options])`](https://node
* `options.stdio` - Array Child's stdio configuration. Defaults to `['pipe', process.stdout, process.stderr]`
* `options.uid` - Number Sets the user identity of the process.
* `options.gid` - Number Sets the group identity of the process.
* `options.pythonBridgeScriptPath` - String Path to the `node_python_bridge.py` file.

```javascript
const python = pythonBridge({
Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface PythonBridgeOptions {
env?: { [key: string]: string | undefined; };
uid?: number;
gid?: number;
/** Path to the `node_python_bridge.py` file. */
pythonBridgeScriptPath?: string
}

export interface PythonBridge {
Expand Down
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ let Promise = require('bluebird');
let path = require('path');
let child_process = Promise.promisifyAll(require('child_process'));

const PYTHON_BRIDGE_SCRIPT = path.join(__dirname, 'node_python_bridge.py');

function pythonBridge(opts) {
// default options
let intepreter = opts && opts.python || 'python';
Expand All @@ -19,7 +17,8 @@ function pythonBridge(opts) {
};

// create process bridge
let ps = child_process.spawn(intepreter, [PYTHON_BRIDGE_SCRIPT], options);
const pythonBridgeScriptPath = opts.pythonBridgeScriptPath || path.join(__dirname, 'node_python_bridge.py');
let ps = child_process.spawn(intepreter, [pythonBridgeScriptPath], options);
let queue = singleQueue();

function sendPythonCommand(type, enqueue, self) {
Expand Down