Parcourir la source

Switch to python 3.5+ (#5119)

* Switch to python 3.4+

* Bump launcher dep, version dep

* update classifiers

* fix appveyor python path

* Upgrade pip on appveyor

* remove redundant python build

* Remove redundant group

* Fix urllib imports

* fix missing import
Steven Silvester il y a 6 ans
Parent
commit
40530f84b8

+ 1 - 6
.travis.yml

@@ -15,14 +15,9 @@ matrix:
   - env: GROUP=integrity
   - env: GROUP=python
   - env: GROUP=js_services
-    python: 2.7
-  - env: GROUP=python
-    python: 3.5
-  - env: GROUP=python
   - env: GROUP=js_cov
   - env: GROUP=cli
-    python: 2.7
-  - env: GROUP=cli
+    python: 3.5
   - env: GROUP=docs
 env:
   global:

+ 3 - 2
appveyor.yml

@@ -8,8 +8,8 @@ matrix:
 environment:
   nodejs_version: "lts"
   matrix:
-    - PYTHON: C:\Miniconda
-      PYTHON_VERSION: 2.7
+    - PYTHON: C:\Miniconda35
+      PYTHON_VERSION: 3.5
       NAME: javascript
 
     - PYTHON: C:\Miniconda36-x64
@@ -42,6 +42,7 @@ install:
   # Ensure python and python scripts are from right version:
   - 'SET "PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"'
   # Install our package:
+  - 'python -m pip install -U pip'
   - 'pip install --upgrade -e ".[test]"'
   - 'jupyter kernelspec list'
   - 'jlpm versions'

+ 0 - 2
jupyterlab/browser_check.py

@@ -1,7 +1,5 @@
 
 # -*- coding: utf-8 -*-
-from __future__ import print_function, absolute_import
-
 from concurrent.futures import ThreadPoolExecutor
 from os import path as osp
 import os

+ 3 - 11
jupyterlab/commands.py

@@ -3,8 +3,6 @@
 
 # Copyright (c) Jupyter Development Team.
 # Distributed under the terms of the Modified BSD License.
-from __future__ import print_function
-
 import contextlib
 from distutils.version import LooseVersion
 import errno
@@ -19,9 +17,11 @@ import shutil
 import site
 import sys
 import tarfile
+from tempfile import TemporaryDirectory
 from threading import Event
+from urllib.request import Request, urlopen, urljoin, quote
+from urllib.error import URLError
 
-from ipython_genutils.tempdir import TemporaryDirectory
 from jupyter_core.paths import jupyter_config_path
 from jupyterlab_launcher.process import which, Process, WatchHelper
 from notebook.nbextensions import GREEN_ENABLED, GREEN_OK, RED_DISABLED, RED_X
@@ -29,14 +29,6 @@ from notebook.nbextensions import GREEN_ENABLED, GREEN_OK, RED_DISABLED, RED_X
 from .semver import Range, gte, lt, lte, gt, make_semver
 from .jlpmapp import YARN_PATH, HERE
 
-if sys.version_info.major < 3:
-    from urllib2 import Request, urlopen, quote
-    from urllib2 import URLError, HTTPError
-    from urlparse import urljoin
-else:
-    from urllib.request import Request, urlopen, urljoin, quote
-    from urllib.error import URLError, HTTPError
-
 
 # The regex for expecting the webpack output.
 WEBPACK_EXPECT = re.compile(r'.*/index.out.js')

+ 1 - 0
jupyterlab/jlpmapp.py

@@ -34,6 +34,7 @@ def execvp(cmd, argv):
     else:
         os.execvp(cmd, argv)
 
+
 def main(argv=None):
     """Run node and return the result.
     """

+ 0 - 2
jupyterlab/labextensions.py

@@ -3,8 +3,6 @@
 
 # Copyright (c) Jupyter Development Team.
 # Distributed under the terms of the Modified BSD License.
-from __future__ import print_function
-
 import os
 import sys
 import traceback

+ 1 - 0
jupyterlab/tests/echo_kernel.py

@@ -4,6 +4,7 @@ import logging
 from ipykernel.kernelapp import IPKernelApp
 from ipykernel.kernelbase import Kernel
 
+
 class EchoKernel(Kernel):
     implementation = 'Echo'
     implementation_version = '1.0'

+ 5 - 15
jupyterlab/tests/test_app.py

@@ -1,8 +1,6 @@
 # coding: utf-8
 """A lab app that runs a sub process for a demo or a test."""
 
-from __future__ import print_function, absolute_import
-
 from os import path as osp
 from os.path import join as pjoin
 from stat import S_IRUSR, S_IRGRP, S_IROTH
@@ -16,15 +14,11 @@ import pkg_resources
 import shutil
 import sys
 import tempfile
+from tempfile import TemporaryDirectory
+from unittest.mock import patch
 
-try:
-    from unittest.mock import patch
-except ImportError:
-    from mock import patch  # py2
 
 from traitlets import Unicode
-from ipython_genutils import py3compat
-from ipython_genutils.tempdir import TemporaryDirectory
 from ipykernel.kernelspec import write_kernel_spec
 import jupyter_core
 
@@ -33,7 +27,6 @@ import jupyterlab_launcher
 
 
 HERE = osp.realpath(osp.dirname(__file__))
-PY2 = sys.version_info[0] < 3
 
 
 def _create_notebook_dir():
@@ -47,7 +40,7 @@ def _create_notebook_dir():
     with open(readonly_filepath, 'w') as fid:
         fid.write('hello from a readonly file')
 
-    os.chmod(readonly_filepath, S_IRUSR|S_IRGRP|S_IROTH)
+    os.chmod(readonly_filepath, S_IRUSR | S_IRGRP | S_IROTH)
     atexit.register(lambda: shutil.rmtree(root_dir, True))
     return root_dir
 
@@ -231,12 +224,9 @@ class KarmaTestApp(ProcessTestApp):
                 '"@jupyterlab/test-<package_dir_name>"' % name
             )
 
