-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·135 lines (126 loc) · 4.41 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/python
##############################################################################
#
# Copyright (c) 2006-2015 Agendaless Consulting and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the BSD-like license at
# http://www.repoze.org/LICENSE.txt. A copy of the license should accompany
# this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL
# EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND
# FITNESS FOR A PARTICULAR PURPOSE
#
##############################################################################
import os
import sys
from setuptools import setup, find_packages
requires = [
"pyyaml",
"pytimeparse",
"docker-py",
]
tests_require = [
"coverage",
]
testing_extras = []
here = os.path.abspath(os.path.dirname(__file__))
README = ''
CHANGES = ''
try:
README = open(os.path.join(here, 'README.rst')).read()
except:
try :
for line_no, line in enumerate(open(os.path.join(here, 'README.md'))) :
if line_no==1 :
README = line.strip()
except :
pass
try:
CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
except:
pass
CLASSIFIERS = [
'Development Status :: 1 - Beta',
'Environment :: Console',
'Natural Language :: English',
'Operating System :: POSIX',
'License :: OSI Approved :: GNU General Public License (GPL)',
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
]
class ChangeDir(object) :
def __init__(self, wd) :
self.wd = wd
def __enter__(self):
self._pwd = os.getcwd()
if self.wd :
os.chdir(self.wd)
def __exit__(self, *args, **kwds) :
os.chdir(self._pwd)
def getDirtyState() :
import subprocess
p = subprocess.Popen(['git', 'status', '-s', '--untracked-files=no'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode != 0 :
raise RuntimeError('Failed to retrieve clean/dirty status, stdout:\n%s\nstderr:\n%s'%(stdout, stderr))
if stdout :
return "-dirty"
else :
return ""
def getVersion() :
with ChangeDir(os.path.dirname(__file__)) :
version = None
if os.path.exists('.git') :
import subprocess
p = subprocess.Popen(['git', 'describe'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode == 0 :
version = stdout.strip()
if version[0] == 'v' :
version = version[1:]
import re
match = re.match("([^-]*)(?:-([^-])-([^-]*)|)", version)
if match :
version, changes, commit = match.groups()
if changes :
version = "%s.dev%s"%(version, changes)
version += getDirtyState()
elif os.path.exists("PKG-INFO") :
import re
versionRe = re.compile("Version:[\s]*([^\s]*).*")
for line in file("PKG-INFO") :
match = versionRe.match(line)
if match :
version = match.group(1)
if not version :
version = "0.0.0"
return version
dist = setup(
name='caduc',
version=getVersion(),
license='GNU GPLv3',
url='https://github.com/tjamet/caduc',
description='caduc monitors docker events and schedules clean-up when resources are nor used any longer',
long_description=README + '\n\n' + CHANGES,
classifiers=CLASSIFIERS,
author="Thibault Jamet",
author_email=''.join([chr(i) for i in [116, 104, 105, 98, 97, 117, 108, 116, 46, 106, 97, 109, 101, 116, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109]]),
maintainer="Thibault Jamet",
maintainer_email=''.join([chr(i) for i in [116, 104, 105, 98, 97, 117, 108, 116, 46, 106, 97, 109, 101, 116, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109]]),
packages=find_packages(),
install_requires=requires,
extras_require={
'testing': testing_extras,
},
tests_require=tests_require,
include_package_data=True,
zip_safe=False,
entry_points={
'console_scripts': [
'caduc = caduc.cmd:main',
],
},
)