|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
|
|
3
|
|
|
import imp |
|
4
|
|
|
import os |
|
5
|
|
|
import uuid |
|
6
|
|
|
import sys |
|
7
|
|
|
import urllib2 |
|
8
|
|
|
|
|
9
|
|
|
# Check for pip, setuptools and wheel |
|
10
|
|
|
try: |
|
11
|
|
|
import pip |
|
12
|
|
|
import setuptools |
|
13
|
|
|
import wheel |
|
14
|
|
|
except ImportError as exp: |
|
15
|
|
|
print("install missing pip now (%s)" % exp) |
|
16
|
|
|
from get_pip import main as check_for_pip |
|
17
|
|
|
old_args = sys.argv |
|
18
|
|
|
sys.argv = [sys.argv[0]] |
|
19
|
|
|
try: |
|
20
|
|
|
check_for_pip() |
|
21
|
|
|
except SystemExit as e: |
|
22
|
|
|
if e.code == 0: |
|
23
|
|
|
os.execv(sys.executable, [sys.executable] + old_args) |
|
24
|
|
|
else: |
|
25
|
|
|
print("install pip failed with error code %s" % e.code) |
|
26
|
|
|
sys.exit(e.code) |
|
27
|
|
|
|
|
28
|
|
|
base_path = os.path.dirname(os.path.abspath(__file__)) |
|
29
|
|
|
metadata = imp.load_source('metadata', os.path.join(base_path, 'doorpi', 'metadata.py')) |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
def parse_string(raw_string): |
|
33
|
|
|
for meta_key in dir(metadata): |
|
34
|
|
|
if not meta_key.startswith('__'): |
|
35
|
|
|
raw_string = raw_string.replace('!!%s!!' % meta_key, str(getattr(metadata, meta_key))) |
|
36
|
|
|
return raw_string |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
def read(filename, parse_file_content=False, new_filename=None): |
|
40
|
|
|
with open(os.path.join(base_path, filename)) as f: |
|
41
|
|
|
file_content = f.read() |
|
42
|
|
|
if parse_file_content: |
|
43
|
|
|
file_content = parse_string(file_content) |
|
44
|
|
|
if new_filename: |
|
45
|
|
|
with open(os.path.join(base_path, new_filename), 'w') as f: |
|
46
|
|
|
f.write(file_content) |
|
47
|
|
|
return new_filename |
|
48
|
|
|
return file_content |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
from setuptools import setup, find_packages |
|
52
|
|
|
from pip.req import parse_requirements |
|
53
|
|
|
install_reqs = parse_requirements(os.path.join(base_path, 'requirements.txt'), session=uuid.uuid1()) |
|
54
|
|
|
reqs = [str(req.req) for req in install_reqs] |
|
55
|
|
|
|
|
56
|
|
|
setup_dict = dict( |
|
57
|
|
|
# <http://pythonhosted.org/setuptools/setuptools.html> |
|
58
|
|
|
license=metadata.license, |
|
59
|
|
|
name=metadata.package, |
|
60
|
|
|
version=metadata.version, |
|
61
|
|
|
author=metadata.authors[0], |
|
62
|
|
|
author_email=metadata.emails[0], |
|
63
|
|
|
maintainer=metadata.authors[0], |
|
64
|
|
|
maintainer_email=metadata.emails[0], |
|
65
|
|
|
url=metadata.url, |
|
66
|
|
|
keywords=metadata.keywords, |
|
67
|
|
|
description=metadata.description, |
|
68
|
|
|
long_description=read('README.rst'), |
|
69
|
|
|
# Find a list of classifiers here: |
|
70
|
|
|
# <http://pypi.python.org/pypi?%3Aaction=list_classifiers> |
|
71
|
|
|
classifiers=[ |
|
72
|
|
|
'Development Status :: 5 - Production/Stable', |
|
73
|
|
|
'Environment :: Console', |
|
74
|
|
|
'Intended Audience :: Developers', |
|
75
|
|
|
'Intended Audience :: End Users/Desktop', |
|
76
|
|
|
'Intended Audience :: Information Technology', |
|
77
|
|
|
'Intended Audience :: System Administrators', |
|
78
|
|
|
'License :: Free for non-commercial use', |
|
79
|
|
|
'Natural Language :: German', |
|
80
|
|
|
'Natural Language :: English', |
|
81
|
|
|
'Operating System :: OS Independent', |
|
82
|
|
|
'Programming Language :: Python :: 2.7', |
|
83
|
|
|
# 'Programming Language :: Python :: 3.3', |
|
84
|
|
|
# 'Programming Language :: Python :: Implementation :: PyPy', |
|
85
|
|
|
'Topic :: Documentation', |
|
86
|
|
|
'Topic :: Software Development :: Libraries :: Python Modules', |
|
87
|
|
|
'Topic :: System :: Installation/Setup', |
|
88
|
|
|
'Topic :: System :: Software Distribution', |
|
89
|
|
|
'Topic :: Communications :: Internet Phone', |
|
90
|
|
|
'Topic :: Communications :: Telephony', |
|
91
|
|
|
'Topic :: Multimedia :: Sound/Audio :: Capture/Recording', |
|
92
|
|
|
'Topic :: Multimedia :: Video :: Capture', |
|
93
|
|
|
'Topic :: Multimedia :: Video :: Conversion', |
|
94
|
|
|
'Topic :: Security', |
|
95
|
|
|
'Topic :: System :: Emulators', |
|
96
|
|
|
'Topic :: System :: Filesystems', |
|
97
|
|
|
'Topic :: System :: Hardware', |
|
98
|
|
|
'Topic :: Utilities' |
|
99
|
|
|
], |
|
100
|
|
|
packages=find_packages(exclude=['contrib', 'docs', 'tests*']), |
|
101
|
|
|
install_requires=reqs, |
|
102
|
|
|
platforms=["any"], |
|
103
|
|
|
use_2to3=False, |
|
104
|
|
|
zip_safe=False, # don't use eggs |
|
105
|
|
|
entry_points={ |
|
106
|
|
|
'console_scripts': [ |
|
107
|
|
|
'doorpi_cli = doorpi.main:entry_point' |
|
108
|
|
|
] |
|
109
|
|
|
} |
|
110
|
|
|
) |
|
111
|
|
|
|
|
112
|
|
|
|
|
113
|
|
|
def main(): |
|
114
|
|
|
try: |
|
115
|
|
|
if os.name == 'posix' and os.geteuid() == 0 and \ |
|
116
|
|
|
not os.path.isfile(metadata.daemon_file) and not os.path.exists(metadata.daemon_file): |
|
117
|
|
|
with open(metadata.daemon_file, "w") as daemon_file: |
|
118
|
|
|
for line in urllib2.urlopen(metadata.daemon_online_template): |
|
119
|
|
|
daemon_file.write(parse_string(line)) |
|
120
|
|
|
os.chmod(metadata.daemon_file, 0755) |
|
121
|
|
|
except: pass |
|
122
|
|
|
|
|
123
|
|
|
setup(**setup_dict) |
|
124
|
|
|
|
|
125
|
|
|
if __name__ == '__main__': |
|
126
|
|
|
main() |
|
127
|
|
|
|