forked from mcahriman/Skype4Py
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
executable file
·152 lines (117 loc) · 4.83 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env python
"""
Skype4Py distutils script.
Copyright (c) 2007-2009, Arkadiusz Wahlig
All rights reserved.
Distributed under the BSD License, see the
accompanying LICENSE file for more information.
"""
import sys, os
from distutils.core import setup
from distutils.cmd import Command
from distutils.command.install_lib import install_lib as old_install_lib
# Change the current dir to where the setup.py is in case we're not there.
path = os.path.split(sys.argv[0])[0]
if path:
os.chdir(path)
# So that the Skype4Py library may know that the setup is running.
sys.skype4py_setup = True
# Import Skype4Py version from the distribution package.
from Skype4Py import __version__
class install_lib(old_install_lib):
"""Handles the 'install_lib' command.
This modified version of install_lib command installs only the necessary
platform modules from the Skype4Py.api subpackage.
"""
def install(self):
# The build is done here, now we have to adapt it to current platform
# before installing.
self.adapt_build_to_platform()
# Let the original method do the hard work of copying the files.
outfiles = old_install_lib.install(self)
# Also byte_compile for distribution usage.
if outfiles is not None:
self.byte_compile(outfiles)
return outfiles
def adapt_build_to_platform(self):
# We have to remove unneeded files from the build directory. First,
# decide what platform we're on; this code is similar to the one
# in Skype4Py/api/__init__.py which decides what submodule to
# import at runtime.
if sys.platform[:3] == 'win':
platform = 'windows'
elif sys.platform == 'darwin':
platform = 'darwin'
else:
platform = 'posix'
# Scan the <build_dir>/Skype4Py/api directory and remove all files
# which names do not start with either '__' (for __init__) or the
# detected platform.
path = os.path.join(self.build_dir, os.path.join('Skype4Py', 'api'))
for name in os.listdir(path):
if not (name.startswith('__') or name.startswith(platform)):
os.remove(os.path.join(path, name))
class build_doc(Command):
"""Handles the 'build_doc' command.
This command builds the documentation using epydoc. The documentation is then
zipped using zipfile standard module.
"""
description = 'build the documentation'
user_options = [('pdf', None, 'Builds a PDF documentation instead of a HTML one.')]
def initialize_options(self):
self.pdf = None
def finalize_options(self):
pass
def run(self):
try:
from epydoc import cli
epydoc_config = os.path.join('doc', 'epydoc.conf')
old_argv = sys.argv[1:]
try:
sys.argv[1:] = ['--config=%s' % epydoc_config]
if self.pdf:
sys.argv.append('--pdf')
sys.argv.append('--output=doc/pdf/')
else:
sys.argv.append('--html')
sys.argv.append('--output=doc/html/')
cli.cli()
finally:
sys.argv[1:] = old_argv
print 'zipping the documentation'
import zipfile
if self.pdf:
doctype = 'pdf'
else:
doctype = 'html'
name = 'Skype4Py-%s-%sdoc' % (__version__, doctype)
z = zipfile.ZipFile(os.path.join('doc', '%s.zip' % name),
'w', zipfile.ZIP_DEFLATED)
path = os.path.join('doc', doctype)
if self.pdf:
z.write(os.path.join(path, 'api.pdf'), '%s.pdf' % name)
else:
for f in os.listdir(path):
z.write(os.path.join(path, f), os.path.join(name, f))
z.close()
except ImportError:
print >>sys.stderr, 'epydoc not installed, skipping build_doc.'
commands = {'build_doc': build_doc,
'install_lib': install_lib}
# start the distutils setup
setup(name='Skype4Py',
version=__version__,
description='Skype API wrapper for Python.',
long_description='Skype4Py is a high-level, platform independent Skype API\n' \
'wrapper for Python with Skype4COM alike interface.',
author='Arkadiusz Wahlig',
author_email='[email protected]',
maintainer='Arkadiusz Wahlig',
url='https://developer.skype.com/wiki/Skype4Py',
download_url='http://downloads.sourceforge.net/skype4py/Skype4Py-%s.tar.gz' % __version__,
license='BSD License',
platforms=['Windows', 'Linux', 'MacOS X'],
packages=['Skype4Py', 'Skype4Py.api', 'Skype4Py.lang'],
package_data={'Skype4Py': ['LICENSE']},
provides=['Skype4Py'],
cmdclass=commands)