|
1 | 1 | """ |
2 | | -jupyterlab-favorites setup |
| 2 | +jupyterlab_search_replace setup |
3 | 3 | """ |
4 | 4 | import json |
| 5 | +import sys |
5 | 6 | from pathlib import Path |
6 | 7 |
|
7 | | -from jupyter_packaging import ( |
8 | | - create_cmdclass, |
9 | | - install_npm, |
10 | | - ensure_targets, |
11 | | - combine_commands, |
12 | | - skip_if_exists |
13 | | -) |
14 | 8 | import setuptools |
15 | 9 |
|
16 | 10 | HERE = Path(__file__).parent.resolve() |
17 | 11 |
|
18 | 12 | # The name of the project |
19 | 13 | name = "jupyterlab-favorites" |
20 | | -python_name = name.replace("-", "_") |
21 | 14 |
|
22 | | -lab_path = (HERE / python_name / "labextension") |
| 15 | +lab_path = HERE / name.replace("-", "_") / "labextension" |
23 | 16 |
|
24 | 17 | # Representative files that should exist after a successful build |
25 | | -jstargets = [ |
26 | | - str(lab_path / "package.json"), |
27 | | -] |
28 | | - |
29 | | -package_data_spec = { |
30 | | - name: ["*"], |
31 | | -} |
| 18 | +ensured_targets = [str(lab_path / "package.json"), str(lab_path / "static/style.js")] |
32 | 19 |
|
33 | 20 | labext_name = "@jlab-enhanced/favorites" |
34 | 21 |
|
35 | 22 | data_files_spec = [ |
36 | | - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), |
37 | | - ("share/jupyter/labextensions/%s" % labext_name, str(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"), |
38 | 29 | ] |
39 | 30 |
|
40 | | -cmdclass = create_cmdclass("jsdeps", |
41 | | - package_data_spec=package_data_spec, |
42 | | - data_files_spec=data_files_spec |
43 | | -) |
44 | | - |
45 | | -js_command = combine_commands( |
46 | | - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), |
47 | | - ensure_targets(jstargets), |
48 | | -) |
49 | | - |
50 | | -is_repo = (HERE / ".git").exists() |
51 | | -if is_repo: |
52 | | - cmdclass["jsdeps"] = js_command |
53 | | -else: |
54 | | - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) |
55 | | - |
56 | 31 | long_description = (HERE / "README.md").read_text() |
57 | 32 |
|
58 | 33 | # Get the package info from package.json |
59 | 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") |
| 40 | +) |
60 | 41 |
|
61 | 42 | setup_args = dict( |
62 | | - name=python_name, |
63 | | - version=pkg_json["version"], |
| 43 | + name=name, |
| 44 | + version=version, |
64 | 45 | url=pkg_json["homepage"], |
65 | 46 | author=pkg_json["author"], |
66 | 47 | description=pkg_json["description"], |
67 | 48 | license=pkg_json["license"], |
68 | 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", |
74 | | - ], |
75 | 52 | zip_safe=False, |
76 | 53 | include_package_data=True, |
77 | | - python_requires=">=3.6", |
| 54 | + python_requires=">=3.7", |
78 | 55 | platforms="Linux, Mac OS X, Windows", |
79 | 56 | keywords=pkg_json["keywords"], |
80 | 57 | classifiers=[ |
81 | 58 | "License :: OSI Approved :: BSD License", |
82 | 59 | "Programming Language :: Python", |
83 | 60 | "Programming Language :: Python :: 3", |
84 | | - "Programming Language :: Python :: 3.6", |
85 | 61 | "Programming Language :: Python :: 3.7", |
86 | 62 | "Programming Language :: Python :: 3.8", |
87 | 63 | "Programming Language :: Python :: 3.9", |
| 64 | + "Programming Language :: Python :: 3.10", |
88 | 65 | "Framework :: Jupyter", |
| 66 | + "Framework :: Jupyter :: JupyterLab", |
| 67 | + "Framework :: Jupyter :: JupyterLab :: 3", |
| 68 | + "Framework :: Jupyter :: JupyterLab :: Extensions", |
| 69 | + "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", |
89 | 70 | ], |
90 | 71 | ) |
91 | 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 |
92 | 92 |
|
93 | 93 | if __name__ == "__main__": |
94 | 94 | setuptools.setup(**setup_args) |
0 commit comments