add windows support to setup.py

This commit is contained in:
Marcos Pinto 2008-02-03 01:04:26 +00:00
parent 8ab923fb94
commit 34fd115051

View File

@ -44,6 +44,13 @@ import os
python_version = platform.python_version()[0:3]
def windows_check():
import platform
if platform.system() in ('Windows', 'Microsoft'):
return True
else:
return False
# Try to get SVN revision number to append to version
revision_string = ""
try:
@ -79,9 +86,26 @@ _extra_compile_args = [
"-O2",
"-DNDEBUG"
]
if windows_check():
_extra_compile_args.remove("-Wno-missing-braces")
_extra_compile_args = _extra_compile_args + [
"-DBOOST_WINDOWS",
"-DWIN32_LEAN_AND_MEAN",
"-D_WIN32_WINNT=0x0500",
"-D__USE_W32_SOCKETS",
"-D_WIN32",
"-DWIN32",
"-DUNICODE",
"-DBOOST_ALL_NO_LIB",
"-D_FILE_OFFSET_BITS=64",
"-DBOOST_THREAD_USE_LIB",
"-DTORRENT_BUILDING_SHARED",
"-DTORRENT_LINKING_SHARED",
]
removals = ["-Wstrict-prototypes"]
if not windows_check():
if python_version == '2.5':
cv_opt = sysconfig.get_config_vars()["CFLAGS"]
for removal in removals:
@ -93,6 +117,8 @@ else:
cv_opt = cv_opt.replace(removal, " ")
sysconfig.get_config_vars()["OPT"] = " ".join(cv_opt.split())
_extra_link_args = [
]
_include_dirs = [
'./libtorrent',
'./libtorrent/include',
@ -108,14 +134,32 @@ _libraries = [
'z',
'pthread',
'ssl',
]
if windows_check():
_extra_link_args = _extra_link_args + [
'-L./win32/lib'
]
_include_dirs.remove('/usr/include/python' + python_version)
_include_dirs = _include_dirs + [
'./win32/include'
]
_libraries.remove('ssl')
_libraries = _libraries + [
'ssleay32MT',
'libeay32MT',
'advapi32',
'wsock32',
'gdi32',
'ws2_32'
]
_sources = glob.glob("./libtorrent/src/*.cpp") + \
glob.glob("./libtorrent/src/kademlia/*.cpp") + \
glob.glob("./libtorrent/bindings/python/src/*.cpp")
# Remove file_win.cpp as it is only for Windows builds
# Remove file_win.cpp if not on windows
if not windows_check():
for source in _sources:
if "file_win.cpp" in source:
_sources.remove(source)
@ -126,6 +170,7 @@ libtorrent = Extension(
include_dirs = _include_dirs,
libraries = _libraries,
extra_compile_args = _extra_compile_args,
extra_link_args = _extra_link_args,
sources = _sources
)