-
Notifications
You must be signed in to change notification settings - Fork 9
/
gp-setup.py.in
76 lines (71 loc) · 2.43 KB
/
gp-setup.py.in
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
#!/usr/bin/python
# gp-setup.py - python distutils script for use in automake-based build system
#
# Copyright (C) 2003-2004 David PHAM-VAN -- [email protected]
# Copyright (C) 2007 Hans Ulrich Niedermann <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
def my_include_dirs():
"""create list of include dirs from LIBGPHOTO2_CFLAGS env var"""
import os
libgphoto2_include_dirs = []
for x in os.getenv("LIBGPHOTO2_CFLAGS").split():
if x[:3] == "-I/":
libgphoto2_include_dirs.append(x[2:])
return libgphoto2_include_dirs
def my_lib_dirs():
"""create list of library dirs (for rpath and -L) from LIBGPHOTO2_LIBS env var"""
import os
res = []
for x in os.getenv("LIBGPHOTO2_LIBS").split():
if x[:3] == "-L/":
res.append(x[2:])
elif x[-3:] == ".la" and os.path.isfile(x):
import re
r = re.compile("^libdir='(.*)'$")
for line in open(x,"r").readlines():
m = r.match(line)
if m:
res.append(m.group(1))
ret = []
for x in res:
if x not in ret:
ret.append(x)
return ret
setup(
name = "@PACKAGE_TARNAME@",
version = "@PACKAGE_VERSION@",
description = "@PACKAGE_NAME@",
maintainer_email = "@PACKAGE_BUGREPORT@",
url = "@URL_GPHOTO_HOME@",
license = "LGPL 2",
ext_modules=[
Extension(
"gphoto2",
[ "gphoto2.pyx" ],
runtime_library_dirs = my_lib_dirs(),
library_dirs = my_lib_dirs(),
libraries = [ "gphoto2" ],
include_dirs = my_include_dirs(),
)
],
cmdclass = {'build_ext': build_ext}
)
# Local Variables:
# mode: python
# End: