Quellcode durchsuchen

Update the mock packages to jupyter-packaging 0.10 (#10177)

* Update test-hyphens mock package to jupyter-packaging 0.9

* Update to jupyter-packaging 0.10

* Update build cmd

* Update other mock packages to jupyter-packaging 0.10

* Fix build cmd

* Fix data files

* Remove source_dir

* Update mock packages
Jeremy Tuloup vor 3 Jahren
Ursprung
Commit
5b5af1ee9f

+ 2 - 3
jupyterlab/federated_labextensions.py

@@ -355,7 +355,6 @@ def _get_labextension_metadata(module):
         Importable Python module exposing the
         magic-named `_jupyter_labextension_paths` function
     """
-
     mod_path = osp.abspath(module)
     if not osp.exists(mod_path):
         raise FileNotFoundError('The path `{}` does not exist.'.format(mod_path))
@@ -422,6 +421,6 @@ def _get_labextension_metadata(module):
                 if hasattr(m, '_jupyter_labextension_paths') :
                     return m, m._jupyter_labextension_paths()
             except Exception:
-                m = None            
-            
+                m = None
+
     raise ModuleNotFoundError('There is not a labextensions at {}'.format(module))

+ 15 - 2
jupyterlab/tests/mock_packages/test-hyphens-underscore/pyproject.toml

@@ -1,3 +1,16 @@
 [build-system]
-requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
-build-backend = "setuptools.build_meta"
+requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"]
+build-backend = "jupyter_packaging.build_api"
+
+[tool.jupyter-packaging.options]
+ensured-targets = ["test_hyphens_underscore/labextension/package.json"]
+
+[tool.jupyter-packaging.builder]
+factory = "jupyter_packaging.npm_builder"
+
+[tool.jupyter-packaging.build-args]
+build_cmd = "build:labextension"
+npm = ["jlpm"]
+
+[tool.check-manifest]
+ignore = ["test_hyphens_underscore/labextension/**", "yarn.lock", ".*", "package-lock.json"]

+ 27 - 37
jupyterlab/tests/mock_packages/test-hyphens-underscore/setup.py

@@ -1,46 +1,36 @@
 from os import path
 from setuptools import setup
-from jupyter_packaging import (
-    create_cmdclass, install_npm,
-    ensure_targets, combine_commands
-)
 
-version = '3.0.2'
-name = 'test-hyphens-underscore'
-module_name = 'test_hyphens_underscore'
-lab_ext_name = 'test-hyphens-underscore'
+version = "3.0.2"
+name = "test-hyphens-underscore"
+module_name = "test_hyphens_underscore"
+lab_ext_name = "test-hyphens-underscore"
 
 HERE = path.abspath(path.dirname(__file__))
-lab_path = path.join(HERE, module_name, 'labextension')
-
-# Representative files that should exist after a successful build
-jstargets = [
-    path.join(lab_path, 'package.json'),
-]
-
-package_data_spec = {
-    module_name: [
-        'labextension/*'
-    ]
-}
-
-data_files_spec = [
-    ("share/jupyter/labextensions/" + lab_ext_name, lab_path, "**")
-]
-
-cmdclass = create_cmdclass('js', package_data_spec=package_data_spec, data_files_spec=data_files_spec)
-cmdclass['js'] = combine_commands(
-    install_npm(
-        path=path.join(HERE),
-        npm=["jlpm"],
-        build_cmd="build:labextension"
-    ),
-    ensure_targets(jstargets),
-)
+lab_path = path.join(HERE, module_name, "labextension")
 
-setup(
+data_files_spec = [("share/jupyter/labextensions/" + lab_ext_name, lab_path, "**")]
+
+setup_args = dict(
     name=name,
     version=version,
-    packages=[module_name],
-    cmdclass=cmdclass
+    packages=[module_name]
 )
+
+
+try:
+    from jupyter_packaging import get_data_files, npm_builder, wrap_installers
+    post_develop = npm_builder(
+        build_cmd="build:labextension", build_dir=lab_path, npm=["jlpm"]
+    )
+    cmdclass = wrap_installers(post_develop=post_develop)
+
+    setup_args.update(dict(
+        cmdclass=cmdclass,
+        data_files=get_data_files(data_files_spec),
+    ))
+except ImportError:
+    pass
+
+
+setup(**setup_args)

+ 2 - 2
jupyterlab/tests/mock_packages/test-hyphens/package.json

@@ -8,10 +8,10 @@
     "clean": "rimraf ./test-hyphens/labextension"
   },
   "dependencies": {
-    "@jupyterlab/launcher": "^3.0.2"
+    "@jupyterlab/launcher": "^3.1.0-alpha.5"
   },
   "devDependencies": {
-    "@jupyterlab/builder": "^3.0.1",
+    "@jupyterlab/builder": "^3.1.0-alpha.5",
     "rimraf": "^3.0.2"
   },
   "files": [

+ 15 - 2
jupyterlab/tests/mock_packages/test-hyphens/pyproject.toml

@@ -1,3 +1,16 @@
 [build-system]
-requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
-build-backend = "setuptools.build_meta"
+requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"]
+build-backend = "jupyter_packaging.build_api"
+
+[tool.jupyter-packaging.options]
+ensured-targets = ["test-hyphens/labextension/package.json"]
+
+[tool.jupyter-packaging.builder]
+factory = "jupyter_packaging.npm_builder"
+
+[tool.jupyter-packaging.build-args]
+build_cmd = "build:labextension"
+npm = ["jlpm"]
+
+[tool.check-manifest]
+ignore = ["test-hyphens/labextension/**", "yarn.lock", ".*", "package-lock.json"]

+ 27 - 37
jupyterlab/tests/mock_packages/test-hyphens/setup.py

@@ -1,46 +1,36 @@
 from os import path
 from setuptools import setup
-from jupyter_packaging import (
-    create_cmdclass, install_npm,
-    ensure_targets, combine_commands
-)
 
-version = '3.0.2'
-name = 'test-hyphens'
-module_name = 'test-hyphens'
-lab_ext_name = 'test-hyphens'
+version = "3.0.2"
+name = "test-hyphens"
+module_name = "test-hyphens"
+lab_ext_name = "test-hyphens"
 
 HERE = path.abspath(path.dirname(__file__))
-lab_path = path.join(HERE, module_name, 'labextension')
-
-# Representative files that should exist after a successful build
-jstargets = [
-    path.join(lab_path, 'package.json'),
-]
-
-package_data_spec = {
-    module_name: [
-        'labextension/*'
-    ]
-}
-
-data_files_spec = [
-    ("share/jupyter/labextensions/" + lab_ext_name, lab_path, "**")
-]
-
-cmdclass = create_cmdclass('js', package_data_spec=package_data_spec, data_files_spec=data_files_spec)
-cmdclass['js'] = combine_commands(
-    install_npm(
-        path=path.join(HERE),
-        npm=["jlpm"],
-        build_cmd="build:labextension"
-    ),
-    ensure_targets(jstargets),
-)
+lab_path = path.join(HERE, module_name, "labextension")
 
-setup(
+data_files_spec = [("share/jupyter/labextensions/" + lab_ext_name, lab_path, "**")]
+
+setup_args = dict(
     name=name,
     version=version,
-    packages=[module_name],
-    cmdclass=cmdclass
+    packages=[module_name]
 )
+
+try:
+    from jupyter_packaging import get_data_files, npm_builder, wrap_installers
+    post_develop = npm_builder(
+        build_cmd="build:labextension", build_dir=lab_path, npm=["jlpm"]
+    )
+
+    cmdclass = wrap_installers(post_develop=post_develop)
+
+    setup_args.update(dict(
+        cmdclass=cmdclass,
+        data_files=get_data_files(data_files_spec),
+    ))
+except ImportError:
+    pass
+
+
+setup(**setup_args)

+ 15 - 2
jupyterlab/tests/mock_packages/test_no_hyphens/pyproject.toml

@@ -1,3 +1,16 @@
 [build-system]
-requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
-build-backend = "setuptools.build_meta"
+requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"]
+build-backend = "jupyter_packaging.build_api"
+
+[tool.jupyter-packaging.options]
+ensured-targets = ["test_no_underscore/labextension/package.json"]
+
+[tool.jupyter-packaging.builder]
+factory = "jupyter_packaging.npm_builder"
+
+[tool.jupyter-packaging.build-args]
+build_cmd = "build:labextension"
+npm = ["jlpm"]
+
+[tool.check-manifest]
+ignore = ["test_no_underscore/labextension/**", "yarn.lock", ".*", "package-lock.json"]

+ 26 - 37
jupyterlab/tests/mock_packages/test_no_hyphens/setup.py

@@ -1,46 +1,35 @@
 from os import path
 from setuptools import setup
-from jupyter_packaging import (
-    create_cmdclass, install_npm,
-    ensure_targets, combine_commands
-)
 
-version = '3.0.2'
-name = 'test_no_hyphens'
-module_name = 'test_no_hyphens'
-lab_ext_name = 'test_no_hyphens'
+version = "3.0.2"
+name = "test_no_hyphens"
+module_name = "test_no_hyphens"
+lab_ext_name = "test_no_hyphens"
 
 HERE = path.abspath(path.dirname(__file__))
-lab_path = path.join(HERE, module_name, 'labextension')
-
-# Representative files that should exist after a successful build
-jstargets = [
-    path.join(lab_path, 'package.json'),
-]
-
-package_data_spec = {
-    module_name: [
-        'labextension/*'
-    ]
-}
-
-data_files_spec = [
-    ("share/jupyter/labextensions/" + lab_ext_name, lab_path, "**")
-]
-
-cmdclass = create_cmdclass('js', package_data_spec=package_data_spec, data_files_spec=data_files_spec)
-cmdclass['js'] = combine_commands(
-    install_npm(
-        path=path.join(HERE),
-        npm=["jlpm"],
-        build_cmd="build:labextension"
-    ),
-    ensure_targets(jstargets),
-)
+lab_path = path.join(HERE, module_name, "labextension")
 
-setup(
+data_files_spec = [("share/jupyter/labextensions/" + lab_ext_name, lab_path, "**")]
+
+setup_args = dict(
     name=name,
     version=version,
-    packages=[module_name],
-    cmdclass=cmdclass
+    packages=[module_name]
 )
+
+
+try:
+    from jupyter_packaging import get_data_files, npm_builder, wrap_installers
+    post_develop = npm_builder(
+        build_cmd="build:labextension", build_dir=lab_path, npm=["jlpm"]
+    )
+    cmdclass = wrap_installers(post_develop=post_develop)
+    setup_args.update(dict(
+        cmdclass=cmdclass,
+        data_files=get_data_files(data_files_spec)
+    ))
+except ImportError:
+    pass
+
+
+setup(**setup_args)

+ 3 - 0
scripts/ci_script.sh

@@ -216,8 +216,11 @@ if [[ $GROUP == usage ]]; then
     jupyter labextension build extension
 
     # Test develop script with hyphens and underscores in the module name
+    pip install -e test-hyphens
     jupyter labextension develop test-hyphens --overwrite --debug
+    pip install -e test_no_hyphens
     jupyter labextension develop test_no_hyphens --overwrite --debug
+    pip install -e test-hyphens-underscore
     jupyter labextension develop test-hyphens-underscore --overwrite --debug
 
     python -m jupyterlab.browser_check