-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·65 lines (55 loc) · 1.82 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·65 lines (55 loc) · 1.82 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
#!/usr/bin/env python
from setuptools import setup
from re import match
import os
import subprocess
def get_git_version():
'''get a pypi compatible version from git.
verifies the tag is pypi compatible
returns None if the tag is not pypi compatible
converts post tag revisions into 'dev<increment>'
'''
regex = '(\d(\.\d+)+((a|b|rc)\d+)?)((-([1-9]\d*)-g[0-9a-f]+)?(-dirty)?)?'
try:
version_git = subprocess.check_output(['git', 'describe', '--dirty'])
except:
return None
m = match(regex, version_git)
if not m:
return None
version_pypi = m.group(1)
if m.group(5):
post_increment = 0
try:
post_increment = int(m.group(7))
except:
pass
version_pypi += '.dev{}'.format(post_increment)
return version_pypi
def load_version():
from buildbot_webhook_gogs.version import __version__
return __version__
def save_version(version):
version_msg = '''# Do not edit this file, pipeline versioning is governed by git tags
__version__ = '{}'
'''
version_py = os.path.join(os.path.dirname(__file__), 'buildbot_webhook_gogs', 'version.py')
with open(version_py, 'w') as fh:
fh.write(version_msg.format(version))
def cache_git_version():
version = get_git_version()
if version:
save_version(version)
else:
version = load_version()
return version
setup(name='buildbot-webhook-gogs',
version=cache_git_version(),
description='Gogs web hook support for buildbot 9.9 and above',
author='Joshua A Clayton',
author_email='stillcompiling@gmail.com',
url='https://github.com/d4ddi0/buildbot-webhook-gogs',
license='GPLv2',
packages=['buildbot_webhook_gogs',],
entry_points={'buildbot.webhooks': 'gogs = buildbot_webhook_gogs:gogs'}
)