2
# -*- coding: utf-8 -*-
4
# Python Bindings for libLZMA
6
# Copyright (c) 2008 Per Øyvind Karlsen <peroyvind@mandriva.org>
7
# liblzma Copyright (C) 2007-2008 Lasse Collin
8
# LZMA SDK Copyright (C) 1999-2007 Igor Pavlov
10
# This library is free software; you can redistribute it and/or
11
# modify it under the terms of the GNU Lesser General Public
12
# License as published by the Free Software Foundation; either
13
# version 3 of the License, or (at your option) any later version.
15
# This library is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
# Lesser General Public License for more details.
20
# You should have received a copy of the GNU Lesser General Public
21
# License along with this library; if not, write to the Free Software
22
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
import sys, os, subprocess
25
from warnings import warn
26
from setuptools import setup, Extension
28
descr = "Python bindings for liblzma"
29
long_descr = """PylibLZMA provides a python interface for the liblzma library
30
to read and write data that has been compressed or can be decompressed
31
by Lasse Collin's xz / lzma utils."""
33
version_define = [('VERSION', '"%s"' % version)]
35
# FIXME: Probably some nicer way to do this
36
if 'sdist' in sys.argv:
37
os.system('bzr log . > ChangeLog')
39
c_files = ['liblzma.c', 'liblzma_compressobj.c', 'liblzma_decompressobj.c', 'liblzma_file.c', 'liblzma_fileobj.c', 'liblzma_options.c', 'liblzma_util.c']
40
for i in xrange(len(c_files)):
41
c_files[i] = os.path.join('src', c_files[i])
44
warnflags = ['-Wall', '-Wextra', '-pedantic', '-Wswitch-enum', '-Wswitch-default']
45
compile_args.extend(warnflags)
47
if not subprocess.Popen('touch gnu99-test.c; gcc -std=gnu99 -E gnu99-test.c > /dev/null; rm -f gnu99-test.c',
48
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True).stdout.read():
49
compile_args.append('-std=gnu99')
51
pc_cflags = subprocess.Popen("pkg-config --cflags liblzma", shell=True, stdout=subprocess.PIPE, close_fds=True).stdout.readline().strip()
53
compile_args.extend(pc_cflags.split(' '))
54
pc_libs = subprocess.Popen("pkg-config --libs liblzma", shell=True, stdout=subprocess.PIPE, close_fds=True).stdout.readline().strip()
56
link_args.extend(pc_libs.split(' '))
58
extens=[Extension('lzma', c_files, extra_compile_args=compile_args, extra_link_args=link_args, define_macros=version_define)]
64
author = "Per Øyvind Karlsen",
65
author_email = "peroyvind@mandriva.org",
66
url = "https://launchpad.net/pyliblzma",
68
keywords = "xz lzma compression",
69
long_description = long_descr,
70
platforms = sys.platform,
72
'Development Status :: 4 - Beta',
73
'Programming Language :: Python',
74
'Topic :: Software Development :: Libraries :: Python Modules',
75
'Intended Audience :: Developers',
76
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
77
'Operating System :: POSIX :: Linux'