Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 143 lines (126 sloc) 4.886 kb
705e021 @fancycode set svn:eol-style to "native"
authored
1 #!/usr/bin/python -u
2 #
3 # Python Bindings for LZMA
4 #
b681342 @fancycode updated year in copyright header
authored
5 # Copyright (c) 2004-2008 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
38849c0 @fancycode added "ez_setup.py" to enfore compilation using setuptools
authored
28 from ez_setup import use_setuptools
29 use_setuptools()
30
31 from setuptools import setup, Extension
705e021 @fancycode set svn:eol-style to "native"
authored
32
33 class UnsupportedPlatformWarning(Warning):
34 pass
35
36 # set this to any true value to enable multithreaded compression
a2a0b0e @fancycode added initial code for compatibility decompression (streams without EOS ...
authored
37 ENABLE_MULTITHREADING = True
38
39 # set this to any true value to add the compatibility decoder
40 # from version 0.0.3 to be able to decompress strings without
41 # the end of stream mark and you don't know their lengths
42 ENABLE_COMPATIBILITY = True
705e021 @fancycode set svn:eol-style to "native"
authored
43
0025835 @fancycode added switch to compile with debug symbols on windows
authored
44 # compile including debug symbols on Windows?
45 COMPILE_DEBUG = False
46
41c056d @fancycode Fixed compilation on Apple platforms.
authored
47 # are we running on Windows?
48 IS_WINDOWS = sys.platform in ('win32', )
49
50 libraries = []
51 if IS_WINDOWS:
52 libraries += ['user32', 'oleaut32']
705e021 @fancycode set svn:eol-style to "native"
authored
53
54 include_dirs = [
55 ".",
56 ]
57
58 library_dirs = [
59 ".",
60 ]
61
62 mt_platforms = (
63 'win32',
64 )
65
66 if ENABLE_MULTITHREADING and not sys.platform in mt_platforms:
67 warn("""\
68 Multithreading is not supported on the platform "%s",
69 please contact mail@joachim-bauch.de for more informations.""" % (sys.platform), UnsupportedPlatformWarning)
70 ENABLE_MULTITHREADING = 0
71
72 descr = "Python bindings for the LZMA library by Igor Pavlov."
72927fe @fancycode updates for building egg package
authored
73 long_descr = """PyLZMA provides a platform independent way to read and write data
74 that has been compressed or can be decompressed by the LZMA library by Igor Pavlov."""
705e021 @fancycode set svn:eol-style to "native"
authored
75 try: version = open('version.txt', 'rb').read().strip()
76 except: version = 'unknown'
77 modules = ['py7zlib']
78 c_files = ['pylzma.c', 'pylzma_decompressobj.c', 'pylzma_compressfile.cpp',
79 'pylzma_decompress.c', 'pylzma_compress.cpp', 'pylzma_guids.cpp']
80 compile_args = []
0025835 @fancycode added switch to compile with debug symbols on windows
authored
81 link_args = []
705e021 @fancycode set svn:eol-style to "native"
authored
82 macros = []
41c056d @fancycode Fixed compilation on Apple platforms.
authored
83 if IS_WINDOWS:
705e021 @fancycode set svn:eol-style to "native"
authored
84 macros.append(('WIN32', 1))
0025835 @fancycode added switch to compile with debug symbols on windows
authored
85 if COMPILE_DEBUG:
86 compile_args.append('/Zi')
e7801a8 @fancycode don't link against msvcXX.dll but include necessary functions in pylzma....
authored
87 compile_args.append('/MTd')
0025835 @fancycode added switch to compile with debug symbols on windows
authored
88 link_args.append('/DEBUG')
e7801a8 @fancycode don't link against msvcXX.dll but include necessary functions in pylzma....
authored
89 else:
90 compile_args.append('/MT')
41c056d @fancycode Fixed compilation on Apple platforms.
authored
91 if not IS_WINDOWS:
705e021 @fancycode set svn:eol-style to "native"
authored
92 # disable gcc warning about virtual functions with non-virtual destructors
93 compile_args.append(('-Wno-non-virtual-dtor'))
94 if ENABLE_MULTITHREADING:
95 macros.append(('COMPRESS_MF_MT', 1))
ed554ef @fancycode prepared for update to new 7-zip SDK
authored
96 lzma_files = ('src/LzmaStateDecode.c', 'src/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp',
97 'src/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp', 'src/CPP/Common/CRC.cpp',
98 'src/CPP/7zip/Compress/LZ/LZInWindow.cpp', 'src/CPP/7zip/Common/StreamUtils.cpp',
99 'src/CPP/7zip/Common/OutBuffer.cpp', 'src/CPP/Common/Alloc.cpp', 'src/CPP/Common/NewHandler.cpp', )
705e021 @fancycode set svn:eol-style to "native"
authored
100 if ENABLE_MULTITHREADING:
ed554ef @fancycode prepared for update to new 7-zip SDK
authored
101 lzma_files += ('src/CPP/7zip/Compress/LZ/MT/MT.cpp', 'src/CPP/OS/Synchronization.cpp', )
a2a0b0e @fancycode added initial code for compatibility decompression (streams without EOS ...
authored
102 if ENABLE_COMPATIBILITY:
103 c_files += ('pylzma_decompress_compat.c', 'pylzma_decompressobj_compat.c', )
ed554ef @fancycode prepared for update to new 7-zip SDK
authored
104 lzma_files += ('src/LzmaCompatDecode.c', )
a2a0b0e @fancycode added initial code for compatibility decompression (streams without EOS ...
authored
105 macros.append(('WITH_COMPAT', 1))
38849c0 @fancycode added "ez_setup.py" to enfore compilation using setuptools
authored
106
107 c_files += [os.path.normpath(os.path.join('.', x)) for x in lzma_files]
108 extens = [
109 Extension('pylzma', c_files, include_dirs=include_dirs, libraries=libraries,
110 library_dirs=library_dirs, define_macros=macros, extra_compile_args=compile_args,
111 extra_link_args=link_args),
112 ]
705e021 @fancycode set svn:eol-style to "native"
authored
113
41c056d @fancycode Fixed compilation on Apple platforms.
authored
114 if IS_WINDOWS:
72927fe @fancycode updates for building egg package
authored
115 operating_system = 'Microsoft :: Windows'
116 else:
117 operating_system = 'POSIX :: Linux'
118
119 setup(
120 name = "pylzma",
121 version = version,
122 description = descr,
123 author = "Joachim Bauch",
124 author_email = "mail@joachim-bauch.de",
38849c0 @fancycode added "ez_setup.py" to enfore compilation using setuptools
authored
125 url = "http://www.joachim-bauch.de/projects/python/pylzma/",
72927fe @fancycode updates for building egg package
authored
126 license = 'LGPL',
127 keywords = "lzma compression",
128 long_description = long_descr,
129 platforms = sys.platform,
130 classifiers = [
131 'Development Status :: 5 - Production/Stable',
132 'Programming Language :: Python',
133 'Topic :: Software Development :: Libraries :: Python Modules',
134 'Intended Audience :: Developers',
135 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
136 'Operating System :: %s' % operating_system,
137 ],
138 py_modules = modules,
139 ext_modules = extens,
38849c0 @fancycode added "ez_setup.py" to enfore compilation using setuptools
authored
140 test_suite = 'tests',
141 zip_safe = False,
72927fe @fancycode updates for building egg package
authored
142 )
Something went wrong with that request. Please try again.