-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
68 lines (54 loc) · 2.05 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright (c) Jupyter Accessibility Team.
# Distributed under the terms of the Modified BSD License.
"""Setup module for jupyterlab_accessible_themes."""
import json
import os
from pathlib import Path
import setuptools
def get_long_description():
"""Get packge description from README.md."""
with open(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "README.md"),
encoding="utf8",
) as fp:
return fp.read()
HERE = Path(__file__).parent
MOD = "jupyterlab_accessible_themes"
VARIANTS = ["pitayasmoothie", "githublight", "githubdark"]
EXTS = [HERE / MOD / f"labextensions/{v}" for v in VARIANTS]
MANIFESTS = [ext / "package.json" for ext in EXTS]
PACKAGES = [json.loads(pkg_json.read_text(encoding="utf-8")) for pkg_json in MANIFESTS]
SHARE = "share/jupyter/labextensions"
EXT_FILES = {f"""{SHARE}/{pkg["name"]}""": ["install.json"] for pkg in PACKAGES}
for ext, pkg in zip(EXTS, PACKAGES):
for ext_path in [ext] + [d for d in ext.rglob("*") if d.is_dir()]:
target = f"""{SHARE}/{pkg["name"]}"""
if ext_path != ext:
target = f"""{target}/{ext_path.relative_to(ext)}"""
EXT_FILES[target] = [
str(p.relative_to(HERE).as_posix())
for p in ext_path.glob("*")
if not p.is_dir()
]
DATA_FILES = sorted(EXT_FILES.items())
pkg_name = HERE / "package.json"
PKG_INFO = json.loads(pkg_name.read_text(encoding="utf-8"))
SETUP_ARGS = {
"name": PKG_INFO["name"],
"description": PKG_INFO["description"],
"version": PKG_INFO["version"],
"url": PKG_INFO["homepage"],
"license": PKG_INFO["license"],
"packages": ["jupyterlab_accessible_themes"],
"long_description": get_long_description(),
"long_description_content_type": "text/markdown",
"data_files": DATA_FILES,
"project_urls": {
"Bug Tracker": PKG_INFO["bugs"]["url"],
"Source Code": PKG_INFO["repository"]["url"],
},
"author": "quansight-labs",
"author_email": "[email protected]",
}
if __name__ == "__main__":
setuptools.setup(**SETUP_ARGS)