forked from LINBIT/linstor-api-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·97 lines (81 loc) · 3.03 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
#!/usr/bin/env python2
"""
linstor - management of distributed DRBD9 resources
Copyright (C) 2013 - 2018 LINBIT HA-Solutions GmbH
Author: Robert Altnoeder, Philipp Reisner
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import sys
import re
from setuptools import setup, Command
def get_version():
"""
Function to parse the version string from the linstor/__init__.py.
This was done to not rely on a working build, e.g. sometimes files were
not yet generated and this made problems with importing.
:return: semantic version string
:rtype: str
"""
with open('linstor/__init__.py') as linstor_init:
for line in linstor_init:
if line.startswith('VERSION'):
m = re.search(r'"(.*)"', line)
if m:
return m.group(1)
else:
raise RuntimeError("Unable to parse version: " + line)
raise RuntimeError("Unable to find version string.")
# used to overwrite version tag by internal build tools
# keep it, even if you don't understand it.
def get_setup_version():
return get_version()
class CheckUpToDate(Command):
description = "Check if version strings are up to date"
user_options = []
def initialize_options(self):
self.cwd = None
def finalize_options(self):
self.cwd = os.getcwd()
def run(self):
version = get_version()
try:
with open("debian/changelog") as f:
firstline = f.readline()
if version not in firstline:
# returning false is not promoted
sys.exit(1)
except IOError:
# probably a release tarball without the debian directory but with Makefile
return True
setup(
name="python-linstor",
version=get_version(),
description="Linstor python api",
long_description="Python linstor api interface",
url='https://www.linbit.com',
author="Robert Altnoeder <[email protected]>, Roland Kammerer <[email protected]>" +
", Rene Peinthor <[email protected]>",
author_email="[email protected]",
maintainer="LINBIT HA-Solutions GmbH",
maintainer_email="[email protected]",
license="GPLv3",
# install_requires=[],
packages=[
'linstor'
],
# package_data={},
cmdclass={
"versionup2date": CheckUpToDate
},
test_suite="tests"
)