-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
135 lines (103 loc) · 3.8 KB
/
setup.py
File metadata and controls
135 lines (103 loc) · 3.8 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import distutils.log
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py as _build_py
from setuptools.command.install import install as _install
import os
import subprocess
with open("version.txt") as f:
PACKAGE_NAME, VERSION, COMPATIBLE_VERSION = \
(x.strip() for x in f.read().strip().split())
with open('travelsBackend/requirements.txt') as f:
INSTALL_REQUIRES = [
x.strip('\n')
for x in f.readlines()
if x and x[0] != '#'
]
SHORT_DESCRIPTION = "Travel Expenses"
PACKAGES_ROOT = 'travelsBackend'
PACKAGES = find_packages(PACKAGES_ROOT)
# Package meta
CLASSIFIERS = [
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
]
EXTRAS_REQUIRES = {
}
TESTS_REQUIRES = [
]
def get_all_data_files(dest_path, source_path):
dest_path = dest_path.strip('/')
source_path = source_path.strip('/')
source_len = len(source_path)
return [
(
os.path.join(dest_path, path[source_len:].strip('/')),
[os.path.join(path, f) for f in files],
)
for path, _, files in os.walk(source_path)
]
UI_DATA_FILES = get_all_data_files('lib/travel/www/ui', 'travelsFront/dist')
TRAVEL_TEMPLATE_FILES = get_all_data_files('lib/travel/resources/templates',
'travelsBackend/texpenses/templates')
TRAVEL_VISUALIZATIONS_FILES = get_all_data_files('lib/travel/visualizations', 'travelsBackend/visualizations')
class BuildUiCommand(_build_py):
""" Extend build_py to build Travel UI. """
description = 'build Travel UI'
user_options = _build_py.user_options + [
('no-ui', None, 'skip Travel UI build'),
]
boolean_options = _build_py.boolean_options + ['no-ui']
def initialize_options(self):
""" Set default values for options. """
_build_py.initialize_options(self)
self.no_ui = None
def run(self):
if not self.no_ui:
command = ['./build_ui.sh', 'production']
self.announce('building ui: %s' % ' '.join(command),
level=distutils.log.INFO)
subprocess.call(command, cwd='./travelsFront/')
_build_py.run(self)
class InstallCommand(_install):
""" Extend install command with --no-build-ui option. """
user_options = _install.user_options + [
('no-build-ui', None, 'skip Travel UI build'),
]
boolean_options = _install.boolean_options + ['no-build-ui']
def initialize_options(self):
""" Set default values for options. """
_install.initialize_options(self)
self.no_build_ui = None
def run(self):
if self.no_build_ui or self.compile == 0:
self.reinitialize_command('build_py', no_ui=True)
_install.run(self)
setup(
name=PACKAGE_NAME,
version=VERSION,
description=SHORT_DESCRIPTION,
classifiers=CLASSIFIERS,
packages=PACKAGES,
package_dir={'': PACKAGES_ROOT},
data_files=[
('lib/travel/resources',
[
'resources/common.json',
'resources/unaccent_greek.rules',
'travelsBackend/texpenses/data/countries-full.csv',
'travelsBackend/texpenses/data/countriesTZ.csv',
'travelsBackend/texpenses/data/ListEfories.csv',
'travelsBackend/texpenses/fixtures/data.json',
]),
('lib/travel/scripts', ['scripts/travel_init.sh']),
] + UI_DATA_FILES + TRAVEL_TEMPLATE_FILES + TRAVEL_VISUALIZATIONS_FILES,
zip_safe=False,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRES,
tests_require=TESTS_REQUIRES,
entry_points={
'console_scripts': [
'travel = texpenses.management:main',
],
},
cmdclass={'install': InstallCommand, 'build_py': BuildUiCommand},
)