forked from gavinbeatty/mkvtomp4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
102 lines (90 loc) · 2.9 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
import sys
import os
import subprocess as sp
from distutils.core import setup, Command
from simplemkv.tomp4 import __doc__
try:
from simplemkv.version import __version__
except ImportError:
__version__ = 'unknown'
# A list of classifiers can be found here:
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = """\
Natural Language :: English
Development Status :: 4 - Beta
Environment :: Console
Topic :: Multimedia
Topic :: Multimedia :: Sound/Audio :: Conversion
Topic :: Multimedia :: Video :: Conversion
Intended Audience :: End Users/Desktop
License :: OSI Approved :: MIT License
Programming Language :: Python
Operating System :: OS Independent
"""
def write_version(v):
f = open('simplemkv/version.py', 'w')
try:
f.write('__version__ = %s\n' % repr(v))
finally:
f.close()
def git_version():
cmd = ['git', 'describe', '--abbrev=4']
try:
proc = sp.Popen(cmd, stdout=sp.PIPE)
stdout = proc.communicate()[0].rstrip('\n')
except OSError:
sys.stderr.write('git not found: leaving __version__ alone\n')
return __version__
if proc.returncode != 0:
sys.stderr.write('git describe failed: leaving __version__ alone\n')
return __version__
ver = stdout.lstrip('mkvtomp4-v')
write_version(ver)
try:
proc = sp.Popen(['git', 'update-index', '-q', '--refresh'])
proc.communicate()
except OSError:
return ver
if proc.returncode != 0:
return ver
try:
proc = sp.Popen(['git', 'diff-index', '--name-only', 'HEAD', '--'], stdout=sp.PIPE)
stdout = proc.communicate()[0]
except OSError:
sys.stderr.write('git diff-index failed\n')
if stdout.strip('\n'):
ver = ver + '-dirty'
write_version(ver)
return ver
if sys.version_info < (2, 3):
_setup = setup
def setup(**kwargs):
if kwargs.has_key("classifiers"):
del kwargs["classifiers"]
_setup(**kwargs)
doclines_ = __doc__.split("\n")
codeopts = {
'name': 'mkvtomp4',
'description': doclines_[0],
'long_description': "\n".join(doclines_[2:]),
'author': 'Gavin Beatty',
'author_email': '[email protected]',
'maintainer': 'Gavin Beatty',
'maintainer_email': '[email protected]',
'license': 'http://opensource.org/licenses/MIT',
'platforms': ["any"],
'classifiers': filter(None, classifiers.split("\n")),
'url': 'https://github.com/gavinbeatty/mkvtomp4/',
'version': __version__,
'scripts': ['mkvtomp4.py'],
'py_modules': ['simplemkv.version', 'simplemkv.info', 'simplemkv.tomp4'],
}
fullopts = codeopts.copy()
fullopts['data_files'] = [
('share/doc/mkvtomp4', ['README.mkd', 'LICENSE', 'doc/mkvtomp4.txt']),
('share/man/man1', ['doc/mkvtomp4.1', 'doc/mkvtomp4.1.html']),
]
if __name__ == '__main__':
__version__ = git_version()
fullopts['version'] = __version__
setup(**fullopts)