forked from iiasa/ixmp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
94 lines (79 loc) · 2.23 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
#!/usr/bin/env python
from __future__ import print_function
import os
import shutil
import sys
import glob
from setuptools import setup, Command, find_packages
from setuptools.command.install import install
INFO = {
'version': '0.1.0',
}
paths = """
import os
fullpath = lambda *x: os.path.abspath(os.path.join(*x))
ROOT_DIR = fullpath(r'{here}')
TEST_DIR = fullpath(r'{here}', 'tests')
CONFIG_DIR = fullpath(r'{here}', 'config')
""".format(here=os.path.dirname(os.path.realpath(__file__)))
class Cmd(install):
"""Custom clean command to tidy up the project root."""
def initialize_options(self):
install.initialize_options(self)
def finalize_options(self):
install.finalize_options(self)
def run(self):
install.run(self)
dirs = [
'ixmp.egg-info',
'build',
]
for d in dirs:
print('removing {}'.format(d))
shutil.rmtree(d)
def main():
packages = [
'ixmp',
]
pack_dir = {
'ixmp': 'ixmp',
}
entry_points = {
'console_scripts': [
'import-timeseries=ixmp.cli:import_timeseries',
],
}
cmdclass = {
'install': Cmd,
}
lib_files = [x.split('ixmp/')[-1] for x in glob.glob('ixmp/lib/*')]
db_files = [x.split('ixmp/')[-1]
for x in glob.glob('ixmp/db/migration/*/*')]
pack_data = {
'ixmp': [
'ixmp.jar',
] + lib_files + db_files,
}
setup_kwargs = {
"name": "ixmp",
"version": INFO['version'],
"description": 'ix modeling platform',
"author": 'Daniel Huppmann, Matthew Gidden, Volker Krey, '
'Oliver Fricko, Peter Kolp',
"author_email": '[email protected]',
"url": 'http://github.com/iiasa/message_ix',
"packages": packages,
"package_dir": pack_dir,
"package_data": pack_data,
"entry_points": entry_points,
"cmdclass": cmdclass,
}
print('Writing default_paths.py')
pth = os.path.join('ixmp', 'default_paths.py')
with open(pth, 'w') as f:
f.write(paths)
rtn = setup(**setup_kwargs)
print('Removing default_paths.py')
os.remove(pth)
if __name__ == "__main__":
main()