-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
86 lines (69 loc) · 2 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
from setuptools import setup, find_packages
from setuptools.command.develop import develop
from setuptools.command.install import install
def requirements():
with open('requirements.txt') as f:
return f.read().split('\n')
def version():
with open('metacatalog/__version__.py') as f:
c = f.read()
d = dict()
exec(c, d, d)
return d['__version__']
def readme():
with open('README.md') as f:
return f.read()
def migrate_database():
"""
This can fail if the install command is run for the fist time.
In these cases, a database migration is not necessary, as the
latest Models will be installed anyway.
"""
try:
from metacatalog import api
from metacatalog.db import migration
except ModuleNotFoundError:
# this happens on first startup as the dependencies are
# not yet installed. Can be ignored.
pass
try:
session = api.connect_database()
migration.upgrade(session)
except:
print()
pass
class PostDevelopCommand(develop):
def run(self):
# create config and migrate the database
migrate_database()
# default develop
develop.run(self)
class PostInstallCommand(install):
def run(self):
# create config and migrate the database
migrate_database()
# default install
install.run(self)
setup(
name="metacatalog",
author="Mirko Mälicke",
author_email="mirko.maelicke@kit.edu",
license="GPL v3",
install_requires=requirements(),
version=version(),
description="Metadata model management module.",
long_description=readme(),
long_description_content_type="text/markdown",
packages=find_packages(),
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand
},
entry_points={
'console_scripts': [
'metacatalog = metacatalog.command_line:main'
]
},
include_package_data=True,
zip_safe=False
)