pinokiod 1.0.50 → 1.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kernel/bin/py.js +20 -0
- package/kernel/python/index.js +1 -10
- package/package.json +1 -1
- package/server/index.js +4 -0
package/kernel/bin/py.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class Py {
|
|
2
|
+
async install(req, ondata) {
|
|
3
|
+
await this.kernel.exec({
|
|
4
|
+
message: "git clone https://github.com/pinokiocomputer/python py",
|
|
5
|
+
path: this.kernel.path("bin")
|
|
6
|
+
}, ondata)
|
|
7
|
+
await this.kernel.exec({
|
|
8
|
+
message: "pip install -r requirements.txt",
|
|
9
|
+
path: this.kernel.bin.path("py")
|
|
10
|
+
}, ondata)
|
|
11
|
+
}
|
|
12
|
+
async installed() {
|
|
13
|
+
let exists = await this.kernel.exists(this.kernel.bin.path("py"))
|
|
14
|
+
return exists
|
|
15
|
+
}
|
|
16
|
+
async uninstall(req, ondata) {
|
|
17
|
+
await this.kernel.bin.rm(this.kernel.bin.path("py"), ondata)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
module.exports = Py
|
package/kernel/python/index.js
CHANGED
|
@@ -7,19 +7,10 @@ class Python {
|
|
|
7
7
|
console.log("CALL", { modname, modpath, method, args })
|
|
8
8
|
// if this.proc doesn't exist, create
|
|
9
9
|
if (!this.proc) {
|
|
10
|
-
await this.kernel.exec({
|
|
11
|
-
message: [
|
|
12
|
-
"which pip",
|
|
13
|
-
"pip install fastapi importlib_metadata uvicorn[standard]",
|
|
14
|
-
],
|
|
15
|
-
conda: "base"
|
|
16
|
-
}, (s) => {
|
|
17
|
-
ondata(s)
|
|
18
|
-
})
|
|
19
10
|
await new Promise((resolve, reject) => {
|
|
20
11
|
this.kernel.exec({
|
|
21
12
|
message: "uvicorn --port 42001 server:app",
|
|
22
|
-
path:
|
|
13
|
+
path: this.kernel.bin.path("py"),
|
|
23
14
|
conda: "base"
|
|
24
15
|
}, (s) => {
|
|
25
16
|
// process.stdout.write(s)
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -289,6 +289,8 @@ class Server {
|
|
|
289
289
|
type: "conda",
|
|
290
290
|
name: "nodejs",
|
|
291
291
|
args: "-c conda-forge"
|
|
292
|
+
}, {
|
|
293
|
+
name: "py"
|
|
292
294
|
}]
|
|
293
295
|
let platform = os.platform()
|
|
294
296
|
if (platform === "win32") {
|
|
@@ -528,6 +530,8 @@ class Server {
|
|
|
528
530
|
type: "conda",
|
|
529
531
|
name: "nodejs",
|
|
530
532
|
args: "-c conda-forge"
|
|
533
|
+
}, {
|
|
534
|
+
name: "py"
|
|
531
535
|
}]
|
|
532
536
|
let platform = os.platform()
|
|
533
537
|
if (platform === "win32") {
|