Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 131 lines (115 sloc) 4.515 kb
705e021 @fancycode set svn:eol-style to "native"
authored
1 #!/usr/bin/python -u
2 #
3 # Python Bindings for LZMA
4 #
72171d7 @fancycode updated year in copyright header
authored
5 # Copyright (c) 2004-2006 by Joachim Bauch, mail@joachim-bauch.de
705e021 @fancycode set svn:eol-style to "native"
authored
6 # 7-Zip Copyright (C) 1999-2005 Igor Pavlov
7 # LZMA SDK Copyright (C) 1999-2005 Igor Pavlov
8 #
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
13 #
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
18 #
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #
23 # $Id$
24 #
25 import sys, os
26 from warnings import warn
d9518aa @fancycode added "license" entry to extension
authored
27
28 # set this to True to create an egg package
29 BUILD_EGG = False
30
31 if BUILD_EGG:
32 from setuptools import setup, Extension
33 else:
34 from distutils.core import setup, Extension
705e021 @fancycode set svn:eol-style to "native"
authored
35
36 PYTHON_VERSION=sys.version[:3]
37 PYTHON_PREFIX=sys.prefix
38
39 class UnsupportedPlatformWarning(Warning):
40 pass
41
42 # set this to any true value to enable multithreaded compression
a2a0b0e @fancycode added initial code for compatibility decompression (streams without E…
authored
43 ENABLE_MULTITHREADING = True
44
45 # set this to any true value to add the compatibility decoder
46 # from version 0.0.3 to be able to decompress strings without
47 # the end of stream mark and you don't know their lengths
48 ENABLE_COMPATIBILITY = True
705e021 @fancycode set svn:eol-style to "native"
authored
49
0025835 @fancycode added switch to compile with debug symbols on windows
authored
50 # compile including debug symbols on Windows?
51 COMPILE_DEBUG = False
52
705e021 @fancycode set svn:eol-style to "native"
authored
53 if os.name == 'posix':
54 # This is the directory, your Python is installed in. It must contain the header and include files.
55 PYTHON_INCLUDE_DIR="%s/include/python%s" % (PYTHON_PREFIX, PYTHON_VERSION)
56 PYTHON_LIB_DIR="%s/lib/python%s" % (PYTHON_PREFIX, PYTHON_VERSION)
57 libraries=[]
58 else:
59 PYTHON_INCLUDE_DIR="%s\\include" % (PYTHON_PREFIX)
60 PYTHON_LIB_DIR="%s\\libs" % (PYTHON_PREFIX)
61 libraries=['user32', 'oleaut32']
62
63 include_dirs = [
64 PYTHON_INCLUDE_DIR,
65 ".",
66 ]
67
68 library_dirs = [
69 PYTHON_LIB_DIR,
70 ".",
71 ]
72
73 mt_platforms = (
74 'win32',
75 )
76
77 if ENABLE_MULTITHREADING and not sys.platform in mt_platforms:
78 warn("""\
79 Multithreading is not supported on the platform "%s",
80 please contact mail@joachim-bauch.de for more informations.""" % (sys.platform), UnsupportedPlatformWarning)
81 ENABLE_MULTITHREADING = 0
82
83 descr = "Python bindings for the LZMA library by Igor Pavlov."
84 try: version = open('version.txt', 'rb').read().strip()
85 except: version = 'unknown'
86 modules = ['py7zlib']
87 c_files = ['pylzma.c', 'pylzma_decompressobj.c', 'pylzma_compressfile.cpp',
88 'pylzma_decompress.c', 'pylzma_compress.cpp', 'pylzma_guids.cpp']
89 compile_args = []
0025835 @fancycode added switch to compile with debug symbols on windows
authored
90 link_args = []
705e021 @fancycode set svn:eol-style to "native"
authored
91 macros = []
92 if 'win' in sys.platform:
93 macros.append(('WIN32', 1))
0025835 @fancycode added switch to compile with debug symbols on windows
authored
94 if COMPILE_DEBUG:
95 compile_args.append('/Zi')
96 link_args.append('/DEBUG')
705e021 @fancycode set svn:eol-style to "native"
authored
97 if not 'win' in sys.platform:
98 # disable gcc warning about virtual functions with non-virtual destructors
99 compile_args.append(('-Wno-non-virtual-dtor'))
100 if ENABLE_MULTITHREADING:
101 macros.append(('COMPRESS_MF_MT', 1))
102 lzma_files = ('7zip/LzmaStateDecode.c', '7zip/7zip/Compress/LZMA/LZMAEncoder.cpp',
103 '7zip/7zip/Compress/RangeCoder/RangeCoderBit.cpp', '7zip/Common/CRC.cpp',
5f6432a @fancycode updated to 7-Zip version 4.32
authored
104 '7zip/7zip/Compress/LZ/LZInWindow.cpp', '7zip/7zip/Common/StreamUtils.cpp',
105 '7zip/7zip/Common/OutBuffer.cpp', '7zip/Common/Alloc.cpp', '7zip/Common/NewHandler.cpp', )
705e021 @fancycode set svn:eol-style to "native"
authored
106 if ENABLE_MULTITHREADING:
107 lzma_files += ('7zip/7zip/Compress/LZ/MT/MT.cpp', '7zip/OS/Synchronization.cpp', )
a2a0b0e @fancycode added initial code for compatibility decompression (streams without E…
authored
108 if ENABLE_COMPATIBILITY:
109 c_files += ('pylzma_decompress_compat.c', 'pylzma_decompressobj_compat.c', )
562b0e7 @fancycode fixed typo
authored
110 lzma_files += ('7zip/LzmaCompatDecode.c', )
a2a0b0e @fancycode added initial code for compatibility decompression (streams without E…
authored
111 macros.append(('WITH_COMPAT', 1))
705e021 @fancycode set svn:eol-style to "native"
authored
112 join = os.path.join
113 normalize = os.path.normpath
114 c_files += map(lambda x: normalize(join('.', x)), lzma_files)
115 extens=[Extension('pylzma', c_files, include_dirs=include_dirs, libraries=libraries,
0025835 @fancycode added switch to compile with debug symbols on windows
authored
116 library_dirs=library_dirs, define_macros=macros, extra_compile_args=compile_args,
117 extra_link_args=link_args)]
705e021 @fancycode set svn:eol-style to "native"
authored
118
119 setup (name = "pylzma",
120 version = version,
121 description = descr,
122 author = "Joachim Bauch",
123 author_email = "mail@joachim-bauch.de",
124 url = "http://www.joachim-bauch.de",
d9518aa @fancycode added "license" entry to extension
authored
125 license = 'LGPL',
705e021 @fancycode set svn:eol-style to "native"
authored
126 py_modules=modules,
127 ext_modules=extens,
128 )
129
130 sys.exit(0)
Something went wrong with that request. Please try again.