-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·54 lines (42 loc) · 1.6 KB
/
setup.py
File metadata and controls
executable file
·54 lines (42 loc) · 1.6 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
#!/usr/bin/env python
#
# Copyright (c) 2016 Stefan Seefeld
# All rights reserved.
#
# This file is part of Faber. It is made available under the
# Boost Software License, Version 1.0.
# (Consult LICENSE or http://www.boost.org/LICENSE_1_0.txt)
from setuptools import setup
from setuptools.command.build import build
from subprocess import check_output
import re
import os
def get_version_from_git():
try:
out = check_output('git describe --tags --long --match release/*'.split()).decode().strip()
match = re.match(r'release/'
r'(?P<version>[a-zA-Z0-9.]+)'
r'(?:-(?P<post>\d+)-g(?P<hash>[0-9a-f]{7,}))$',
out)
version, post, hash = match.groups()
return version if post == '0' else '{0}.post{1}+{2}'.format(version, post, hash)
except Exception:
raise ValueError('unable to extract version from git tag')
data = [('share/doc/faber', ('LICENSE', 'README.md'))]
class build_doc(build):
description = "build documentation"
def run(self):
self.announce('building documentation')
orig = sys.argv
sys.argv = ['faber', '--srcdir=doc', '--builddir=doc']
try: cli.main()
finally: sys.argv = orig
docs = []
if os.path.exists('doc/html'):
for root, dirs, files in os.walk('doc/html'):
dest = root.replace('doc/html', 'share/doc/faber')
docs.append((dest,
[os.path.join(root, file) for file in files
if os.path.isfile(os.path.join(root, file))]))
if __name__ == '__main__':
setup(data_files=data + docs)