pinokiod 8.1.1 → 8.2.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.
@@ -3,6 +3,7 @@ const portfinder = require('portfinder-cp')
3
3
  const fs = require('fs')
4
4
  const Util = require('./util')
5
5
  const ManagedSkills = require('./managed_skills')
6
+ const { pipConfigDisabledPath } = require('./pip_env')
6
7
  const TEMP_ENV_KEYS = ["TMP", "TEMP", "TMPDIR", "PIP_TMPDIR"]
7
8
  const CACHE_ENV_KEYS = ["UV_CACHE_DIR", "PIP_CACHE_DIR"]
8
9
  const CACHE_PREFLIGHT_KEYS = TEMP_ENV_KEYS.concat(CACHE_ENV_KEYS)
@@ -311,7 +312,7 @@ const ENVS = async () => {
311
312
  type: ["system"],
312
313
  key: "PIP_CONFIG_FILE",
313
314
  hidden: true,
314
- val: "./pipconfig"
315
+ val: pipConfigDisabledPath(process.platform)
315
316
  }, {
316
317
  type: ["system"],
317
318
  key: "CONDARC",
@@ -0,0 +1,30 @@
1
+ const fs = require('fs/promises')
2
+ const path = require('path')
3
+
4
+ function pipConfigDisabledPath(platform) {
5
+ // pip compares this string exactly with Python's os.devnull.
6
+ return platform === 'win32' ? 'nul' : '/dev/null'
7
+ }
8
+
9
+ async function normalizeLegacyPipConfig(source, { platform, homedir }) {
10
+ if (typeof source.PIP_CONFIG_FILE !== 'string') return source
11
+ const legacyPath = path.resolve(homedir, 'pipconfig')
12
+ const configuredPath = path.resolve(source.PIP_CONFIG_FILE)
13
+ const comparable = value => platform === 'win32' ? value.toLowerCase() : value
14
+ if (comparable(configuredPath) !== comparable(legacyPath)) return source
15
+
16
+ try {
17
+ // The old config may have been replaced with a directory, device, or pipe.
18
+ if (!(await fs.stat(legacyPath)).isFile()) return source
19
+ const contents = await fs.readFile(legacyPath, 'utf8')
20
+ if (!/^\s*\[global\]\s+timeout\s*=\s*1000\s*$/.test(contents)) return source
21
+ } catch (error) {
22
+ // Failure to recognize the stock config must not prevent shell startup.
23
+ if (error.code !== 'ENOENT') return source
24
+ }
25
+ // Existing ENVIRONMENT files point at this generated timeout-only config.
26
+ // Retain customized configs as intentional overrides; never rewrite files.
27
+ return { ...source, PIP_CONFIG_FILE: pipConfigDisabledPath(platform) }
28
+ }
29
+
30
+ module.exports = { normalizeLegacyPipConfig, pipConfigDisabledPath }
package/kernel/shell.js CHANGED
@@ -15,6 +15,7 @@ const sudo = require("sudo-prompt-programfiles-x86");
15
15
  const unparse = require('yargs-unparser-custom-flag');
16
16
  const Util = require('./util')
17
17
  const Environment = require('./environment')
18
+ const { normalizeLegacyPipConfig, pipConfigDisabledPath } = require('./pip_env')
18
19
  const { applyWindowsNodePackageManagerEnv } = require('./windows_node_package_manager_env')
19
20
  const ShellParser = require('./shell_parser')
20
21
  const AnsiStreamTracker = require('./ansi_stream_tracker')
@@ -223,6 +224,10 @@ class Shell {
223
224
  let app_env = await Environment.get(api_path, this.kernel)
224
225
  this.env = Object.assign(this.env, app_env)
225
226
  }
227
+ this.env = await normalizeLegacyPipConfig(this.env, {
228
+ platform: this.platform,
229
+ homedir: this.kernel.homedir,
230
+ })
226
231
  stripInheritedCondaActivationState(this.env)
227
232
  let PATH_KEY = Object.keys(this.env).find((key) => key.toLowerCase() === "path") || "PATH";
228
233
  if (!this.env[PATH_KEY]) {
@@ -290,6 +295,14 @@ class Shell {
290
295
  }
291
296
  }
292
297
 
298
+ // An explicitly selected config supplies its own timeout defaults.
299
+ if (this.env.PIP_CONFIG_FILE === pipConfigDisabledPath(this.platform)) {
300
+ const hasPipTimeout = Object.keys(this.env).some(key => {
301
+ const name = this.platform === 'win32' ? key.toUpperCase() : key
302
+ return (name === 'PIP_TIMEOUT' || name === 'PIP_DEFAULT_TIMEOUT') && this.env[key] !== undefined
303
+ })
304
+ if (!hasPipTimeout) this.env.PIP_TIMEOUT = "1000"
305
+ }
293
306
  setDefaultEnvValue(this.env, "UV_HTTP_TIMEOUT", "60")
294
307
  setDefaultEnvValue(this.env, "HF_HUB_DISABLE_UPDATE_CHECK", "1")
295
308
  setDefaultEnvValue(this.env, "HF_TOKEN_PATH", this.kernel.envs?.HF_TOKEN_PATH || path.resolve(this.kernel.homedir, "cache", "HF_AUTH", "token"))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "8.1.1",
3
+ "version": "8.2.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -216,12 +216,10 @@ test('nested menus and shortcuts resolve relative paths from pinokio/', async ()
216
216
  { text: 'Start', href: 'start.js' },
217
217
  { text: 'Shell', run: 'echo ready' },
218
218
  { text: 'Stop', action: { method: 'stop', uri: 'start.js' } },
219
- { text: 'Absolute', action: { method: 'stop', uri: path.resolve('/abs', 'stop.js') } },
220
219
  { text: 'State', when: 'start.js', off: 'off' }
221
220
  ],
222
221
  shortcuts: [
223
- { action: { method: 'stop', uri: 'start.js' } },
224
- { action: { method: 'stop', uri: path.resolve('/abs', 'stop.js') } }
222
+ { action: { method: 'stop', uri: 'start.js' } }
225
223
  ]
226
224
  }
227
225
 
@@ -229,12 +227,10 @@ test('nested menus and shortcuts resolve relative paths from pinokio/', async ()
229
227
  assert.equal(config.menu[0].href, '/api/nested/pinokio/start.js')
230
228
  assert.equal(config.menu[1].cwd, launcher)
231
229
  assert.equal(config.menu[2].action.uri, '~/api/nested/pinokio/start.js')
232
- assert.equal(config.menu[3].action.uri, '~/api/nested/abs/stop.js')
233
230
  assert(checked.includes(path.resolve(launcher, 'start.js')))
234
231
 
235
232
  await server.renderShortcuts(kernel.path('api'), 'nested', config, [], 'pinokio')
236
233
  assert.equal(config.shortcuts[0].action.uri, '~/api/nested/pinokio/start.js')
237
- assert.equal(config.shortcuts[1].action.uri, '~/api/nested/abs/stop.js')
238
234
  })
239
235
  })
240
236