[Python-modules-commits] [jupyter-core] 03/12: Import jupyter-core_4.1.0.orig.tar.gz
Julien Cristau
jcristau at moszumanska.debian.org
Fri Apr 8 09:39:33 UTC 2016
This is an automated email from the git hooks/post-receive script.
jcristau pushed a commit to branch master
in repository jupyter-core.
commit d48348ce954c43313119bf18eb71f8b4e66d5ee5
Author: Julien Cristau <julien.cristau at logilab.fr>
Date: Fri Apr 8 10:59:56 2016 +0200
Import jupyter-core_4.1.0.orig.tar.gz
---
PKG-INFO | 2 +-
docs/changelog.rst | 15 ++++++
jupyter.py | 4 ++
jupyter_core/command.py | 23 ++++++--
jupyter_core/migrate.py | 2 +
jupyter_core/tests/test_command.py | 19 ++++++-
jupyter_core/tests/test_migrate.py | 5 +-
jupyter_core/troubleshoot.py | 104 +++++++++++++++++++++++++++++++++++++
jupyter_core/version.py | 2 +-
setup.py | 2 +
10 files changed, 169 insertions(+), 9 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 45d9076..c3ab83a 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: jupyter_core
-Version: 4.0.6
+Version: 4.1.0
Summary: Jupyter core package. A base package on which Jupyter projects rely.
Home-page: http://jupyter.org
Author: Jupyter Development Team
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 3094b27..39bb152 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -1,6 +1,21 @@
Changes in jupyter-core
=======================
+4.1
+---
+
+4.1.0
+~~~~~
+
+`on
+GitHub <https://github.com/jupyter/jupyter_core/releases/tag/4.1>`__
+
+- Add ``jupyter.py`` module, so that :command:`python -m jupyter` always works.
+- Add prototype ``jupyter troubleshoot`` command for displaying environment info.
+- Ensure directory containing ``jupyter`` executable is included when dispatching subcommands.
+- Unicode fixes for Legacy Python.
+
+
4.0
---
diff --git a/jupyter.py b/jupyter.py
new file mode 100644
index 0000000..1860cc4
--- /dev/null
+++ b/jupyter.py
@@ -0,0 +1,4 @@
+"""Launch the root jupyter command"""
+if __name__ == '__main__':
+ from jupyter_core.command import main
+ main()
diff --git a/jupyter_core/command.py b/jupyter_core/command.py
index ba783b2..0c42086 100644
--- a/jupyter_core/command.py
+++ b/jupyter_core/command.py
@@ -56,6 +56,7 @@ def jupyter_parser():
return parser
+
def list_subcommands():
"""List all jupyter subcommands
@@ -64,10 +65,9 @@ def list_subcommands():
Returns a list of jupyter's subcommand names, without the `jupyter-` prefix.
Nested children (e.g. jupyter-sub-subsub) are not included.
"""
- path = os.environ.get('PATH') or os.defpath
subcommand_tuples = set()
# construct a set of `('foo', 'bar') from `jupyter-foo-bar`
- for d in path.split(os.pathsep):
+ for d in _path_with_self():
try:
names = os.listdir(d)
except OSError:
@@ -93,7 +93,7 @@ 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:])
+ p = Popen([cmd] + argv[1:], shell=True)
# Don't raise KeyboardInterrupt in the parent process.
# Set this after spawning, to avoid subprocess inheriting handler.
import signal
@@ -104,7 +104,24 @@ def _execvp(cmd, argv):
os.execvp(cmd, argv)
+def _path_with_self():
+ """Ensure `jupyter`'s dir is on PATH"""
+ script = sys.argv[0]
+ bindir = os.path.dirname(script)
+ path_list = (os.environ.get('PATH') or os.defpath).split(os.pathsep)
+ 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)
+ os.environ['PATH'] = os.pathsep.join(path_list)
+ return path_list
+
+
def main():
+ _path_with_self() # ensure executable is on PATH
if len(sys.argv) > 1 and not sys.argv[1].startswith('-'):
# Don't parse if a subcommand is given
# Avoids argparse gobbling up args passed to subcommand, such as `-h`.
diff --git a/jupyter_core/migrate.py b/jupyter_core/migrate.py
index 8a6a58e..302f4a5 100644
--- a/jupyter_core/migrate.py
+++ b/jupyter_core/migrate.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
"""Migrating IPython < 4.0 to Jupyter
This *copies* configuration and resources to their new locations in Jupyter
diff --git a/jupyter_core/tests/test_command.py b/jupyter_core/tests/test_command.py
index 1f6a9da..d5bcafa 100644
--- a/jupyter_core/tests/test_command.py
+++ b/jupyter_core/tests/test_command.py
@@ -7,7 +7,7 @@ from subprocess import check_output, CalledProcessError
import pytest
try:
- from unitteset.mock import patch
+ from unittest.mock import patch
except ImportError:
# py2
from mock import patch
@@ -76,6 +76,7 @@ def test_subcommand_not_found():
with pytest.raises(CalledProcessError):
output = get_jupyter_output('nonexistant-subcommand')
+ at patch.object(sys, 'argv', [__file__] + sys.argv[1:])
def test_subcommand_list(tmpdir):
a = tmpdir.mkdir("a")
for cmd in ('jupyter-foo-bar',
@@ -98,3 +99,19 @@ def test_subcommand_list(tmpdir):
'xyz',
'yo-eyropa-ganymyde-callysto',
]
+
+def test_not_on_path(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.join(witness_cmd)
+ witness.write('#!%s\n%s\n' % (sys.executable, 'print("WITNESS ME")'))
+ witness.chmod(0o700)
+ out = check_output([sys.executable, str(jupyter), 'witness'], env={'PATH': ''})
+ assert b'WITNESS' in out
diff --git a/jupyter_core/tests/test_migrate.py b/jupyter_core/tests/test_migrate.py
index b83d164..799da33 100644
--- a/jupyter_core/tests/test_migrate.py
+++ b/jupyter_core/tests/test_migrate.py
@@ -1,4 +1,5 @@
"""Test config file migration"""
+# coding: utf-8
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
@@ -36,7 +37,7 @@ dotipython_empty = pjoin(here, 'dotipython_empty')
@pytest.fixture
def td(request):
"""Fixture for a temporary directory"""
- td = mkdtemp()
+ td = mkdtemp(u'μnïcø∂e')
request.addfinalizer(lambda : shutil.rmtree(td))
return td
@@ -215,5 +216,3 @@ def test_migrate(env):
migrate()
assert os.path.exists(env['JUPYTER_CONFIG_DIR'])
assert os.path.exists(env['JUPYTER_DATA_DIR'])
-
-
diff --git a/jupyter_core/troubleshoot.py b/jupyter_core/troubleshoot.py
new file mode 100755
index 0000000..4ad03b4
--- /dev/null
+++ b/jupyter_core/troubleshoot.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+"""
+display environment information that isfrequently
+used to troubleshoot installations of Jupyter or IPython
+"""
+
+# import argparse
+import os
+import platform
+import subprocess
+import sys
+
+
+# def get_args():
+# """
+# TODO: output in JSON or xml? maybe?
+# """
+# pass
+
+def subs(cmd):
+ """
+ get data from commands that we need to run outside of python
+ """
+ try:
+ stdout = subprocess.check_output(cmd)
+ return stdout.decode('utf-8', 'replace').strip()
+ except (OSError, subprocess.CalledProcessError):
+ return None
+
+
+def get_data():
+ """
+ returns a dict of various user environment data
+ """
+ env = {}
+ env['path'] = os.environ.get('PATH')
+ env['sys_path'] = sys.path
+ env['sys_exe'] = sys.executable
+ env['sys_version'] = sys.version
+ env['platform'] = platform.platform()
+ # FIXME: which on Windows?
+ if sys.platform == 'win32':
+ env['where'] = subs(['where', 'jupyter'])
+ env['which'] = None
+ else:
+ env['which'] = subs(['which', '-a', 'jupyter'])
+ env['where'] = None
+ env['pip'] = subs(['pip', 'list'])
+ env['conda'] = subs(['conda', 'list'])
+ return env
+
+
+def main():
+ """
+ print out useful info
+ """
+ #pylint: disable=superfluous-parens
+ # args = get_args()
+ environment_data = get_data()
+
+ print('$PATH:')
+ for directory in environment_data['path'].split(':'):
+ print('\t' + directory)
+
+ print('\n' + 'sys.path:')
+ for directory in environment_data['sys_path']:
+ print('\t' + directory)
+
+ print('\n' + 'sys.executable:')
+ print('\t' + environment_data['sys_exe'])
+
+ print('\n' + 'sys.version:')
+ if '\n' in environment_data['sys_version']:
+ for data in environment_data['sys_version'].split('\n'):
+ print('\t' + data)
+ else:
+ print('\t' + environment_data['sys_version'])
+
+ print('\n' + 'platform.platform():')
+ print('\t' + environment_data['platform'])
+
+ if environment_data['which']:
+ print('\n' + 'which -a jupyter:')
+ for line in environment_data['which'].split('\n'):
+ print('\t' + line)
+
+ if environment_data['where']:
+ print('\n' + 'where jupyter:')
+ for line in environment_data['where'].split('\n'):
+ print('\t' + line)
+
+ if environment_data['pip']:
+ print('\n' + 'pip list:')
+ for package in environment_data['pip'].split('\n'):
+ print('\t' + package)
+
+ if environment_data['conda']:
+ print('\n' + 'conda list:')
+ for package in environment_data['conda'].split('\n'):
+ print('\t' + package)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/jupyter_core/version.py b/jupyter_core/version.py
index 9db0989..31b0a68 100644
--- a/jupyter_core/version.py
+++ b/jupyter_core/version.py
@@ -1,6 +1,6 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
-version_info = (4, 0, 6)
+version_info = (4, 1, 0)
__version__ = '.'.join(map(str, version_info))
diff --git a/setup.py b/setup.py
index f155663..f041234 100644
--- a/setup.py
+++ b/setup.py
@@ -51,6 +51,7 @@ setup_args = dict(
packages = ['jupyter_core',
'jupyter_core.utils',
'jupyter_core.tests'],
+ py_modules = ['jupyter'],
package_data = package_data,
scripts = glob(pjoin('scripts', '*')),
description = "Jupyter core package. A base package on which Jupyter projects rely.",
@@ -86,6 +87,7 @@ setuptools_args['entry_points'] = {
'console_scripts': [
'jupyter = jupyter_core.command:main',
'jupyter-migrate = jupyter_core.migrate:main',
+ 'jupyter-troubleshoot = jupyter_core.troubleshoot:main',
]
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/jupyter-core.git
More information about the Python-modules-commits
mailing list