pinokiod 3.5.18 → 3.5.20
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/cuda.js +3 -3
- package/kernel/bin/py.js +1 -0
- package/kernel/index.js +14 -22
- package/kernel/shell.js +27 -27
- package/package.json +1 -1
- package/server/index.js +10 -1
package/kernel/bin/cuda.js
CHANGED
package/kernel/bin/py.js
CHANGED
|
@@ -2,6 +2,7 @@ const fse = require('fs-extra')
|
|
|
2
2
|
const path = require('path')
|
|
3
3
|
class Py {
|
|
4
4
|
async install(req, ondata) {
|
|
5
|
+
// set the permission
|
|
5
6
|
await fse.remove(this.kernel.path('bin/py'))
|
|
6
7
|
await this.kernel.exec({
|
|
7
8
|
message: "git clone https://github.com/pinokiocomputer/python py",
|
package/kernel/index.js
CHANGED
|
@@ -372,28 +372,16 @@ class Kernel {
|
|
|
372
372
|
}
|
|
373
373
|
async initHome() {
|
|
374
374
|
if (this.homedir) {
|
|
375
|
-
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
await
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
console.log("[initHome] 1 Give full permission")
|
|
386
|
-
clearInterval(interval)
|
|
387
|
-
await this.bin.exec({
|
|
388
|
-
sudo: true,
|
|
389
|
-
message: `icacls ${this.homedir} /grant *S-1-1-0:(OI)(CI)F /T`
|
|
390
|
-
}, (stream) => {
|
|
391
|
-
process.stdout.write(stream.raw)
|
|
392
|
-
})
|
|
393
|
-
console.log("[initHome] 2 Give full permission done")
|
|
394
|
-
}
|
|
395
|
-
}, 1000)
|
|
396
|
-
}
|
|
375
|
+
await fs.promises.mkdir(this.homedir, { recursive: true }).catch((e) => {})
|
|
376
|
+
if (this.platform === "win32") {
|
|
377
|
+
console.log("[initHome] 1 Give full permission")
|
|
378
|
+
await this.bin.exec({
|
|
379
|
+
sudo: true,
|
|
380
|
+
message: `icacls ${this.homedir} /grant *S-1-1-0:(OI)(CI)F /T`
|
|
381
|
+
}, (stream) => {
|
|
382
|
+
process.stdout.write(stream.raw)
|
|
383
|
+
})
|
|
384
|
+
console.log("[initHome] 2 Give full permission done")
|
|
397
385
|
}
|
|
398
386
|
}
|
|
399
387
|
}
|
|
@@ -471,6 +459,10 @@ class Kernel {
|
|
|
471
459
|
let home_exists = await this.exists(this.homedir)
|
|
472
460
|
console.log({ home_exists, homedir: this.homedir })
|
|
473
461
|
if (!home_exists) {
|
|
462
|
+
// home didn't exist.
|
|
463
|
+
// 1. mkdir
|
|
464
|
+
await fs.promises.mkdir(this.homedir, { recursive: true }).catch((e) => {})
|
|
465
|
+
// 2. and then add permission
|
|
474
466
|
await this.initHome()
|
|
475
467
|
}
|
|
476
468
|
|
package/kernel/shell.js
CHANGED
|
@@ -596,35 +596,35 @@ class Shell {
|
|
|
596
596
|
if (env_exists) {
|
|
597
597
|
conda_activation = [
|
|
598
598
|
(this.platform === 'win32' ? 'conda_hook' : `eval "$(conda shell.bash hook)"`),
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
599
|
+
`conda deactivate`,
|
|
600
|
+
`conda deactivate`,
|
|
601
|
+
`conda deactivate`,
|
|
602
602
|
// timeout,
|
|
603
603
|
`conda activate ${env_path}`,
|
|
604
|
-
timeout,
|
|
604
|
+
// timeout,
|
|
605
605
|
]
|
|
606
606
|
} else {
|
|
607
607
|
conda_activation = [
|
|
608
608
|
(this.platform === 'win32' ? 'conda_hook' : `eval "$(conda shell.bash hook)"`),
|
|
609
609
|
`conda create -y -p ${env_path} ${conda_python} ${conda_args ? conda_args : ''}`,
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
610
|
+
`conda deactivate`,
|
|
611
|
+
`conda deactivate`,
|
|
612
|
+
`conda deactivate`,
|
|
613
613
|
// timeout,
|
|
614
614
|
`conda activate ${env_path}`,
|
|
615
|
-
timeout,
|
|
615
|
+
// timeout,
|
|
616
616
|
]
|
|
617
617
|
}
|
|
618
618
|
} else if (conda_name) {
|
|
619
619
|
if (conda_name === "base") {
|
|
620
620
|
conda_activation = [
|
|
621
621
|
(this.platform === 'win32' ? 'conda_hook' : `eval "$(conda shell.bash hook)"`),
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
622
|
+
`conda deactivate`,
|
|
623
|
+
`conda deactivate`,
|
|
624
|
+
`conda deactivate`,
|
|
625
625
|
// timeout,
|
|
626
626
|
`conda activate ${conda_name}`,
|
|
627
|
-
timeout,
|
|
627
|
+
// timeout,
|
|
628
628
|
]
|
|
629
629
|
} else {
|
|
630
630
|
let envs_path = this.kernel.bin.path("miniconda/envs")
|
|
@@ -633,23 +633,23 @@ class Shell {
|
|
|
633
633
|
if (env_exists) {
|
|
634
634
|
conda_activation = [
|
|
635
635
|
(this.platform === 'win32' ? 'conda_hook' : `eval "$(conda shell.bash hook)"`),
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
636
|
+
`conda deactivate`,
|
|
637
|
+
`conda deactivate`,
|
|
638
|
+
`conda deactivate`,
|
|
639
639
|
// timeout,
|
|
640
640
|
`conda activate ${conda_name}`,
|
|
641
|
-
timeout,
|
|
641
|
+
// timeout,
|
|
642
642
|
]
|
|
643
643
|
} else {
|
|
644
644
|
conda_activation = [
|
|
645
645
|
(this.platform === 'win32' ? 'conda_hook' : `eval "$(conda shell.bash hook)"`),
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
646
|
+
`conda create -y -n ${conda_name} ${conda_python} ${conda_args ? conda_args : ''}`,
|
|
647
|
+
`conda deactivate`,
|
|
648
|
+
`conda deactivate`,
|
|
649
|
+
`conda deactivate`,
|
|
650
650
|
// timeout,
|
|
651
651
|
`conda activate ${conda_name}`,
|
|
652
|
-
timeout,
|
|
652
|
+
// timeout,
|
|
653
653
|
]
|
|
654
654
|
}
|
|
655
655
|
}
|
|
@@ -793,13 +793,13 @@ class Shell {
|
|
|
793
793
|
// `python -m venv --upgrade ${env_path}`,
|
|
794
794
|
// `uv venv --allow-existing ${env_path}${python_version}`,
|
|
795
795
|
(this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
|
|
796
|
-
timeout,
|
|
796
|
+
// timeout,
|
|
797
797
|
]
|
|
798
798
|
} else {
|
|
799
799
|
venv_activation = [
|
|
800
800
|
// `python -m venv --upgrade ${env_path}`,
|
|
801
801
|
(this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
|
|
802
|
-
timeout,
|
|
802
|
+
// timeout,
|
|
803
803
|
]
|
|
804
804
|
}
|
|
805
805
|
} else {
|
|
@@ -810,9 +810,9 @@ class Shell {
|
|
|
810
810
|
(this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
|
|
811
811
|
`uv pip install --upgrade pip setuptools wheel`,
|
|
812
812
|
deactivate_path,
|
|
813
|
-
timeout,
|
|
813
|
+
// timeout,
|
|
814
814
|
(this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
|
|
815
|
-
timeout,
|
|
815
|
+
// timeout,
|
|
816
816
|
]
|
|
817
817
|
} else {
|
|
818
818
|
// when python version is not specified, use the default python -m venv
|
|
@@ -821,9 +821,9 @@ class Shell {
|
|
|
821
821
|
(this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
|
|
822
822
|
`python -m pip install --upgrade pip setuptools wheel`,
|
|
823
823
|
deactivate_path,
|
|
824
|
-
timeout,
|
|
824
|
+
// timeout,
|
|
825
825
|
(this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
|
|
826
|
-
timeout,
|
|
826
|
+
// timeout,
|
|
827
827
|
]
|
|
828
828
|
}
|
|
829
829
|
}
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -2025,7 +2025,6 @@ class Server {
|
|
|
2025
2025
|
console.log({ homedir })
|
|
2026
2026
|
let logsdir = path.resolve(homedir, "logs")
|
|
2027
2027
|
console.log({ logsdir })
|
|
2028
|
-
await this.kernel.initHome()
|
|
2029
2028
|
await fs.promises.mkdir(logsdir, { recursive: true }).catch((e) => { console.log(e) })
|
|
2030
2029
|
console.log("this.log", this.log)
|
|
2031
2030
|
if (!this.log) {
|
|
@@ -2131,10 +2130,16 @@ class Server {
|
|
|
2131
2130
|
let version = this.kernel.store.get("version")
|
|
2132
2131
|
let home = this.kernel.store.get("home")
|
|
2133
2132
|
console.log({ home, version })
|
|
2133
|
+
|
|
2134
|
+
let needInitHome = false
|
|
2134
2135
|
if (home) {
|
|
2135
2136
|
if (version === this.version.pinokiod) {
|
|
2136
2137
|
console.log("version up to date")
|
|
2137
2138
|
} else {
|
|
2139
|
+
// For every update, this gets triggered exactly once.
|
|
2140
|
+
// 1. first mkdir if it doesn't exist (this step is irrelevant since at this point the home dir will exist)
|
|
2141
|
+
|
|
2142
|
+
needInitHome = true
|
|
2138
2143
|
console.log("not up to date. update py.")
|
|
2139
2144
|
// remove ~/bin/miniconda/py
|
|
2140
2145
|
let p = path.resolve(home, "bin/py")
|
|
@@ -2150,6 +2155,10 @@ class Server {
|
|
|
2150
2155
|
// initialize kernel
|
|
2151
2156
|
await this.kernel.init({ port: this.port})
|
|
2152
2157
|
|
|
2158
|
+
console.log({ needInitHome })
|
|
2159
|
+
if (needInitHome) {
|
|
2160
|
+
await this.kernel.initHome()
|
|
2161
|
+
}
|
|
2153
2162
|
|
|
2154
2163
|
if (this.kernel.homedir) {
|
|
2155
2164
|
let ex = await this.kernel.exists(this.kernel.homedir, "ENVIRONMENT")
|