forked from smartfile/python-libarchive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
119 lines (107 loc) · 4.89 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python
#
# Copyright (c) 2015, SmartFile <tcunningham@smartfile.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the organization nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from os import environ
try:
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
except ImportError:
from distutils.core import setup, Extension
from distutils.command.build_ext import build_ext
name = 'python-libarchive'
version = '4.0.0'
release = '1'
versrel = version + '-' + release
readme = 'README.rst'
download_url = "http://" + name + ".googlecode.com/files/" + name + "-" + \
versrel + ".tar.gz"
long_description = open(readme).read()
class build_ext_extra(build_ext, object):
"""
Extend build_ext allowing extra_compile_args and extra_link_args to be set
on the command-line.
"""
user_options = build_ext.user_options
user_options.append(
('extra-compile-args=', None,
'Extra arguments passed directly to the compiler')
)
user_options.append(
('extra-link-args=', None,
'Extra arguments passed directly to the linker')
)
def initialize_options(self):
build_ext.initialize_options(self)
self.extra_compile_args = None
self.extra_link_args = None
def build_extension(self, ext):
if self.extra_compile_args:
ext.extra_compile_args.append(self.extra_compile_args)
if self.extra_link_args:
ext.extra_link_args.append(self.extra_link_args)
super(build_ext_extra, self).build_extension(ext)
# Use a provided libarchive else default to hard-coded path.
libarchivePrefix = environ.get('LIBARCHIVE_PREFIX')
if libarchivePrefix:
extra_compile_args = ['-I{0}/include'.format(libarchivePrefix)]
extra_link_args = ['-Wl,-rpath={0}/lib'.format(libarchivePrefix)]
environ['LDFLAGS'] = '-L{0}/lib {1}'.format(libarchivePrefix,
environ.get('LDFLAGS', ''))
else:
extra_compile_args = []
extra_link_args = ['-l:libarchive.so.13']
__libarchive = Extension(name='libarchive.__libarchive',
sources=['libarchive/_libarchive_wrap.c'],
libraries=['archive'],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
include_dirs=['libarchive'],
)
setup(name = name,
version = versrel,
description = 'A libarchive wrapper for Python.',
long_description = long_description,
license = 'BSD-style license',
platforms = ['any'],
author = 'Ben Timby, Travis Cunningham, Ryan Johnston, SmartFile',
author_email = 'tcunningham@smartfile.com',
url = 'https://github.com/smartfile/python-libarchive',
download_url = download_url,
packages = ['libarchive'],
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Programming Language :: C',
'Programming Language :: Python',
'Topic :: System :: Archiving :: Compression',
'Topic :: Software Development :: Libraries :: Python Modules',
],
cmdclass = {
'build_ext': build_ext_extra,
},
ext_modules = [__libarchive],
)