|
2 | 2 | jlab_enhanced_launcher setup |
3 | 3 | """ |
4 | 4 | import json |
5 | | -import os |
| 5 | +import sys |
| 6 | +from pathlib import Path |
6 | 7 |
|
7 | 8 | import setuptools |
8 | | -from jupyter_packaging import ( |
9 | | - create_cmdclass, install_npm, ensure_targets, |
10 | | - combine_commands, skip_if_exists |
11 | | -) |
12 | | -from packaging.version import parse |
13 | 9 |
|
14 | | -HERE = os.path.abspath(os.path.dirname(__file__)) |
| 10 | +HERE = Path(__file__).parent.resolve() |
15 | 11 |
|
16 | 12 | # The name of the project |
17 | 13 | name="jlab_enhanced_launcher" |
18 | 14 |
|
19 | | -# Get our version |
20 | | -with open(os.path.join(HERE, 'package.json')) as f: |
21 | | - version = str(parse(json.load(f)['version'])) |
22 | | - |
23 | | -lab_path = os.path.join(HERE, name, "labextension") |
| 15 | +lab_path = HERE / name.replace("-", "_") / "labextension" |
24 | 16 |
|
25 | 17 | # Representative files that should exist after a successful build |
26 | | -jstargets = [ |
27 | | - os.path.join(lab_path, "package.json"), |
28 | | -] |
29 | | - |
30 | | -package_data_spec = { |
31 | | - name.replace("_", "-"): [ |
32 | | - "*" |
33 | | - ] |
34 | | -} |
| 18 | +ensured_targets = [str(lab_path / "package.json"), str(lab_path / "static/style.js")] |
35 | 19 |
|
36 | 20 | labext_name = "@jlab-enhanced/launcher" |
37 | 21 |
|
38 | 22 | data_files_spec = [ |
39 | | - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), |
40 | | - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), |
| 23 | + ( |
| 24 | + "share/jupyter/labextensions/%s" % labext_name, |
| 25 | + str(lab_path.relative_to(HERE)), |
| 26 | + "**", |
| 27 | + ), |
| 28 | + ("share/jupyter/labextensions/%s" % labext_name, str("."), "install.json"), |
41 | 29 | ] |
42 | 30 |
|
43 | | -cmdclass = create_cmdclass("jsdeps", |
44 | | - package_data_spec=package_data_spec, |
45 | | - data_files_spec=data_files_spec |
46 | | -) |
| 31 | +long_description = (HERE / "README.md").read_text() |
47 | 32 |
|
48 | | -js_command = combine_commands( |
49 | | - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), |
50 | | - ensure_targets(jstargets), |
| 33 | +# Get the package info from package.json |
| 34 | +pkg_json = json.loads((HERE / "package.json").read_bytes()) |
| 35 | +version = ( |
| 36 | + pkg_json["version"] |
| 37 | + .replace("-alpha.", "a") |
| 38 | + .replace("-beta.", "b") |
| 39 | + .replace("-rc.", "rc") |
51 | 40 | ) |
52 | 41 |
|
53 | | -is_repo = os.path.exists(os.path.join(HERE, ".git")) |
54 | | -if is_repo: |
55 | | - cmdclass["jsdeps"] = js_command |
56 | | -else: |
57 | | - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) |
58 | | - |
59 | | -with open("README.md", "r") as fh: |
60 | | - long_description = fh.read() |
61 | | - |
62 | 42 | setup_args = dict( |
63 | | - name=name.replace("_", "-"), |
| 43 | + name=name, |
64 | 44 | version=version, |
65 | | - url="https://github.com/jupyterlab-contrib/jlab-enhanced-launcher.git", |
66 | | - author="Frederic COLLONVAL", |
67 | | - description="A enhanced launcher for JupyterLab", |
68 | | - long_description= long_description, |
| 45 | + url=pkg_json["homepage"], |
| 46 | + author=pkg_json["author"], |
| 47 | + description=pkg_json["description"], |
| 48 | + license=pkg_json["license"], |
| 49 | + long_description=long_description, |
69 | 50 | long_description_content_type="text/markdown", |
70 | | - cmdclass= cmdclass, |
71 | 51 | packages=setuptools.find_packages(), |
72 | | - install_requires=[ |
73 | | - "jupyterlab>=3.0.0rc13,==3.*", |
74 | | - "packaging" |
75 | | - ], |
76 | 52 | zip_safe=False, |
77 | 53 | include_package_data=True, |
78 | | - python_requires=">=3.6", |
79 | | - license="BSD-3-Clause", |
| 54 | + python_requires=">=3.7", |
80 | 55 | platforms="Linux, Mac OS X, Windows", |
81 | 56 | keywords=["Jupyter", "JupyterLab", "JupyterLab3"], |
82 | 57 | classifiers=[ |
83 | 58 | "License :: OSI Approved :: BSD License", |
84 | 59 | "Programming Language :: Python", |
85 | 60 | "Programming Language :: Python :: 3", |
86 | | - "Programming Language :: Python :: 3.6", |
87 | 61 | "Programming Language :: Python :: 3.7", |
88 | 62 | "Programming Language :: Python :: 3.8", |
89 | 63 | "Programming Language :: Python :: 3.9", |
| 64 | + "Programming Language :: Python :: 3.10", |
90 | 65 | "Framework :: Jupyter", |
| 66 | + "Framework :: Jupyter :: JupyterLab", |
| 67 | + "Framework :: Jupyter :: JupyterLab :: 3", |
| 68 | + "Framework :: Jupyter :: JupyterLab :: Extensions", |
| 69 | + "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", |
91 | 70 | ], |
92 | 71 | ) |
93 | 72 |
|
| 73 | +try: |
| 74 | + from jupyter_packaging import wrap_installers, npm_builder, get_data_files |
| 75 | + |
| 76 | + post_develop = npm_builder( |
| 77 | + build_cmd="install:extension", source_dir="src", build_dir=lab_path |
| 78 | + ) |
| 79 | + setup_args["cmdclass"] = wrap_installers( |
| 80 | + post_develop=post_develop, ensured_targets=ensured_targets |
| 81 | + ) |
| 82 | + setup_args["data_files"] = get_data_files(data_files_spec) |
| 83 | +except ImportError as e: |
| 84 | + import logging |
| 85 | + |
| 86 | + logging.basicConfig(format="%(levelname)s: %(message)s") |
| 87 | + logging.warning( |
| 88 | + "Build tool `jupyter-packaging` is missing. Install it with pip or conda." |
| 89 | + ) |
| 90 | + if not ("--name" in sys.argv or "--version" in sys.argv): |
| 91 | + raise e |
94 | 92 |
|
95 | 93 | if __name__ == "__main__": |
96 | 94 | setuptools.setup(**setup_args) |
0 commit comments