Commit 719a46e5 authored by Julien Puydt's avatar Julien Puydt

Import jupyter-core_4.2.0.orig.tar.gz

parent 4a7eaee7
......@@ -15,3 +15,4 @@ __pycache__
.#*
.coverage
htmlcov
.cache
Changes in jupyter-core
=======================
4.2
---
4.2.0
~~~~~
`on
GitHub <https://github.com/jupyter/jupyter_core/releases/tag/4.2.0>`__
- Make :command:`jupyter` directory top priority in search path for subcommands,
so that :command:`jupyter-subcommand` next to :command:`jupyter` will always be picked if present.
- Avoid using ``shell=True`` for subcommand dispatch on Windows.
4.1
---
......
......@@ -93,7 +93,16 @@ def _execvp(cmd, argv):
Python provides execvp on Windows, but its behavior is problematic (Python bug#9148).
"""
if sys.platform.startswith('win'):
p = Popen([cmd] + argv[1:], shell=True)
# PATH is ignored when shell=False,
# so rely on shutil.which
try:
from shutil import which
except ImportError:
from .utils.shutil_which import which
cmd = which(cmd)
if cmd is None:
raise OSError('%r not found' % cmd, errno.ENOENT)
p = Popen([cmd] + argv[1:])
# Don't raise KeyboardInterrupt in the parent process.
# Set this after spawning, to avoid subprocess inheriting handler.
import signal
......@@ -105,20 +114,26 @@ def _execvp(cmd, argv):
def _path_with_self():
"""Ensure `jupyter`'s dir is on PATH"""
"""Put `jupyter`'s dir at the front of PATH
Ensures that /path/to/jupyter subcommand
will do /path/to/jupyter-subcommand
even if /other/jupyter-subcommand is ahead of it on PATH
"""
scripts = [sys.argv[0]]
if os.path.islink(scripts[0]):
# include realpath, if `jupyter` is a symlink
scripts.append(os.path.realpath(scripts[0]))
path_list = (os.environ.get('PATH') or os.defpath).split(os.pathsep)
for script in scripts:
bindir = os.path.dirname(script)
if (os.path.isdir(bindir)
and bindir not in path_list
and os.access(script, os.X_OK) # only if it's a script
):
# ensure executable's dir is on PATH
# avoids missing subcommands when jupyter is run via absolute path
path_list.append(bindir)
path_list.insert(0, bindir)
os.environ['PATH'] = os.pathsep.join(path_list)
return path_list
......
......@@ -115,3 +115,26 @@ def test_not_on_path(tmpdir):
witness.chmod(0o700)
out = check_output([sys.executable, str(jupyter), 'witness'], env={'PATH': ''})
assert b'WITNESS' in out
def test_path_priority(tmpdir):
a = tmpdir.mkdir("a")
jupyter = a.join('jupyter')
jupyter.write(
'from jupyter_core import command; command.main()'
)
jupyter.chmod(0o700)
witness_cmd = 'jupyter-witness'
if sys.platform == 'win32':
witness_cmd += '.py'
witness_a = a.join(witness_cmd)
witness_a.write('#!%s\n%s\n' % (sys.executable, 'print("WITNESS A")'))
witness_a.chmod(0o700)
b = tmpdir.mkdir("b")
witness_b = b.join(witness_cmd)
witness_b.write('#!%s\n%s\n' % (sys.executable, 'print("WITNESS B")'))
witness_b.chmod(0o700)
out = check_output([sys.executable, str(jupyter), 'witness'], env={'PATH': str(b)})
assert b'WITNESS A' in out
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
version_info = (4, 1, 1)
version_info = (4, 2, 0)
__version__ = '.'.join(map(str, version_info))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment