-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
84 lines (62 loc) · 1.84 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
# vim: tabstop=4 expandtab autoindent shiftwidth=4 fileencoding=utf-8
from setuptools import setup
import os
import sys
NAME = 'bombcdn_client'
AUTHOR = 'BombCDN'
AUTHOR_EMAIL = 'bombcdn@bombcdn.com'
URL = 'http://bombcdn.com/'
def get_egg_version():
dirname = os.path.dirname(__file__)
dir = os.path.split(dirname)[1]
egg_dir = '%s.egg-info' % dir
egg_path = os.path.join(dirname, egg_dir)
pkg_info = os.path.join(egg_path, 'PKG-INFO')
with open(pkg_info, 'r') as pkg_info_f:
for line in pkg_info_f.readlines():
split_line = line.split(': ')
if split_line[0] == 'Version':
return split_line[1].strip()
raise ValueError('No version found')
def get_version():
stdin_f, stdout_f, stderr_f = os.popen3('git ls-remote .')
stderr = stderr_f.read()
if stderr:
print stderr
try:
return get_egg_version()
except Exception, e:
print e
sys.exit(1)
stdout = stdout_f.readlines()
head = None
tag = None
for line in stdout:
hash, name = line.split()
if name == 'HEAD':
head = hash
if head and hash == head and 'tag' in name:
tag = name.rsplit('/', 1)[-1]
tag = '.'.join(tag.split('.')[:-1])
if tag is None:
print 'tag not found'
sys.exit(1)
return tag
packages = []
def get_packages(arg, dir, fnames):
global packages
if '__init__.py' in fnames:
packages.append(dir.replace('/', '.'))
os.path.walk(NAME, get_packages, None)
setup(
name = NAME,
version = get_version(),
author = AUTHOR,
author_email = AUTHOR_EMAIL,
url = URL,
packages = packages,
# package_data = package_data, # MANIFEST.in where available
include_package_data = True,
long_description = '%s.' % NAME,
)
# EOF