-        if PY2:
-            karma_inject_file = karma_inject_file.encode('utf-8')
-            folder = folder.encode('utf-8')
         env = os.environ.copy()
         env['KARMA_INJECT_FILE'] = karma_inject_file
-        env.setdefault('KARMA_FILE_PATTERN', py3compat.unicode_to_str(pattern))
+        env.setdefault('KARMA_FILE_PATTERN', pattern)
         env.setdefault('KARMA_COVER_FOLDER', folder)
         cwd = self.karma_base_dir
         cmd = ['karma', 'start'] + sys.argv[1:]
@@ -254,4 +244,4 @@ def run_karma(base_dir):
 
 
 if __name__ == '__main__':
-    TestApp.launch_instance()
+    KarmaTestApp.launch_instance()

+ 2 - 3
jupyterlab/tests/test_build_api.py

@@ -1,8 +1,7 @@
 """Test the kernels service API."""
+from tempfile import TemporaryDirectory
 import threading
 
-from ipython_genutils.tempdir import TemporaryDirectory
-from ipython_genutils import py3compat
 from jupyterlab.labapp import LabApp
 from jupyterlab_launcher.tests.utils import APITester, LabTestBase
 from notebook.tests.launchnotebook import assert_http_error
@@ -29,7 +28,7 @@ class BuildAPITest(LabTestBase):
     def tempdir(self):
         td = TemporaryDirectory()
         self.tempdirs.append(td)
-        return py3compat.cast_unicode(td.name)
+        return td.name
 
     def setUp(self):
         # Any TemporaryDirectory objects appended to this list will be cleaned

+ 4 - 9
jupyterlab/tests/test_jupyterlab.py

@@ -9,16 +9,11 @@ import os
 import shutil
 import sys
 from os.path import join as pjoin
