BrOakes 2018-10-30 21:44:32 -04:00
commit 00d125aad9
12 changed files with 46 additions and 11 deletions

View File

@ -0,0 +1 @@
python-3.7.1.exe

View File

@ -2,8 +2,9 @@
const path = require('path'); const path = require('path');
let pythonPath = path.resolve(__dirname, '..', 'Python', 'python.exe'); let pythonPath = path.resolve(__dirname, '..', 'Python', 'python.exe');
// const versions = require('./')
// console.log(process.argv); let args = process.argv.slice(2);
require('child_process').spawn(pythonPath, [], {stdio: 'inherit'}); require('child_process').spawn(pythonPath, args, {stdio: 'inherit'});

5
package-lock.json generated
View File

@ -217,6 +217,11 @@
"mime-db": "~1.37.0" "mime-db": "~1.37.0"
} }
}, },
"minimist": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
},
"oauth-sign": { "oauth-sign": {
"version": "0.9.0", "version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",

View File

@ -6,7 +6,8 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "node postinstall.js", "postinstall": "node postinstall.js",
"preuninstall": "node uninstall.js" "preuninstall": "node uninstall.js",
"clean": "node clean.js"
}, },
"bin": { "bin": {
"python": "bin/python.js" "python": "bin/python.js"
@ -21,6 +22,7 @@
"url": "https://github.com/marcus13345/pythonjs/issues" "url": "https://github.com/marcus13345/pythonjs/issues"
}, },
"dependencies": { "dependencies": {
"minimist": "^1.2.0",
"python": "0.0.4", "python": "0.0.4",
"request": "^2.88.0" "request": "^2.88.0"
}, },

20
readme.md 100644
View File

@ -0,0 +1,20 @@
# PortaPy
PortaPy is a module for running python from node.
To install it, simply run
```
npm install -g portapy
```
Global installation gives you access to the normal python command, as if it were installed normally.
```
C:\Users\Cobra>python
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>exit()
```

1
scripts/clean.js 100644
View File

@ -0,0 +1 @@
// const fs =

View File

@ -0,0 +1,10 @@
const path = require('path');
const fs = require('fs');
let installerFilename = fs.readFileSync('.installerLocation').toString();
let pythonPath = path.resolve(__dirname, 'Python-Installer', installerFilename);
require('child_process').execSync(`${pythonPath} /passive /uninstall`, {
stdio: 'inherit'
});

View File

@ -1,6 +0,0 @@
const path = require('path');
let pythonPath = path.resolve(__dirname, 'Python-Installer', 'python-3.7.1.exe');
require('child_process').execSync(`${pythonPath} /passive /uninstall`, {
stdio: 'inherit'
});

View File

@ -20,6 +20,9 @@ async function download() {
try { try {
fs.mkdirSync('Python'); fs.mkdirSync('Python');
} catch(e) {'';} } catch(e) {'';}
try {
fs.writeFileSync('.installerLocation', filename);
} catch(e) {'';}
// let installSettings = fs.readFileSync('unattend.xml'); // let installSettings = fs.readFileSync('unattend.xml');
let out_file = `Python-Installer/${filename}` let out_file = `Python-Installer/${filename}`
@ -30,7 +33,6 @@ async function download() {
uri: url, uri: url,
encoding: null encoding: null
}, function (error, response, body) { }, function (error, response, body) {
console.log(typeof body);
fs.writeFileSync(out_file, body, {}); fs.writeFileSync(out_file, body, {});
resolve(); resolve();
}); });
@ -86,7 +88,6 @@ function getPythonDownloadLink() {
let current_download_end = body.indexOf('">', current_download_start); let current_download_end = body.indexOf('">', current_download_start);
let current_download = body.substring(current_download_start, current_download_end); let current_download = body.substring(current_download_start, current_download_end);
console.log(current_download);
let url = current_download; let url = current_download;
resolve(url); resolve(url);

View File