pinokiod 7.4.3 → 7.5.1

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.
@@ -1,10 +1,11 @@
1
1
  const semver = require('semver')
2
2
 
3
- const CONDA_PIN_VERSION = "25.5.1"
3
+ const CONDA_PIN_VERSION = "26.3.2"
4
4
  const DEFAULT_SQLITE_PIN_VERSION = "3.47.2"
5
5
  const WINDOWS_SQLITE_PIN_VERSION = "3.53.2"
6
- const WINDOWS_PYTHON_SSL_FIX_SPEC = "python=3.10.20=*_1_cpython"
7
- const WINDOWS_PYTHON_SSL_FIX_VERSION = "3.10.20"
6
+ const PYTHON_PIN_VERSION = "3.10.20"
7
+ const PYTHON_INSTALL_SPEC = `python=${PYTHON_PIN_VERSION}`
8
+ const WINDOWS_PYTHON_SSL_FIX_SPEC = `${PYTHON_INSTALL_SPEC}=*_1_cpython`
8
9
 
9
10
  const sqlitePinVersion = (platform) => {
10
11
  return platform === "win32" ? WINDOWS_SQLITE_PIN_VERSION : DEFAULT_SQLITE_PIN_VERSION
@@ -28,15 +29,15 @@ const condaBuildNumber = (build) => {
28
29
  return buildNumber ? Number(buildNumber) : null
29
30
  }
30
31
 
31
- const isWindowsPythonSslFixed = (version, build) => {
32
+ const isExpectedPythonPinned = (platform, version, build) => {
32
33
  const coerced = semver.coerce(version)
33
34
  if (!coerced) {
34
35
  return false
35
36
  }
36
- if (!semver.satisfies(coerced, ">=3.10.20 <3.11.0")) {
37
+ if (!semver.eq(coerced, PYTHON_PIN_VERSION)) {
37
38
  return false
38
39
  }
39
- if (semver.eq(coerced, WINDOWS_PYTHON_SSL_FIX_VERSION)) {
40
+ if (platform === "win32") {
40
41
  const buildNumber = condaBuildNumber(build)
41
42
  return typeof buildNumber === "number" && buildNumber >= 1
42
43
  }
@@ -45,9 +46,10 @@ const isWindowsPythonSslFixed = (version, build) => {
45
46
 
46
47
  module.exports = {
47
48
  CONDA_PIN_VERSION,
49
+ PYTHON_INSTALL_SPEC,
48
50
  WINDOWS_PYTHON_SSL_FIX_SPEC,
49
51
  isExpectedSqlitePinned,
50
- isWindowsPythonSslFixed,
52
+ isExpectedPythonPinned,
51
53
  sqliteInstallSpec,
52
54
  sqlitePinnedSpec,
53
55
  }
@@ -1,50 +1,36 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
- const fetch = require('cross-fetch')
4
3
  const { glob } = require('glob')
5
4
  const semver = require('semver')
6
5
  const { buildCondaListFromMeta } = require('./conda-meta')
7
6
  const {
8
7
  CONDA_PIN_VERSION,
8
+ PYTHON_INSTALL_SPEC,
9
9
  WINDOWS_PYTHON_SSL_FIX_SPEC,
10
+ isExpectedPythonPinned,
10
11
  isExpectedSqlitePinned,
11
- isWindowsPythonSslFixed,
12
12
  sqliteInstallSpec,
13
13
  sqlitePinnedSpec,
14
14
  } = require('./conda-pins')
15
15
 
16
+ const MINIFORGE_RELEASE = "26.3.2-3"
17
+ const MINIFORGE_BASE_URL = `https://github.com/conda-forge/miniforge/releases/download/${MINIFORGE_RELEASE}`
18
+ const CONDA_ROOT_DIR = "miniforge"
19
+ const LEGACY_CONDA_ROOT_DIR = "miniconda"
20
+
16
21
  class Conda {
17
22
  description = "Pinokio uses Conda to install various useful programs in an isolated manner."
18
23
  urls = {
19
24
  darwin: {
20
- //x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-x86_64.sh",
21
- //arm64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-arm64.sh"
22
- //x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-MacOSX-x86_64.sh",
23
- //arm64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-MacOSX-arm64.sh"
24
-
25
- //x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.11.1-0-MacOSX-x86_64.sh",
26
- //arm64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.11.1-0-MacOSX-arm64.sh"
27
-
28
- x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_25.1.1-2-MacOSX-x86_64.sh",
29
- arm64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_25.1.1-2-MacOSX-arm64.sh"
25
+ x64: `${MINIFORGE_BASE_URL}/Miniforge3-MacOSX-x86_64.sh`,
26
+ arm64: `${MINIFORGE_BASE_URL}/Miniforge3-MacOSX-arm64.sh`
30
27
  },
31
28
  win32: {
32
- //x64: "https://github.com/cocktailpeanut/miniconda/releases/download/v23.5.2/Miniconda3-py310_23.5.2-0-Windows-x86_64.exe",
33
- //x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-Windows-x86_64.exe"
34
-
35
- //x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.11.1-0-Windows-x86_64.exe"
36
- x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_25.1.1-2-Windows-x86_64.exe",
29
+ x64: `${MINIFORGE_BASE_URL}/Miniforge3-Windows-x86_64.exe`,
37
30
  },
38
31
  linux: {
39
- //x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-Linux-x86_64.sh",
40
- //arm64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-Linux-aarch64.sh"
41
- //x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-Linux-x86_64.sh",
42
- //arm64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-Linux-aarch64.sh"
43
-
44
- //x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.11.1-0-Linux-x86_64.sh",
45
- //arm64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_24.11.1-0-Linux-aarch64.sh"
46
- x64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_25.1.1-2-Linux-x86_64.sh",
47
- arm64: "https://repo.anaconda.com/miniconda/Miniconda3-py310_25.1.1-2-Linux-aarch64.sh"
32
+ x64: `${MINIFORGE_BASE_URL}/Miniforge3-Linux-x86_64.sh`,
33
+ arm64: `${MINIFORGE_BASE_URL}/Miniforge3-Linux-aarch64.sh`
48
34
  }
49
35
  }
50
36
  installer = {
@@ -53,9 +39,9 @@ class Conda {
53
39
  linux: "installer.sh"
54
40
  }
55
41
  paths = {
56
- darwin: [ "miniconda/etc/profile.d", "miniconda/bin", "miniconda/condabin", "miniconda/lib", "miniconda/Library/bin", "miniconda/pkgs", "miniconda" ],
57
- win32: ["miniconda/etc/profile.d", "miniconda/bin", "miniconda/Scripts", "miniconda/condabin", "miniconda/lib", "miniconda/Library/bin", "miniconda/pkgs", "miniconda"],
58
- linux: ["miniconda/etc/profile.d", "miniconda/bin", "miniconda/condabin", "miniconda/lib", "miniconda/Library/bin", "miniconda/pkgs", "miniconda"]
42
+ darwin: [ `${CONDA_ROOT_DIR}/etc/profile.d`, `${CONDA_ROOT_DIR}/bin`, `${CONDA_ROOT_DIR}/condabin`, `${CONDA_ROOT_DIR}/lib`, `${CONDA_ROOT_DIR}/Library/bin`, `${CONDA_ROOT_DIR}/pkgs`, CONDA_ROOT_DIR ],
43
+ win32: [`${CONDA_ROOT_DIR}/etc/profile.d`, `${CONDA_ROOT_DIR}/bin`, `${CONDA_ROOT_DIR}/Scripts`, `${CONDA_ROOT_DIR}/condabin`, `${CONDA_ROOT_DIR}/lib`, `${CONDA_ROOT_DIR}/Library/bin`, `${CONDA_ROOT_DIR}/pkgs`, CONDA_ROOT_DIR],
44
+ linux: [`${CONDA_ROOT_DIR}/etc/profile.d`, `${CONDA_ROOT_DIR}/bin`, `${CONDA_ROOT_DIR}/condabin`, `${CONDA_ROOT_DIR}/lib`, `${CONDA_ROOT_DIR}/Library/bin`, `${CONDA_ROOT_DIR}/pkgs`, CONDA_ROOT_DIR]
59
45
  }
60
46
  pinnedPackages() {
61
47
  return [
@@ -63,25 +49,27 @@ class Conda {
63
49
  sqlitePinnedSpec(this.kernel.platform),
64
50
  ].join("\n")
65
51
  }
52
+ async hasCondaMeta() {
53
+ return await this.kernel.exists(`bin/${CONDA_ROOT_DIR}/conda-meta`)
54
+ }
66
55
  env() {
67
56
  let base = {
68
- // CONDA_ROOT: this.kernel.bin.path("miniconda"),
69
- CONDA_PREFIX: this.kernel.bin.path("miniconda"),
70
- CONDA_ENVS_PATH: this.kernel.bin.path("miniconda/envs"),
71
- CONDA_PKGS_DIRS: this.kernel.bin.path("miniconda/pkgs"),
72
- PYTHON: this.kernel.bin.path("miniconda/python"),
57
+ CONDA_PREFIX: this.kernel.bin.path(CONDA_ROOT_DIR),
58
+ CONDA_ENVS_PATH: this.kernel.bin.path(`${CONDA_ROOT_DIR}/envs`),
59
+ CONDA_PKGS_DIRS: this.kernel.bin.path(`${CONDA_ROOT_DIR}/pkgs`),
60
+ PYTHON: this.kernel.bin.path(`${CONDA_ROOT_DIR}/python`),
73
61
  PATH: this.paths[this.kernel.platform].map((p) => {
74
62
  return this.kernel.bin.path(p)
75
63
  })
76
64
  }
77
65
  if (this.kernel.platform === "win32") {
78
- base.CONDA_BAT = this.kernel.bin.path("miniconda/condabin/conda.bat")
79
- base.CONDA_EXE = this.kernel.bin.path("miniconda/Scripts/conda.exe")
80
- base.CONDA_PYTHON_EXE = this.kernel.bin.path("miniconda/Scripts/python")
66
+ base.CONDA_BAT = this.kernel.bin.path(`${CONDA_ROOT_DIR}/condabin/conda.bat`)
67
+ base.CONDA_EXE = this.kernel.bin.path(`${CONDA_ROOT_DIR}/Scripts/conda.exe`)
68
+ base.CONDA_PYTHON_EXE = this.kernel.bin.path(`${CONDA_ROOT_DIR}/Scripts/python`)
81
69
  }
82
70
  if (this.kernel.platform === 'darwin') {
83
- base.TCL_LIBRARY = this.kernel.bin.path("miniconda/lib/tcl8.6")
84
- base.TK_LIBRARY = this.kernel.bin.path("miniconda/lib/tk8.6")
71
+ base.TCL_LIBRARY = this.kernel.bin.path(`${CONDA_ROOT_DIR}/lib/tcl8.6`)
72
+ base.TK_LIBRARY = this.kernel.bin.path(`${CONDA_ROOT_DIR}/lib/tk8.6`)
85
73
  }
86
74
  return base
87
75
  }
@@ -89,7 +77,10 @@ class Conda {
89
77
  if (this.kernel.platform !== "win32") {
90
78
  return
91
79
  }
92
- const activateDir = this.kernel.bin.path("miniconda/etc/conda/activate.d")
80
+ if (!(await this.hasCondaMeta())) {
81
+ return
82
+ }
83
+ const activateDir = this.kernel.bin.path(`${CONDA_ROOT_DIR}/etc/conda/activate.d`)
93
84
  await fs.promises.mkdir(activateDir, { recursive: true }).catch(() => {})
94
85
  await fs.promises.writeFile(
95
86
  path.resolve(activateDir, "zz_pinokio_unset_ssl_cert_dir-win.bat"),
@@ -115,61 +106,31 @@ fi
115
106
  )
116
107
  }
117
108
  async init() {
118
- //
119
109
  if (this.kernel.homedir) {
120
- // let exists = await this.kernel.exists("condarc")
121
110
  console.log("condarc init")
122
- // if (!exists) {
123
111
  await fs.promises.writeFile(this.kernel.path('condarc'), `channels:
124
112
  - conda-forge
125
- - defaults
126
113
  channel_priority: flexible
127
114
  create_default_packages:
128
- - python=3.10
115
+ - ${PYTHON_INSTALL_SPEC}
129
116
  envs_dirs:
130
- - ${this.kernel.bin.path("miniconda/envs")}
131
- plugins:
132
- anaconda_telemetry: false
133
- auto_accept_tos: true
117
+ - ${this.kernel.bin.path(`${CONDA_ROOT_DIR}/envs`)}
134
118
  pkgs_dirs:
135
- - ${this.kernel.bin.path("miniconda/pkgs")}
119
+ - ${this.kernel.bin.path(`${CONDA_ROOT_DIR}/pkgs`)}
136
120
  remote_connect_timeout_secs: 20.0
137
121
  remote_read_timeout_secs: 300.0
138
122
  remote_max_retries: 6
139
123
  report_errors: false`)
140
- //repodata_threads: 4
141
- //fetch_threads: 5
142
- //report_errors: false`)
143
- // }
144
- let pinned_exists = await this.kernel.exists("bin/miniconda/conda-meta")
124
+ let pinned_exists = await this.hasCondaMeta()
145
125
  if (pinned_exists) {
146
- //await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda ==24.11.3`)
147
- await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), this.pinnedPackages())
148
- // await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), "")
149
- //sqlite ==3.47.2`)
150
- // await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.9.0`)
151
- // await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.11.2
152
- //conda-libmamba-solver=24.11.1`)
153
- // await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.7.1
154
- //conda-libmamba-solver=24.7.0`)
126
+ await fs.promises.writeFile(this.kernel.path(`bin/${CONDA_ROOT_DIR}/conda-meta/pinned`), this.pinnedPackages())
127
+ await this.ensureSslCertDirOverride()
128
+ await this.ensureCompatibilityAlias()
155
129
  }
156
- await this.ensureSslCertDirOverride()
157
130
  }
158
131
  }
159
- // async init() {
160
- // let exists = await this.kernel.bin.exists("miniconda/condarc")
161
- // console.log("condarc exists?", exists)
162
- // if (!exists) {
163
- // console.log("write to condarc")
164
- // await fs.promises.writeFile(this.kernel.bin.path('miniconda/condarc'), `channels:
165
- // - conda-forge
166
- // - defaults
167
- // create_default_packages:
168
- // - python=3.10`)
169
- // }
170
- // }
171
132
  async check() {
172
- let res = await buildCondaListFromMeta(this.kernel.bin.path("miniconda"))
133
+ let res = await buildCondaListFromMeta(this.kernel.bin.path(CONDA_ROOT_DIR))
173
134
 
174
135
  let lines = res.response.split(/[\r\n]+/)
175
136
  let conda_check = {}
@@ -189,20 +150,12 @@ report_errors: false`)
189
150
  conda_builds[name] = build
190
151
  if (name === "conda") {
191
152
  conda_check.conda = true
192
- // //if (String(version) === "24.11.1") {
193
- // if (String(version) === "24.11.3") {
194
- // conda_check.conda = true
195
- // }
196
153
  }
197
154
  // check conda-libmamba-solver is up to date
198
155
  // sometimes it just fails silently so need to check
199
156
  if (name === "conda-libmamba-solver") {
200
- //if (String(version) === "24.7.0") {
201
- let channel = chunks[3]
202
157
  let coerced = semver.coerce(version)
203
- //let mamba_requirement = ">=24.11.1"
204
158
  let mamba_requirement = ">=25.4.0"
205
- //if (semver.satisfies(coerced, mamba_requirement) && channel === "conda-forge") {
206
159
  if (semver.satisfies(coerced, mamba_requirement)) {
207
160
  conda_check.mamba = true
208
161
  }
@@ -225,7 +178,7 @@ report_errors: false`)
225
178
  //}
226
179
  }
227
180
  if (name === "python") {
228
- conda_check.python = this.kernel.platform !== "win32" || isWindowsPythonSslFixed(version, build)
181
+ conda_check.python = isExpectedPythonPinned(this.kernel.platform, version, build)
229
182
  }
230
183
  }
231
184
  } else {
@@ -237,8 +190,7 @@ report_errors: false`)
237
190
  this.kernel.bin.installed.conda = conda
238
191
  this.kernel.bin.installed.conda_versions = conda_versions
239
192
  this.kernel.bin.installed.conda_builds = conda_builds
240
- return conda_check.conda && conda_check.mamba && conda_check.sqlite && (this.kernel.platform !== "win32" || conda_check.python)
241
- //return conda_check.conda && conda_check.mamba
193
+ return conda_check.conda && conda_check.mamba && conda_check.sqlite && conda_check.python
242
194
  }
243
195
  async install(req, ondata) {
244
196
  for(let i=0; i<5; i++) {
@@ -255,12 +207,12 @@ report_errors: false`)
255
207
  async _install(req, ondata) {
256
208
  const installer_url = this.urls[this.kernel.platform][this.kernel.arch]
257
209
  const installer = this.installer[this.kernel.platform]
258
- const install_path = this.kernel.bin.path("miniconda")
259
- let install_path_exists = await this.kernel.exists("bin/miniconda")
260
- if (install_path_exists) {
261
- console.log("Install path already exists. Removing...", install_path)
262
- await fs.promises.rm(install_path, { recursive: true }).catch((e) => {
263
- })
210
+ const install_path = this.kernel.bin.path(CONDA_ROOT_DIR)
211
+ const legacy_path = this.kernel.bin.path(LEGACY_CONDA_ROOT_DIR)
212
+ let install_path_exists = await this.kernel.exists(`bin/${CONDA_ROOT_DIR}`)
213
+ let legacy_path_exists = await this.kernel.exists(`bin/${LEGACY_CONDA_ROOT_DIR}`)
214
+ if (install_path_exists || legacy_path_exists) {
215
+ console.log("Install path already exists. Will replace after installer download...", install_path)
264
216
  } else {
265
217
  console.log("Install path does not exist. Installing...")
266
218
  }
@@ -268,6 +220,17 @@ report_errors: false`)
268
220
  ondata({ raw: `downloading installer: ${installer_url}...\r\n` })
269
221
  await this.kernel.bin.download(installer_url, installer, ondata)
270
222
 
223
+ legacy_path_exists = await this.kernel.exists(`bin/${LEGACY_CONDA_ROOT_DIR}`)
224
+ if (legacy_path_exists) {
225
+ console.log("Removing legacy install path...", legacy_path)
226
+ await this.removeInstallPath(legacy_path)
227
+ }
228
+ install_path_exists = await this.kernel.exists(`bin/${CONDA_ROOT_DIR}`)
229
+ if (install_path_exists) {
230
+ console.log("Removing existing install path...", install_path)
231
+ await this.removeInstallPath(install_path)
232
+ }
233
+
271
234
  // 2. run the script
272
235
  ondata({ raw: `running installer: ${installer}...\r\n` })
273
236
 
@@ -284,35 +247,13 @@ report_errors: false`)
284
247
  })
285
248
 
286
249
  // set pinned
287
- let pinned_exists = await this.kernel.exists("bin/miniconda/conda-meta")
250
+ let pinned_exists = await this.kernel.exists(`bin/${CONDA_ROOT_DIR}/conda-meta`)
288
251
  if (pinned_exists) {
289
- //await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.11.1`)
290
- //await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda ==24.11.3`)
291
- await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), this.pinnedPackages())
292
- //await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), "sqlite ==3.47.2")
293
- //await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), "")
294
- //sqlite ==3.47.2`)
295
- // await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.9.0`)
296
- // await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.11.2
297
- //conda-libmamba-solver=24.11.1`)
298
- // await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.7.1
299
- //conda-libmamba-solver=24.7.0`)
252
+ await fs.promises.writeFile(this.kernel.path(`bin/${CONDA_ROOT_DIR}/conda-meta/pinned`), this.pinnedPackages())
300
253
  }
301
- //// await this.activate()
302
- // await fs.promises.writeFile(this.kernel.bin.path('miniconda/condarc'), `channels:
303
- // - conda-forge
304
- // - defaults
305
- //create_default_packages:
306
- // - python=3.10`)
307
-
308
-
309
- // 1. right after installing conda==24.11.1, run conda update --all
310
- // 2. The pinned file says conda-libmamba-solver=24.11.1
311
- // 3. so after conda update --all, it should be conda-libmamba-solver=24.11.1
312
254
 
313
255
  let mods = this.kernel.bin.mods.filter((m) => {
314
256
  return req.dependencies.includes(m.name)
315
- // return ["zip", "uv", "node", "huggingface", "gxx", "git", "ffmpeg", "caddy"].includes(m.name)
316
257
  }).map((m) => {
317
258
  if (m.mod.cmd) {
318
259
  return m.mod.cmd()
@@ -323,113 +264,84 @@ report_errors: false`)
323
264
  console.log("Conda dependencies to install", { mods })
324
265
 
325
266
  let condaPackages = [
267
+ this.kernel.platform === "win32" ? `"${WINDOWS_PYTHON_SSL_FIX_SPEC}"` : `"${PYTHON_INSTALL_SPEC}"`,
326
268
  `"${sqliteInstallSpec(this.kernel.platform)}"`,
327
269
  `"conda-libmamba-solver>=25.4.0"`,
328
270
  ]
329
- if (this.kernel.platform === "win32") {
330
- condaPackages.unshift(`"${WINDOWS_PYTHON_SSL_FIX_SPEC}"`)
331
- }
332
271
 
333
272
  let cmds = [
334
- //"conda clean -y --index-cache",
335
273
  "conda clean -y --all",
336
- `conda install -y -c conda-forge ${condaPackages.join(" ")} ${mods}`.trim(),
337
-
338
- // `conda config --file ${this.kernel.path('condarc')} --set remote_connect_timeout_secs 20`,
339
- // `conda config --file ${this.kernel.path('condarc')} --set remote_read_timeout_secs 300`,
340
- // `conda config --file ${this.kernel.path('condarc')} --set remote_max_retries 6`,
341
- // `conda config --file ${this.kernel.path('condarc')} --set repodata_threads 4`,
342
- // `conda config --file ${this.kernel.path('condarc')} --set fetch_threads 5`,
343
- // `conda config --file ${this.kernel.path('condarc')} --set report_errors false`,
344
-
345
-
346
-
347
- // `conda config --file ${this.kernel.path('condarc')} --set auto_update_conda false`,
348
- // "conda install -y -c conda-forge conda-libmamba-solver=24.11.1",
349
- // "conda install libsqlite --force-reinstall -y",
350
- // `conda config --file ${this.kernel.path('condarc')} --set auto_update_conda False`,
351
- //"conda install -y conda=24.9.0 -vvv --strict-channel-priority",
352
- //"conda install -y conda=24.11.3 conda-libmamba-solver=24.11.1 -vvv",
353
- //"conda install -y conda-libmamba-solver=24.7.0 conda=24.7.1 -vvv --strict-channel-priority",
354
- //"conda install -y conda-libmamba-solver=24.11.1 conda=24.7.1",
355
- //"conda install -y conda-libmamba-solver=24.11.1 conda=24.11.2",
356
- //"conda update -y conda-libmamba-solver",
357
- //"conda update -y conda sqlite",// -vvv --debug",
358
-
359
-
360
- // "conda update -y conda",// -vvv --debug",
361
- // "conda update -y --all",// -vvv --debug",
362
-
363
-
364
- // "python -m pip install --upgrade pip setuptools wheel",
365
- // "python -m ensurepip --upgrade",
366
- // "conda update -y conda",
367
- // "conda update -y --all",
274
+ `conda install -y --override-channels -c conda-forge ${condaPackages.join(" ")} ${mods}`.trim(),
368
275
  ]
369
- //if (this.kernel.platform === "win32" || this.kernel.platform === "darwin") {
370
- // cmds.push("conda install -y conda-libmamba-solver=24.7.0 conda=24.7.1 --freeze-installed")
371
- //}
372
276
  await this.kernel.bin.exec({
373
277
  message: cmds,
374
278
  env: {
375
279
  PIP_REQUIRE_VIRTUALENV: "false"
376
280
  }
377
- // conda: {
378
- // name: "base",
379
- // activate: "minimal"
380
- // }
381
- // [
382
- // (this.kernel.platform === 'win32' ? 'conda_hook' : `eval "$(conda shell.bash hook)"`),
383
- // (this.platform === 'win32' ? `activate base` : `conda activate base`),
384
- /*
385
- `conda config --file ${this.kernel.bin.path('miniconda', 'condarc')} --remove channels conda-forge`,
386
- `conda config --file ${this.kernel.bin.path('miniconda', 'condarc')} --remove channels defaults`,
387
- `conda config --file ${this.kernel.bin.path('miniconda', 'condarc')} --prepend channels defaults`,
388
- `conda config --file ${this.kernel.bin.path('miniconda', 'condarc')} --prepend channels conda-forge`,
389
- `conda config --file ${this.kernel.bin.path('miniconda', 'condarc')} --add create_default_packages python=3.10`,
390
- */
391
- //"conda update -y conda",
392
- //"conda update -n base -c conda-forge -c defaults conda",
393
-
394
-
395
- //"conda install conda=24.5.0",
396
- // "conda clean -y --index-cache",
397
- // "conda update -y --all",
398
- // "conda install conda=24.9.0"
399
-
400
-
401
- // handling the conda-libmamba-solver bug here: https://github.com/conda/conda-libmamba-solver/issues/283
402
-
403
-
404
- // "conda remove -y libarchive",
405
- // "conda install -y -c conda-forge libarchive",
406
- // "conda install -y -c conda-forge pip brotli brotlipy",
407
- // "conda install -y -c conda-forge libsqlite --force-reinstall",
408
- // "conda install conda"
409
-
410
-
411
- //"conda install -y -c conda-forge pip brotli brotlipy",
412
- // "conda update --all",
413
- // "conda update -y --all",
414
- // ]
415
281
  }, (stream) => {
416
282
  ondata(stream)
417
283
  })
418
284
  if (this.kernel.platform === "win32") {
419
285
  // copy python.exe to python3.exe so you can run with both python3 and python
420
286
  await fs.promises.copyFile(
421
- this.kernel.bin.path("miniconda", "python.exe"),
422
- this.kernel.bin.path("miniconda", "python3.exe"),
287
+ this.kernel.bin.path(CONDA_ROOT_DIR, "python.exe"),
288
+ this.kernel.bin.path(CONDA_ROOT_DIR, "python3.exe"),
423
289
  )
424
290
  }
425
291
  await this.ensureSslCertDirOverride()
292
+ await this.ensureCompatibilityAlias()
426
293
  ondata({ raw: `Install finished\r\n` })
427
294
  await this.kernel.bin.rm(installer, ondata)
428
295
  }
296
+ async removeInstallPath(target) {
297
+ try {
298
+ const stat = await fs.promises.lstat(target).catch((error) => {
299
+ if (error && error.code === "ENOENT") {
300
+ return null
301
+ }
302
+ throw error
303
+ })
304
+ if (!stat) {
305
+ return
306
+ }
307
+ if (stat.isSymbolicLink()) {
308
+ await fs.promises.rm(target, { force: true })
309
+ return
310
+ }
311
+ await fs.promises.rm(target, {
312
+ recursive: true,
313
+ force: true,
314
+ maxRetries: 5,
315
+ retryDelay: 250,
316
+ })
317
+ } catch (error) {
318
+ const reason = error && (error.code || error.message) ? error.code || error.message : String(error)
319
+ throw new Error([
320
+ `Pinokio needs to replace the Conda runtime at ${target}, but it could not delete that folder.`,
321
+ "Close Pinokio and any terminals or editors using Pinokio, delete that folder manually, then reopen Pinokio.",
322
+ `Original error: ${reason}`,
323
+ ].join("\n"))
324
+ }
325
+ }
326
+ async ensureCompatibilityAlias() {
327
+ const target = this.kernel.bin.path(CONDA_ROOT_DIR)
328
+ const alias = this.kernel.bin.path(LEGACY_CONDA_ROOT_DIR)
329
+ if (!(await this.hasCondaMeta())) {
330
+ return
331
+ }
332
+ const aliasExists = await fs.promises.lstat(alias).then(() => true).catch(() => false)
333
+ if (aliasExists) {
334
+ return
335
+ }
336
+ try {
337
+ await fs.promises.symlink(target, alias, this.kernel.platform === "win32" ? "junction" : "dir")
338
+ } catch (error) {
339
+ console.warn("Could not create Conda compatibility alias", error && error.message ? error.message : error)
340
+ }
341
+ }
429
342
  async exists(pattern) {
430
343
  let paths = this.paths[this.kernel.platform]
431
344
  for(let p of paths) {
432
- //let e = await this.kernel.bin.exists(p + "/" + name)
433
345
  const found = await glob(pattern, {
434
346
  cwd: this.kernel.bin.path(p)
435
347
  })
@@ -441,17 +353,18 @@ report_errors: false`)
441
353
  }
442
354
 
443
355
  async installed() {
444
- let e
445
356
  for(let p of this.paths[this.kernel.platform]) {
446
357
  let e = await this.kernel.bin.exists(p)
447
- if (e && this.kernel.bin.correct_conda) return true
358
+ if (e && this.kernel.bin.correct_conda) {
359
+ return true
360
+ }
448
361
  }
449
362
  return false
450
363
  }
451
364
 
452
- uninstall(req, ondata) {
453
- const install_path = this.kernel.bin.path("miniconda")
454
- return this.kernel.bin.rm(install_path, ondata)
365
+ async uninstall(req, ondata) {
366
+ await this.kernel.bin.rm(LEGACY_CONDA_ROOT_DIR, ondata)
367
+ return this.kernel.bin.rm(CONDA_ROOT_DIR, ondata)
455
368
  }
456
369
 
457
370
  onstart() {
@@ -5,7 +5,7 @@ const { glob } = require('glob')
5
5
  class Cuda {
6
6
  description = "Installs CUDA and cuDNN libraries for NVIDIA GPU workloads."
7
7
  async hasNvTargetHeader() {
8
- const prefix = this.kernel.bin.path("miniconda")
8
+ const prefix = this.kernel.bin.path("miniforge")
9
9
  const patterns = [
10
10
  "Library/include/nv/target",
11
11
  "include/nv/target",
@@ -33,7 +33,7 @@ class Cuda {
33
33
  if (this.kernel.platform !== "win32") {
34
34
  return
35
35
  }
36
- const script = this.kernel.bin.path("miniconda/etc/conda/activate.d/pinokio/~cuda-nvcc_activate.bat")
36
+ const script = this.kernel.bin.path("miniforge/etc/conda/activate.d/pinokio/~cuda-nvcc_activate.bat")
37
37
  let content
38
38
  try {
39
39
  content = await fs.promises.readFile(script, "utf8")
@@ -68,7 +68,7 @@ class Cuda {
68
68
  if (this.kernel.platform !== "win32") {
69
69
  return
70
70
  }
71
- const folder = this.kernel.bin.path("miniconda/etc/conda/activate.d")
71
+ const folder = this.kernel.bin.path("miniforge/etc/conda/activate.d")
72
72
  const stash = path.resolve(folder, "pinokio")
73
73
  await fs.promises.mkdir(stash, { recursive: true }).catch(() => {})
74
74
  const scripts = [
@@ -149,10 +149,10 @@ class Cuda {
149
149
  "vs2019_compiler_vars.bat",
150
150
  "vs2022_compiler_vars.bat",
151
151
  ]
152
- const folder = this.kernel.bin.path("miniconda/etc/conda/activate.d")
152
+ const folder = this.kernel.bin.path("miniforge/etc/conda/activate.d")
153
153
  let at_least_one_exists = false
154
154
  for(let item of deactivate_list) {
155
- let exists = await this.kernel.exists("bin/miniconda/etc/conda/activate.d/" + item)
155
+ let exists = await this.kernel.exists("bin/miniforge/etc/conda/activate.d/" + item)
156
156
  if (exists) {
157
157
  // break if at least one exists
158
158
  at_least_one_exists = true
@@ -190,11 +190,11 @@ class Cuda {
190
190
  env() {
191
191
  if (this.kernel.platform === 'win32') {
192
192
  return {
193
- CUDA_HOME: this.kernel.bin.path("miniconda/Library")
193
+ CUDA_HOME: this.kernel.bin.path("miniforge/Library")
194
194
  }
195
195
  } else {
196
196
  return {
197
- CUDA_HOME: this.kernel.bin.path("miniconda")
197
+ CUDA_HOME: this.kernel.bin.path("miniforge")
198
198
  }
199
199
  }
200
200
  }