This repository has been archived by the owner on Jan 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
154 lines (132 loc) · 5.11 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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
"""
Setuptools and py2app/py2exe build script for transmart-arborist.
To install dependencies for your machine:
Usage:
python3 setup.py install
To build a packaged executable:
Usage (Mac OS X):
python3 setup.py py2app
Usage (Windows):
python3 setup.py py2exe
"""
import sys
import os
import glob
from setuptools import setup, find_packages
NAME = 'tranSMART Arborist'
VERSION = '1.2.4-1'
DIST_DIR = '{} v{}'.format(NAME, VERSION)
mainscript = 'runserver.py'
extra_options = {}
# Which directories to take all normal files from, these have to be specified explicitly.
patterns = [
'static/*',
'templates/*',
'static/img/*',
'static/img/message/*',
'static/img/tree/*',
'static/jstree/*',
'static/jstree/dist/*',
'static/jstree/dist/themes/*',
'static/jstree/dist/themes/default/*',
'static/jstree/dist/themes/default-dark/*',
]
def find_data_files(source, target, patterns):
"""Locates the specified data-files and returns the matches
in a data_files compatible format.
source is the root of the source data tree.
Use '' or '.' for current directory.
target is the root of the target data tree.
Use '' or '.' for the distribution directory.
patterns is a sequence of glob-patterns for the
files you want to copy.
"""
if glob.has_magic(source) or glob.has_magic(target):
raise ValueError("Magic not allowed in src, target")
ret = {}
for pattern in patterns:
pattern = os.path.join(source, pattern)
for filename in glob.glob(pattern):
if os.path.isfile(filename):
targetpath = os.path.join(target, os.path.relpath(filename, source))
path = os.path.dirname(targetpath)
ret.setdefault(path, []).append(filename)
return sorted(ret.items())
def osx_app_build_options():
"""
Collects additional requirements for building a MacOSX packaged executable. Only works on
OS X and must have py2app manually installed.
"""
data_files = find_data_files(source=os.getcwd() + '/arborist',
target='',
patterns=patterns)
py2app_options = {'argv_emulation': True,
'packages': ['jinja2',
'flask',
'email',
],
'includes': ['os',
'flask',
'sys',
],
'excludes': ['mime'],
'iconfile': 'resources/images/icons/boris.icns',
'dist_dir': DIST_DIR,
}
extra_options = dict(setup_requires=['py2app'],
app=[mainscript],
options={'py2app': py2app_options},
data_files=data_files,
)
return extra_options
def win32_exe_build_options():
"""
This collects additional requirements for building a Windows executable.
only works when running from Windows and having manually
installed the py2exe package.
"""
import py2exe
data_files = find_data_files(source=os.getcwd() + r'/arborist',
target='',
patterns=patterns)
py2exe_options = {'packages': ['werkzeug',
'email.mime',
'jinja2',
],
'includes': ['os',
'flask',
'sys',
'jinja2.ext',
],
'excludes': ['tkinter', 'sqlite3'],
'dist_dir': DIST_DIR,
'bundle_files': 1,
}
extra_options = dict(setup_requires=['py2exe'],
zipfile=None,
console=[{'script': mainscript,
'icon_resources': [(0, 'resources/images/icons/boris.ico')]
}],
options={'py2exe': py2exe_options},
data_files=data_files,
)
return extra_options
if sys.platform == 'darwin' and 'py2app' in sys.argv:
extra_options = osx_app_build_options()
elif sys.platform == 'win32' and 'py2exe' in sys.argv:
extra_options = win32_exe_build_options()
setup(
name=NAME,
version=VERSION,
description='Graphical tool to help you prepare your data for loading into the tranSMART data warehouse',
url='https://github.com/thehyve/transmart-arborist',
author='Ward Weistra and Jochem Bijlard',
author_email='[email protected]',
license='GNU General Public License V3',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=['Flask'],
scripts=[mainscript],
**extra_options
)