forked from faraplay/zundamahjong
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
46 lines (31 loc) · 1.06 KB
/
setup.py
File metadata and controls
46 lines (31 loc) · 1.06 KB
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
import os.path
import shutil
from setuptools import Command, setup
from setuptools.command.build import build
class build_client(Command):
def initialize_options(self) -> None:
self.client_dir = None
self.editable_mode = False
def finalize_options(self) -> None:
bdist_dir = self.get_finalized_command("bdist_wheel").bdist_dir
if bdist_dir:
self.client_dir = os.path.join(bdist_dir, "zundamahjong", "client")
def run(self) -> None:
"""Build the Zundamahjong static client files."""
if self.editable_mode:
return
if not os.path.isdir("client_build"):
os.chdir("client")
self.spawn(["npm", "install"])
self.spawn(["npm", "run", "build"])
os.chdir("..")
if self.client_dir:
shutil.copytree("client_build", self.client_dir)
class custom_build(build):
sub_commands = [("build_client", None)] + build.sub_commands
setup(
cmdclass={
"build_client": build_client,
"build": custom_build,
},
)