-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
97 lines (85 loc) · 2.64 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import os
import subprocess
import sys
from distutils.command.install import install
from setuptools import setup, find_packages, Command
MODULE = "tank"
_ROOT = os.path.abspath(os.path.dirname(__file__))
class NpmCommand(Command):
"""A custom command to run Pylint on all Python source files."""
description = 'run npm install & build'
user_options = [
# The format is (long option, short option, description).
('webapp_path=', "wp=", 'path to webapp'),
]
def initialize_options(self):
"""Set default values for options."""
# Each user option must be listed here with their default value.
self.webapp_path = "tank/data/web"
def finalize_options(self):
"""Post-process options."""
if self.webapp_path:
print(os.getcwd())
assert os.path.exists(self.webapp_path), (
f"webapp path '{self.webapp_path}' does not exist.")
def run(self):
"""Run command."""
if not self.webapp_path:
print("No webapp path specified. Aborting...")
sys.exit(1)
wd = os.getcwd()
os.chdir(self.webapp_path)
npm_install = ['npm', 'install']
npm_build = ['npm', 'run', 'build']
self.announce(str(npm_install))
subprocess.check_call(npm_install)
self.announce(str(npm_build))
subprocess.check_call(npm_build)
os.chdir(wd)
class InstallWrapper(install):
def run(self):
# fist run npm install and build to build our webapp
self.run_command("build-client")
# now run install :)
install.run(self)
setup(
name=f'{MODULE}',
author="Christoph Spörk",
author_email="[email protected]",
platforms="any",
version='1.1.2',
packages=find_packages(
include=[f'{MODULE}', f'{MODULE}.*']
),
package_data={"tank": [
"data/web/dist/assets/*",
"data/web/dist/index.html",
"data/tank.service",
"data/tank.conf",
]},
include_package_data=True,
cmdclass={
'install': InstallWrapper,
'build-client': NpmCommand
},
install_requires=[
'APScheduler==3.7.0',
'bidict==0.21.2',
'click==8.0.1',
'Flask==2.0.1',
'Flask-APScheduler==1.12.2',
'Flask-Cors==3.0.10',
'Flask-SocketIO==5.1.1',
'itsdangerous==2.0.1',
'Jinja2==3.0.1',
'MarkupSafe==2.0.1',
'python-dateutil==2.8.2',
'python-engineio==4.2.1',
'python-socketio==5.4.0',
'pytz==2021.1',
'pyzmq==22.2.1',
'six==1.16.0',
'tzlocal==2.1',
'Werkzeug==2.0.1'
]
)