forked from widgetti/ipyvuetify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
58 lines (40 loc) · 1.87 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
import sys
from pathlib import Path
from pynpm import NPMPackage
from setuptools import Command, setup
from setuptools.command.egg_info import egg_info
ROOT = Path(__file__).parent
sys.path.append(str(ROOT))
from generate_source import generate_source # noqa
def update_package_data(distribution) -> None:
"""Update package_data to catch changes during setup"""
distribution.data_files = get_data_files()
distribution.get_command_obj("build_py").finalize_options()
def rel(f: Path) -> str:
"""give the relative path of f with respect to ROOT"""
# make sure the relative links are ok even when build in the isolated directory
return str(f.relative_to(ROOT))
def js_prerelease(command: Command) -> None:
"""Decorator for building minified js/css prior to another command"""
class DecoratedCommand(command):
"""Decorated command to install jsdeps first."""
def run(self):
"""Run the command"""
NPMPackage(ROOT / "js" / "package.json").install()
generate_source.generate()
self.distribution.data_files = get_data_files()
command.run(self)
return DecoratedCommand
def get_data_files():
"""files that need to be installed in specific locations upon installation."""
nbext = [rel(f) for f in ROOT.glob("ipyvuetify/nbextension/*")]
package = [rel(f) for f in ROOT.glob("ipyvuetify/labextension/package.json")]
labext = [rel(f) for f in ROOT.glob("ipyvuetify/labextension/static/*")]
nbconfig = [rel(f) for f in ROOT.glob("jupyter-vuetify.json")]
return [
("share/jupyter/nbextensions/jupyter-vuetify", nbext),
("share/jupyter/labextensions/jupyter-vuetify", package),
("share/jupyter/labextensions/jupyter-vuetify/static", labext),
("etc/jupyter/nbconfig/notebook.d", nbconfig),
]
setup(cmdclass={"egg_info": js_prerelease(egg_info)})