forked from szaghi/FoBiS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
65 lines (54 loc) · 2.22 KB
/
build.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
#!/usr/bin/env python
"""Build script for FoBiS.py"""
import os
from pybuilder.core import init, task, use_plugin
from shutil import copyfile
import subprocess
import re
name = "FoBiS"
use_plugin('python.core')
use_plugin('python.coverage')
use_plugin('python.flake8')
# use_plugin('python.frosted')
use_plugin('python.install_dependencies')
use_plugin('python.pylint')
# use_plugin('python.unittest')
__source__ = open('src/main/python/fobis/FoBiSConfig.py').read()
__version__ = re.search(r'^__version__\s*=\s*"(.*)"', __source__, re.M).group(1)
try:
__branch__ = subprocess.check_output(['git', 'symbolic-ref', '--quiet', '--short', 'HEAD'])
# __branch__ = str(subprocess.check_output(['git', 'symbolic-ref', '--quiet', '--short', 'HEAD'])).strip('\n')
except subprocess.CalledProcessError as e:
__branch__ = 'unknown'
__branch__ = __branch__.decode('utf-8')
__branch__ = re.sub(r'feature/', '', __branch__)
__branch__ = re.sub(r'hotfix/', '', __branch__)
__branch__ = re.sub(r'\n', '', __branch__)
__branch__ = re.sub(r'/', '-', __branch__)
@init
def initialize(project):
"""Initiale the building class."""
project.version = __version__
project.build_depends_on('coverage')
project.build_depends_on('flake8')
project.build_depends_on('frosted')
project.build_depends_on('pylint')
# project.set_property("teamcity_output", True)
project.set_property('flake8_max_line_length', 500)
project.set_property('verbose', True)
project.set_property('coverage_break_build', False)
project.set_property('coverage_threshold_warn', 90)
project.set_property('dir_target', 'release')
project.set_property('dir_dist', 'release/' + project.name + '-' + __branch__)
project.set_property('dir_reports', 'release/reports-' + project.name + '-' + __branch__)
project.default_task = ['analyze', 'publish', 'copy_resources']
return
@task
def copy_resources(project):
"""Copy non source resource files."""
copyfile('MANIFEST.in', 'release/' + project.name + '-' + __branch__ + '/MANIFEST.in')
copyfile('src/main/scripts/setup.py', 'release/' + project.name + '-' + __branch__ + '/setup.py')
for mdf in os.listdir('.'):
if mdf.endswith('.md'):
copyfile(mdf, 'release/' + project.name + '-' + __branch__ + '/' + mdf)
return