-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
executable file
·91 lines (75 loc) · 3.26 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
#!/usr/bin/env python
#
# Copyright 2015 British Broadcasting Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from setuptools import setup
import os
import sys
import re
def find_packages(path, base="" ):
""" Find all packages in path """
packages = {}
if "__init__.py" in os.listdir(path):
packages[base] = path
for item in os.listdir(path):
itempath = os.path.join(path,item)
if os.path.isdir(itempath):
newbase = "%s.%s" % (base, item)
packages.update(find_packages(itempath, newbase))
return packages
packages = find_packages("dvbcss","dvbcss")
package_names = packages.keys()
otherArgs = {}
# if registering or uploading to PyPI: convert markdown readme to ReStructuredText
# using pandoc
lcase_args = [arg.lower() for arg in sys.argv]
if "register" in lcase_args or "upload" in lcase_args:
retval = os.system("pandoc --from=markdown --to=rst --output=tmp.README.rst README.md")
if retval==0:
otherArgs["long_description"] = open("tmp.README.rst").read()
else:
raise RuntimeError("Unable to convert documentation from Markdown to ReStructuredText. Is 'pandoc' command line tool installed?")
try:
VERSION, _ = re.match("^([.0-9a-zA-Z]+)-(.+)$", open("VERSION").read().replace("\n","").replace("\r","")).groups()
setup(
name = "pydvbcss",
version = VERSION,
author = "Matt Hammond (British Broadcasting Corporation)",
author_email = "matt.hammond@bbc.co.uk",
description = ("pydvbcss is a library implementing DVB \"CSS\" protocols for Companion Screen Synchronisation."),
license = "Apache 2.0",
keywords = "dvb companion synchronisation synchronization second-screen protocol",
url = "http://github.com/BBC/pydvbcss",
packages = package_names,
package_dir = packages,
install_requires = filter(len, [req.strip() for req in open("requirements.txt","r").read().splitlines()]),
test_suite = "test.test_all.testSuite",
classifiers=[
"Intended Audience :: Developers",
"Intended Audience :: Telecommunications Industry",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 2.7",
"Topic :: Internet",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Networking :: Time Synchronization",
],
**otherArgs
)
finally:
if "long_description" in otherArgs:
os.remove("tmp.README.rst")