pinokiod 1.2.10 → 1.2.12

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/shell.js CHANGED
@@ -474,37 +474,47 @@ class Shell {
474
474
 
475
475
 
476
476
  // 1. conda
477
- let conda
477
+
478
+ let conda_activation = []
478
479
  if (params.conda) {
479
- conda = params.conda
480
- } else {
481
- conda = null
482
- }
483
480
 
484
- let conda_activation
485
- if (params.skip_conda) {
486
- // don't activate
487
- conda_activation = []
488
- } else {
489
- if (conda) {
490
- let conda_path
491
- let conda_python
492
- if (typeof conda === "string") {
493
- conda_path = conda
494
- conda_python = "python=3.10"
481
+ // 1. conda_path/conda_name/conda_python
482
+ let conda_path
483
+ let conda_name
484
+ let conda_python = "python=3.10"
485
+ if (typeof params.conda === "string") {
486
+ // params.conda => interpret as path
487
+ conda_path = params.conda
488
+ } else {
489
+ // params.conda.skip
490
+ if (params.conda.skip) {
491
+ // do nothing
495
492
  } else {
496
- if (conda.path) {
497
- conda_path = conda.path
493
+ if (typeof params.conda === "string") {
494
+ conda_path = params.conda
498
495
  } else {
499
- throw new Error("when specifying conda as an object, the conda.path must exist")
500
- }
501
- if (conda.python) {
502
- conda_python = conda.python
503
- } else {
504
- conda_python = "python=3.10"
496
+ // conda_path
497
+ if (params.conda.path) {
498
+ conda_path = params.conda.path
499
+ } else if (params.conda.name) {
500
+ conda_name = params.conda.name
501
+ } else {
502
+ throw new Error("when specifying conda as an object, the conda.name or conda.path must exist")
503
+ }
504
+
505
+ // conda_python
506
+ if (params.conda.python) {
507
+ conda_python = params.conda.python
508
+ }
505
509
  }
506
510
  }
511
+ }
512
+
513
+ console.log("CONDA STEP 1", { conda: params.conda, conda_path, conda_name, conda_python })
514
+
507
515
 
516
+ // 2. conda_activation
517
+ if (conda_path) {
508
518
  let env_path = path.resolve(params.path, conda_path)
509
519
  let env_exists = await this.exists(env_path)
510
520
  if (env_exists) {
@@ -525,19 +535,37 @@ class Shell {
525
535
  `conda activate ${env_path}`,
526
536
  ]
527
537
  }
528
-
538
+ } else if (conda_name) {
539
+ let envs_path = this.kernel.bin.path("miniconda/envs")
540
+ let env_path = path.resolve(envs_path, conda_name)
541
+ let env_exists = await this.exists(env_path)
542
+ if (env_exists) {
543
+ conda_activation = [
544
+ (this.platform === 'win32' ? 'conda_hook' : `eval "$(conda shell.bash hook)"`),
545
+ `conda deactivate`,
546
+ `conda deactivate`,
547
+ `conda deactivate`,
548
+ `conda activate ${conda_name}`,
549
+ ]
550
+ } else {
551
+ conda_activation = [
552
+ (this.platform === 'win32' ? 'conda_hook' : `eval "$(conda shell.bash hook)"`),
553
+ `conda create -y -n ${conda_name} ${conda_python}`,
554
+ `conda deactivate`,
555
+ `conda deactivate`,
556
+ `conda deactivate`,
557
+ `conda activate ${conda_name}`,
558
+ ]
559
+ }
529
560
  } else {
530
- // base environment => no need to create
531
- conda_activation = [
532
- (this.platform === 'win32' ? 'conda_hook' : `eval "$(conda shell.bash hook)"`),
533
- `conda deactivate`,
534
- `conda deactivate`,
535
- `conda deactivate`,
536
- `conda activate base`,
537
- ]
561
+ // no conda name or conda path => means don't activate any env
562
+ conda_activation = []
538
563
  }
539
564
  }
540
565
 
566
+ console.log("CONDA STEP 2", { conda_activation })
567
+
568
+
541
569
  // Update env setting
542
570
  if (this.env) {
543
571
  // this.env.CONDA_PIP_INTEROP_ENABLED = "1"
@@ -549,7 +577,6 @@ class Shell {
549
577
  }
550
578
 
551
579
 
552
-
553
580
  // 2. venv
554
581
  let venv_activation
555
582
  if (params.venv) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -2034,12 +2034,14 @@ class Server {
2034
2034
  console.log({ config })
2035
2035
 
2036
2036
  }
2037
+ let platform = os.platform()
2037
2038
 
2038
2039
 
2039
2040
 
2040
2041
 
2041
2042
  console.log("MEMORY", this.kernel.memory)
2042
2043
  res.render("browser", {
2044
+ platform,
2043
2045
  running:this.kernel.api.running,
2044
2046
  memory: this.kernel.memory,
2045
2047
  sidebar: "/pinokio/sidebar/" + name,
@@ -46,3 +46,7 @@ nav .bar #location {
46
46
  cursor: grab;
47
47
  -webkit-app-region: drag;
48
48
  }
49
+
50
+ [data-platform='darwin'] #menu {
51
+ margin-left: 70px;
52
+ }
@@ -457,7 +457,7 @@ body.dark .loader-container {
457
457
  }
458
458
  </style>
459
459
  </head>
460
- <body class='<%=theme%>'>
460
+ <body class='<%=theme%>' data-platform="<%=platform%>">
461
461
  <aside class='active'>
462
462
  <div class='header-top header-item'>
463
463
  <div class='app-info'>