diff --git a/package.json b/package.json index 8c4011e0..02d6c2d2 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ ], "win": { "target": [ - "squirrel" + "squirrel", + "zip" ], "extraResources": [ { diff --git a/src/browser/containers/main.jsx b/src/browser/containers/main.jsx index 52040a83..e876f4bf 100644 --- a/src/browser/containers/main.jsx +++ b/src/browser/containers/main.jsx @@ -87,7 +87,9 @@ export default React.createClass({ store.dispatch(dialogActions.showRegisterRodeo()); // no visual for this please - applicationControl.checkForUpdates(); + if (local.get('enableAutoupdate') !== false) { + applicationControl.checkForUpdates(); + } // try and start an instance of the python client client.guaranteeInstance(); diff --git a/src/browser/containers/preferences-viewer/layout.yml b/src/browser/containers/preferences-viewer/layout.yml index acd00442..c2d0d449 100644 --- a/src/browser/containers/preferences-viewer/layout.yml +++ b/src/browser/containers/preferences-viewer/layout.yml @@ -308,6 +308,12 @@ label: alwaysAskBeforeQuiting type: checkbox value: true + - + id: enableAutoupdate + key: enableAutoupdate + label: enableAutoupdate + type: checkbox + value: true - id: preferences-project label: project diff --git a/src/browser/containers/text.yml b/src/browser/containers/text.yml index f700c361..1aadc50f 100644 --- a/src/browser/containers/text.yml +++ b/src/browser/containers/text.yml @@ -27,6 +27,7 @@ editingEnvironmentVariableExplanation: | Add or override environment variables editor: Editor emacs: Emacs +enableAutoupdate: Enable Autoupdates enableStartingTutorial: Enable the Starting Tutorial environmentVariables: Environment Variables environmentVariableExplanation: | diff --git a/src/node/kernels/python/client.js b/src/node/kernels/python/client.js index 8f614f2f..e70efd32 100644 --- a/src/node/kernels/python/client.js +++ b/src/node/kernels/python/client.js @@ -410,6 +410,8 @@ class JupyterClient extends EventEmitter { * @returns {object} */ function getPythonCommandOptions(options) { + log('info', 'getPythonCommandOptions', options); + return { cwd: options.cwd, env: pythonLanguage.setDefaultEnvVars(options.env), @@ -418,12 +420,18 @@ function getPythonCommandOptions(options) { }; } -function getPythonCmd(options) { - if (options.cmd === '') { - return pythonLanguage.getPythonPath(); +function containsResourcesPath(str) { + return _.isString(str) && str.indexOf(process.resourcesPath) > -1; +} + +function applyPythonCmd(options) { + if (options.cmd === '' || containsResourcesPath(options.cmd)) { + options = _.cloneDeep(options); + options.env = pythonLanguage.setBuiltinDefaultEnvVars(options.env); + options.cmd = pythonLanguage.getPythonPath(); } - return options.cmd; + return options; } /** @@ -435,11 +443,21 @@ function getPythonCmd(options) { * @returns {ChildProcess} */ function createPythonScriptProcess(options) { + log('info', 'createPythonScriptProcess', options); + options = resolveHomeDirectoryOptions(options); + + log('info', 'createPythonScriptProcess1', options); + + options = applyPythonCmd(options); + + log('info', 'createPythonScriptProcess2', options); + + const args = ['-c', listenScript, options.kernelName], cmdOptions = getPythonCommandOptions(options); - return processes.create(getPythonCmd(options), args, cmdOptions); + return processes.create(options.cmd, args, cmdOptions); } /** diff --git a/src/node/kernels/python/language.js b/src/node/kernels/python/language.js index 6a2e0de1..3d399c92 100644 --- a/src/node/kernels/python/language.js +++ b/src/node/kernels/python/language.js @@ -4,11 +4,11 @@ */ import _ from 'lodash'; -import fs from 'fs'; import path from 'path'; import envService from '../../services/env'; -const resourcesPath = process.resourcesPath; +const resourcesPath = process.resourcesPath, + log = require('../../services/log').asInternal(__filename); /** * @param {object} args @@ -21,12 +21,6 @@ function toPythonArgs(args) { }, {}); } -function addPath(envs, path) { - if (!_.includes(envs, path) && fs.existsSync(path)) { - envs.push(path); - } -} - function getCondaPath() { return path.join(resourcesPath, 'conda'); } @@ -40,35 +34,56 @@ function getStartKernelPath() { } function setDefaultEnvVars(env) { - if (_.isString(env.PATH) && process.platform === 'darwin') { - const splitter = ':', - envs = env.PATH.split(splitter); - addPath(envs, '/sbin'); - addPath(envs, '/usr/sbin'); - addPath(envs, '/usr/local/bin'); + log('info', 'setDefaultEnvVars', env); - env.PATH = envs.join(splitter); + if (process.platform === 'darwin') { + envService.appendToPath(env, '/sbin'); + envService.appendToPath(env, '/usr/sbin'); + envService.appendToPath(env, '/usr/local/bin'); } - return _.assign({ - PYTHONUNBUFFERED: '1', - PYTHONIOENCODING: 'utf-8' - }, env); + return setPythonConstants(env); +} + +function setBuiltinDefaultEnvVars(env) { + if (process.resourcesPath) { + log('info', 'setBuiltinDefaultEnvVars', env); + + if (!env.PATH && !env.Path) { + throw new Error('MISSING PATH in setBuiltinDefaultEnvVars'); + } + + envService.appendToPath(env, path.join(process.resourcesPath, 'conda')); + envService.appendToPath(env, path.join(process.resourcesPath, 'conda', 'bin')); + envService.appendToPath(env, path.join(process.resourcesPath, 'conda', 'Lib')); + envService.appendToPath(env, path.join(process.resourcesPath, 'conda', 'Lib', 'bin')); + envService.appendToPath(env, path.join(process.resourcesPath, 'conda', 'Scripts')); + envService.appendToPath(env, path.join(process.resourcesPath, 'conda', 'Scripts', 'bin')); + + envService.appendToPath(env, path.join(process.resourcesPath, 'conda', 'DLLs'), 'pythonPath'); + envService.appendToPath(env, path.join(process.resourcesPath, 'conda', 'Lib'), 'pythonPath'); + envService.appendToPath(env, path.join(process.resourcesPath, 'conda', 'Lib', 'site-packages'), 'pythonPath'); + } + + return env; +} + +function setPythonConstants(env) { + if (!env.PYTHONUNBUFFERED) { + env.PYTHONUNBUFFERED = '1'; + } + + if (!env.PYTHONIOENCODING) { + env.PYTHONIOENCODING = 'utf-8'; + } + + return env; } function extendOwnEnv() { if (process.resourcesPath) { envService.appendToPath(process.env, path.join(process.resourcesPath, 'conda')); - envService.appendToPath(process.env, path.join(process.resourcesPath, 'conda', 'bin')); - envService.appendToPath(process.env, path.join(process.resourcesPath, 'conda', 'Lib')); - envService.appendToPath(process.env, path.join(process.resourcesPath, 'conda', 'Lib', 'bin')); - envService.appendToPath(process.env, path.join(process.resourcesPath, 'conda', 'Scripts')); - envService.appendToPath(process.env, path.join(process.resourcesPath, 'conda', 'Scripts', 'bin')); - - envService.appendToPath(process.env, path.join(process.resourcesPath, 'conda', 'DLLs'), 'pythonPath'); - envService.appendToPath(process.env, path.join(process.resourcesPath, 'conda', 'Lib'), 'pythonPath'); - envService.appendToPath(process.env, path.join(process.resourcesPath, 'conda', 'Lib', 'site-packages'), 'pythonPath'); } if (process.platform !== 'win32') { @@ -77,13 +92,7 @@ function extendOwnEnv() { envService.appendToPath(process.env, '/usr/local/bin'); } - if (!process.env.PYTHONUNBUFFERED) { - process.env.PYTHONUNBUFFERED = '1'; - } - - if (!process.env.PYTHONIOENCODING) { - process.env.PYTHONIOENCODING = 'utf-8'; - } + return setPythonConstants(process.env); } export default { @@ -91,6 +100,7 @@ export default { getStartKernelPath, getPythonPath, getCondaPath, + setBuiltinDefaultEnvVars, setDefaultEnvVars, toPythonArgs };