Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 174 lines (151 sloc) 5.94 kB
705e021 @fancycode set svn:eol-style to "native"
authored
1 #!/usr/bin/python -u
2 #
3 # Python Bindings for LZMA
4 #
3242ded @fancycode updated year in copyright
authored
5 # Copyright (c) 2004-2010 by Joachim Bauch, mail@joachim-bauch.de
6 # 7-Zip Copyright (C) 1999-2010 Igor Pavlov
7 # LZMA SDK Copyright (C) 1999-2010 Igor Pavlov
705e021 @fancycode set svn:eol-style to "native"
authored
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
352c407 @fancycode updated integration of multithreaded compression
authored
27 from distutils import log
28 from distutils.command.build_ext import build_ext as _build_ext
35fb77f @fancycode get version from latest git tag
authored
29 from version import get_git_version
d9518aa @fancycode added "license" entry to extension
authored
30
c7fb5a9 @fancycode use distribute instead of setuptools (supports Python 3.x), don't dep…
authored
31 try:
32 from setuptools import setup, Extension
33 except ImportError:
34 from distribute_setup import use_setuptools
35 use_setuptools()
36
37 from setuptools import setup, Extension
705e021 @fancycode set svn:eol-style to "native"
authored
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
41c056d @fancycode Fixed compilation on Apple platforms.
authored
53 # are we running on Windows?
54 IS_WINDOWS = sys.platform in ('win32', )
55
56 libraries = []
57 if IS_WINDOWS:
58 libraries += ['user32', 'oleaut32']
705e021 @fancycode set svn:eol-style to "native"
authored
59
770175b @fancycode added initial support for AES256-SHA256 encrpyted archives (Bugzilla #7)
authored
60 include_dirs = [
61 'src/sdk',
62 ]
705e021 @fancycode set svn:eol-style to "native"
authored
63
37fe07b @fancycode Use additional include directories on Darwin.
authored
64 if sys.platform == 'darwin':
65 # additional include directories are required when compiling on Darwin platforms
66 include_dirs += [
67 "/var/include",
68 ]
69
c9f5ba9 @fancycode updated LZMA SDK, lots of code cleanup, restructured directories
authored
70 library_dirs = []
705e021 @fancycode set svn:eol-style to "native"
authored
71
352c407 @fancycode updated integration of multithreaded compression
authored
72 # platforms that multithreaded compression is supported on
705e021 @fancycode set svn:eol-style to "native"
authored
73 mt_platforms = (
74 'win32',
75 )
76
c754612 @fancycode don't try to import MSVCCompiler on non-windows (issue #11)
authored
77 if IS_WINDOWS:
78 # don't try to import MSVC compiler on non-windows platforms
79 # as this triggers unnecessary warnings
80 from distutils.msvccompiler import MSVCCompiler
81 else:
82 class MSVCCompiler(object):
83 # dummy marker class
84 pass
85
352c407 @fancycode updated integration of multithreaded compression
authored
86 class build_ext(_build_ext):
87
88 def build_extension(self, ext):
89 self.with_mt = ENABLE_MULTITHREADING
90 if self.with_mt and not sys.platform in mt_platforms:
91 warn("""\
705e021 @fancycode set svn:eol-style to "native"
authored
92 Multithreading is not supported on the platform "%s",
93 please contact mail@joachim-bauch.de for more informations.""" % (sys.platform), UnsupportedPlatformWarning)
352c407 @fancycode updated integration of multithreaded compression
authored
94 self.with_mt = False
95
96 if self.with_mt:
97 log.info('adding support for multithreaded compression')
98 ext.define_macros.append(('COMPRESS_MF_MT', 1))
99 ext.sources += ('src/sdk/LzFindMt.c', 'src/sdk/Threads.c', )
100
035634c @fancycode updated compiler detection
authored
101 if isinstance(self.compiler, MSVCCompiler):
102 # set flags only available when using MSVC
1c82237 @fancycode Fixed compilation issue when using MSVC, thanks Zart.
authored
103 ext.extra_link_args.append('/MANIFEST')
035634c @fancycode updated compiler detection
authored
104 if COMPILE_DEBUG:
105 ext.extra_compile_args.append('/Zi')
106 ext.extra_compile_args.append('/MTd')
107 ext.extra_link_args.append('/DEBUG')
108 else:
109 ext.extra_compile_args.append('/MT')
110
352c407 @fancycode updated integration of multithreaded compression
authored
111 _build_ext.build_extension(self, ext)
705e021 @fancycode set svn:eol-style to "native"
authored
112
113 descr = "Python bindings for the LZMA library by Igor Pavlov."
72927fe @fancycode updates for building egg package
authored
114 long_descr = """PyLZMA provides a platform independent way to read and write data
115 that has been compressed or can be decompressed by the LZMA library by Igor Pavlov."""
705e021 @fancycode set svn:eol-style to "native"
authored
116 modules = ['py7zlib']
c9f5ba9 @fancycode updated LZMA SDK, lots of code cleanup, restructured directories
authored
117 c_files = ['src/pylzma/pylzma.c', 'src/pylzma/pylzma_decompressobj.c', 'src/pylzma/pylzma_compressfile.c',
770175b @fancycode added initial support for AES256-SHA256 encrpyted archives (Bugzilla #7)
authored
118 'src/pylzma/pylzma_decompress.c', 'src/pylzma/pylzma_compress.c', 'src/pylzma/pylzma_streams.c', \
119 'src/pylzma/pylzma_aes.c']
705e021 @fancycode set svn:eol-style to "native"
authored
120 compile_args = []
0025835 @fancycode added switch to compile with debug symbols on windows
authored
121 link_args = []
705e021 @fancycode set svn:eol-style to "native"
authored
122 macros = []
770175b @fancycode added initial support for AES256-SHA256 encrpyted archives (Bugzilla #7)
authored
123 lzma_files = ('src/sdk/LzFind.c', 'src/sdk/LzmaDec.c', 'src/sdk/LzmaEnc.c', \
124 'src/7zip/C/CpuArch.c', 'src/7zip/C/Aes.c', 'src/7zip/C/AesOpt.c', \
125 'src/7zip/C/Sha256.c')
a2a0b0e @fancycode added initial code for compatibility decompression (streams without E…
authored
126 if ENABLE_COMPATIBILITY:
c9f5ba9 @fancycode updated LZMA SDK, lots of code cleanup, restructured directories
authored
127 c_files += ('src/pylzma/pylzma_decompress_compat.c', 'src/pylzma/pylzma_decompressobj_compat.c', )
17a15da @fancycode moved compatibility decompression code to custom source folder
authored
128 lzma_files += ('src/compat/LzmaCompatDecode.c', )
a2a0b0e @fancycode added initial code for compatibility decompression (streams without E…
authored
129 macros.append(('WITH_COMPAT', 1))
38849c0 @fancycode added "ez_setup.py" to enfore compilation using setuptools
authored
130
131 c_files += [os.path.normpath(os.path.join('.', x)) for x in lzma_files]
132 extens = [
133 Extension('pylzma', c_files, include_dirs=include_dirs, libraries=libraries,
134 library_dirs=library_dirs, define_macros=macros, extra_compile_args=compile_args,
135 extra_link_args=link_args),
136 ]
705e021 @fancycode set svn:eol-style to "native"
authored
137
938d6d7 @fancycode Use backported hashlib module for Python versions prior to 2.5
authored
138 install_requires = []
c7fb5a9 @fancycode use distribute instead of setuptools (supports Python 3.x), don't dep…
authored
139 tests_require = []
140
72927fe @fancycode updates for building egg package
authored
141 setup(
142 name = "pylzma",
c7fb5a9 @fancycode use distribute instead of setuptools (supports Python 3.x), don't dep…
authored
143 version = get_git_version().decode('utf-8'),
72927fe @fancycode updates for building egg package
authored
144 description = descr,
145 author = "Joachim Bauch",
146 author_email = "mail@joachim-bauch.de",
a8d8210 @fancycode updated urls
authored
147 url = "http://www.joachim-bauch.de/projects/pylzma/",
4304aa2 @fancycode fixed pypi url
authored
148 download_url = "http://pypi.python.org/pypi/pylzma/",
72927fe @fancycode updates for building egg package
authored
149 license = 'LGPL',
150 keywords = "lzma compression",
151 long_description = long_descr,
152 classifiers = [
153 'Development Status :: 5 - Production/Stable',
154 'Programming Language :: Python',
6cdc4ab @fancycode added Python 3 to list of supported programming languages
authored
155 'Programming Language :: Python :: 3',
72927fe @fancycode updates for building egg package
authored
156 'Topic :: Software Development :: Libraries :: Python Modules',
157 'Intended Audience :: Developers',
158 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
07ea110 @fancycode pylzma is os independent
authored
159 'Operating System :: OS Independent',
72927fe @fancycode updates for building egg package
authored
160 ],
161 py_modules = modules,
162 ext_modules = extens,
352c407 @fancycode updated integration of multithreaded compression
authored
163 cmdclass = {
164 'build_ext': build_ext,
165 },
938d6d7 @fancycode Use backported hashlib module for Python versions prior to 2.5
authored
166 install_requires = install_requires,
770175b @fancycode added initial support for AES256-SHA256 encrpyted archives (Bugzilla #7)
authored
167 extras_require = {
d40a095 @fancycode we have our own internal decryption for AES256/SHA256, M2Crypto is no…
authored
168 'decrypt': [],
770175b @fancycode added initial support for AES256-SHA256 encrpyted archives (Bugzilla #7)
authored
169 },
c7fb5a9 @fancycode use distribute instead of setuptools (supports Python 3.x), don't dep…
authored
170 tests_require = tests_require,
9e158d4 @fancycode made tests runnable from setup.py, fixed deprecation warnings due to …
authored
171 test_suite = 'tests.suite',
38849c0 @fancycode added "ez_setup.py" to enfore compilation using setuptools
authored
172 zip_safe = False,
72927fe @fancycode updates for building egg package
authored
173 )
Something went wrong with that request. Please try again.