14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
# In addition, as a special exception, the copyright holders give
19
# permission to link the code of portions of this program with the OpenSSL
22
# You must obey the GNU General Public License in all respects for all of
23
# the code used other than OpenSSL. If you modify file(s) with this
24
# exception, you may extend this exception to your version of the file(s),
25
# but you are not obligated to do so. If you do not wish to do so, delete
26
# this exception statement from your version. If you delete this exception
27
# statement from all source files in the program, then also delete it here.
46
57
defaultBinaryKitRoot = os.path.join(os.path.dirname(sys.argv[0]), \
47
58
'..', '..', '..', 'dtv-binary-kit')
48
BINARY_KIT_ROOT = defaultBinaryKitRoot
59
BINARY_KIT_ROOT = os.path.abspath(defaultBinaryKitRoot)
50
# Set BOOST_LIB, BOOST_INCLUDE_PATH, and BOOST_RUNTIMES as appropriate
51
# for the location of Boost, the version you built, and the compiler
52
# you used. If you are unsure, search your hard drive for a file named
53
# "boost_python*". If there is more than one, you probably already
54
# know what you're doing.
55
# NEEDS: better accomodate non-vc71 compilers in binary kit?
56
61
BOOST_ROOT = os.path.join(BINARY_KIT_ROOT, 'boost', 'win32')
57
62
BOOST_LIB_PATH = os.path.join(BOOST_ROOT, 'lib')
59
# Hack so we don't break things for people who haven't updated their binary kit
60
if os.path.exists(os.path.join(BOOST_ROOT, 'include', 'boost-1_33_1')):
61
BOOST_LIB = os.path.join(BOOST_LIB_PATH, 'boost_python-vc71-mt-1_33_1.lib')
62
BOOST_INCLUDE_PATH = os.path.join(BOOST_ROOT, 'include', 'boost-1_33_1')
64
os.path.join(BOOST_LIB_PATH, 'boost_python-vc71-mt-1_33_1.dll'),
67
BOOST_LIB = os.path.join(BOOST_LIB_PATH, 'boost_python-vc71-mt-1_33.lib')
68
BOOST_INCLUDE_PATH = os.path.join(BOOST_ROOT, 'include', 'boost-1_33')
70
os.path.join(BOOST_LIB_PATH, 'boost_python-vc71-mt-1_33.dll'),
63
BOOST_INCLUDE_PATH = os.path.join(BOOST_ROOT, 'include')
64
BOOST_LIBRARIES = [os.path.splitext(os.path.basename(f))[0] for f in
65
glob(os.path.join(BOOST_LIB_PATH, '*.lib'))]
66
BOOST_RUNTIMES = glob(os.path.join(BOOST_LIB_PATH, '*.dll'))
68
ZLIB_INCLUDE_PATH = os.path.join(BINARY_KIT_ROOT, 'zlib', 'include')
69
ZLIB_LIB_PATH = os.path.join(BINARY_KIT_ROOT, 'zlib', 'lib')
70
ZLIB_RUNTIME_LIBRARY_PATH = os.path.join(BINARY_KIT_ROOT, 'zlib')
71
ZLIB_RUNTIMES = [os.path.join(ZLIB_RUNTIME_LIBRARY_PATH, 'zlib1.dll')]
73
OPENSSL_INCLUDE_PATH = os.path.join(BINARY_KIT_ROOT, 'openssl', 'include')
74
OPENSSL_LIB_PATH = os.path.join(BINARY_KIT_ROOT, 'openssl', 'lib')
75
OPENSSL_LIBRARIES = [ 'ssleay32', 'libeay32']
73
79
# The 'Democracy.exe' launcher stub, currently provided only in the
167
173
# Find the top of the source tree and set search path
168
174
root = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), '..', '..')
175
platform_dir = os.path.join(root, 'platform', 'windows-xul')
176
portable_dir = os.path.join(root, 'portable')
169
177
sys.path[0:0] = [
170
os.path.join(root, 'platform', platform),
171
os.path.join(root, 'platform'),
172
os.path.join(root, 'portable'),
174
181
root = os.path.normpath(root)
183
#### The database extension ####
184
database_ext = Extension("database",
185
sources=[os.path.join(root, 'portable', 'database.pyx')])
176
187
#### The fasttypes extension ####
178
189
fasttypes_ext = \
179
190
Extension("fasttypes",
180
191
sources = [os.path.join(root, 'portable', 'fasttypes.cpp')],
181
extra_objects = [BOOST_LIB],
192
library_dirs = [BOOST_LIB_PATH],
182
193
include_dirs = [BOOST_INCLUDE_PATH]
185
os.environ['PATH'] = r'%s;%s' % (os.environ['PATH'], BOOST_LIB_PATH)
196
# Setting the path here allows py2exe to find the DLLS
197
os.environ['PATH'] = r'%s;%s;%s;%s' % (os.environ['PATH'], BOOST_LIB_PATH,
198
ZLIB_RUNTIME_LIBRARY_PATH, OPENSSL_LIB_PATH)
200
##### The libtorrent extension ####
203
for root,dirs,files in os.walk(os.path.join(portable_dir, 'libtorrent')):
209
if file.endswith('.cpp'):
210
yield os.path.join(root,file)
212
libtorrent_sources=list(fetchCpp())
213
libtorrent_sources.remove(os.path.join(portable_dir, 'libtorrent\\src\\file.cpp'))
215
print [ BOOST_LIB_PATH, OPENSSL_LIB_PATH, ZLIB_LIB_PATH]
216
libtorrent_ext = Extension(
219
os.path.join(portable_dir, 'libtorrent', 'include'),
220
os.path.join(portable_dir, 'libtorrent', 'include', 'libtorrent'),
223
OPENSSL_INCLUDE_PATH,
225
library_dirs = [ BOOST_LIB_PATH, OPENSSL_LIB_PATH, ZLIB_LIB_PATH],
226
libraries = OPENSSL_LIBRARIES + BOOST_LIBRARIES + [
227
'wsock32', 'gdi32', 'ws2_32', 'zdll'
229
extra_compile_args = [ '-DBOOST_WINDOWS',
230
'-DWIN32_LEAN_AND_MEAN',
231
'-D_WIN32_WINNT=0x0500',
232
'-D__USE_W32_SOCKETS',
235
'-DBOOST_ALL_NO_LIB',
236
'-D_FILE_OFFSET_BITS=64',
237
'-DBOOST_THREAD_USE_LIB',
238
'-DTORRENT_USE_OPENSSL=1',
242
sources = libtorrent_sources)
187
244
# Private extension modules to build.
192
251
#Extension("vlc", [os.path.join(root, 'platform',platform, 'vlc.pyx')],libraries=["simplevlc"]),
193
Extension("database", [os.path.join(root, 'portable', 'database.pyx')]),
194
252
Extension("sorts", [os.path.join(root, 'portable', 'sorts.pyx')]),
195
253
#Extension("template", [os.path.join(root, 'portable', 'template.pyx')]),