+from tempfile import TemporaryDirectory
 from unittest import TestCase
-import pytest
-
-try:
-    from unittest.mock import patch
-except ImportError:
-    from mock import patch  # py2
+from unittest.mock import patch
 
-from ipython_genutils import py3compat
-from ipython_genutils.tempdir import TemporaryDirectory
+import pytest
 from notebook.notebookapp import NotebookApp
 from jupyter_core import paths
 
@@ -56,7 +51,7 @@ class TestExtension(TestCase):
     def tempdir(self):
         td = TemporaryDirectory()
         self.tempdirs.append(td)
-        return py3compat.cast_unicode(td.name)
+        return td.name
 
     def setUp(self):
         # Any TemporaryDirectory objects appended to this list will be cleaned

+ 0 - 40
jupyterlab/update.py

@@ -1,40 +0,0 @@
-# coding: utf-8
-# Copyright (c) Jupyter Development Team.
-# Distributed under the terms of the Modified BSD License.
-from os.path import join as pjoin
-import json
-import os
-import shutil
-
-HERE = os.path.dirname(__file__)
-
-
-# Get the dev mode package.json file.
-dev_path = os.path.realpath(pjoin(HERE, '..', 'dev_mode'))
-with open(pjoin(dev_path, 'package.json')) as fid:
-    data = json.load(fid)
-
-
-# Update the values that need to change and write to staging.
-data['scripts']['build'] = 'webpack'
-data['scripts']['watch'] = 'webpack --watch'
-data['scripts']['build:prod'] = (
-    "webpack --define process.env.NODE_ENV=\"'production'\"")
-data['jupyterlab']['outputDir'] = '..'
-data['jupyterlab']['staticDir'] = '../static'
-data['jupyterlab']['linkedPackages'] = dict()
-
-staging = pjoin(HERE, 'staging')
-
-with open(pjoin(staging, 'package.json'), 'w') as fid:
-    json.dump(data, fid)
-
-# Update our index file and webpack file.
-for fname in ['index.js', 'webpack.config.js']:
-    shutil.copy(pjoin(dev_path, fname), pjoin(staging, fname))
-
-
-# Get a new yarn lock file.
-
-target = os.path.join(app_dir, 'staging', 'yarn.lock')
-shutil.copy(target, os.path.join(staging, 'yarn.lock'))

+ 3 - 8
setup.py

@@ -27,7 +27,7 @@ Development happens on https://github.com/jupyter/jupyterlab, with chat on
 https://gitter.im/jupyterlab/jupyterlab.
 """
 
-ensure_python(['2.7', '>=3.3'])
+ensure_python(['>=3.5'])
 
 data_files_spec = [
     ('share/jupyter/lab/static', '%s/static' % NAME, '**'),
@@ -120,9 +120,7 @@ setup_args = dict(
         'Intended Audience :: Science/Research',
         'License :: OSI Approved :: BSD License',
         'Programming Language :: Python',
-        'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',
     ],
@@ -131,14 +129,10 @@ setup_args = dict(
 
 setup_args['install_requires'] = [
     'notebook>=4.3.1',
-    'jupyterlab_launcher>=0.12.0,<0.13.0',
-    'ipython_genutils',
-    'futures;python_version<"3.0"',
-    'subprocess32;python_version<"3.0"'
+    'jupyterlab_launcher>=0.13.1,<0.14.0'
 ]
 
 setup_args['extras_require'] = {
-    'test:python_version == "2.7"': ['mock'],
     'test': ['pytest', 'requests', 'pytest-check-links'],
     'docs': [
         'sphinx',
@@ -149,6 +143,7 @@ setup_args['extras_require'] = {
 
 
 setup_args['include_package_data'] = True
+setup_args['python_requires'] = '>=3.5'
 
 # Force entrypoints with setuptools (needed for Windows, unconditional
 # because of wheels)