-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
58 lines (43 loc) · 1.63 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 distutils
import logging
import os
import subprocess
import setuptools
def build_js():
subprocess.check_call(["yarn", "install"],
cwd=os.path.join(os.getcwd(), "frontend"))
subprocess.check_call(["yarn", "run", "build"],
cwd=os.path.join(os.getcwd(), "frontend"))
try:
from setuptools.command.build import build as _build
from setuptools.command.editable_wheel import \
editable_wheel as _editable_wheel
class build(_build):
def run(self) -> None:
self.announce("Building JS code", level=logging.INFO)
build_js()
super().run()
class editable_wheel(_editable_wheel):
def run(self) -> None:
self.announce("Building JS code", level=logging.INFO)
build_js()
super().run()
cmdclass = dict(build=build, editable_wheel=editable_wheel)
except ImportError:
# For older versions of setuptools (Python 3.6)
from setuptools.command.develop import develop as _develop
from setuptools.command.install import install as _install
# Build JS code when this package is installed in virtual env
# https://stackoverflow.com/a/36902139
class develop(_develop):
def run(self):
self.announce("Building JS code", level=distutils.log.INFO)
build_js()
super().run()
class install(_install):
def run(self):
self.announce("Building JS code", level=distutils.log.INFO)
build_js()
super().run()
cmdclass = dict(develop=develop, install=install)
setuptools.setup(cmdclass=cmdclass)