forked from mailpile/Mailpile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·84 lines (67 loc) · 2.5 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
#!/usr/bin/env python2.7
from datetime import date
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
import datetime
import os
import re
import subprocess
from glob import glob
from scripts.version import APPVER
here = os.path.abspath(os.path.dirname(__file__))
########################################################
##################### PBR Fix ##########################
## Issue: https://bugs.launchpad.net/pbr/+bug/1530867 ##
## PR: https://review.openstack.org/#/c/263297/ ########
########################################################
import pbr.git
def _get_submodules(git_dir):
submodules = pbr.git._run_git_command(['submodule', 'status'], git_dir)
submodules = [s.strip().split(' ')[1]
for s in submodules.split('\n')
if s != '']
return submodules
def _find_git_files(dirname='', git_dir=None):
"""Behave like a file finder entrypoint plugin.
We don't actually use the entrypoints system for this because it runs
at absurd times. We only want to do this when we are building an sdist.
"""
file_list = []
if git_dir is None:
git_dir = pbr.git._run_git_functions()
if git_dir:
file_list = pbr.git._run_git_command(['ls-files', '-z'], git_dir)
file_list += pbr.git._run_git_command(
['submodule', 'foreach', '--quiet', 'ls-files', '-z'],
git_dir
)
# Users can fix utf8 issues locally with a single commit, so we are
# strict here.
file_list = file_list.split(b'\x00'.decode('utf-8'))
submodules = _get_submodules(git_dir)
return [f for f in file_list if f and f not in submodules]
pbr.git._find_git_files = _find_git_files
########## end of pbr fix ######
## Cleanup ###################################################################
try:
assert(0 == subprocess.call(['make', 'clean'], cwd=here))
except:
print "Faild to run 'make clean'. Bailing out."
exit(1)
## Install ###################################################################
class Builder(build_py):
def run(self):
try:
assert(0 == subprocess.call(['make', 'bdist-prep'], cwd=here))
except:
print "Error building package. Try running 'make'."
exit(1)
else:
build_py.run(self)
## "Main" ####################################################################
setup(
setup_requires=['pbr'],
version=APPVER,
pbr=True,
cmdclass={'build_py': Builder},
)