Gentoo Archives: gentoo-commits

From: "Kacper Kowalik (xarthisius)" <xarthisius@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-python/pywcs/files: pywcs-1.11-wcslib.patch
Date: Fri, 06 Jan 2012 17:37:12
Message-Id: 20120106173702.AEBFA2004C@flycatcher.gentoo.org
1 xarthisius 12/01/06 17:37:02
2
3 Added: pywcs-1.11-wcslib.patch
4 Log:
5 Version bump, adds Python3 support
6
7 (Portage version: 2.2.0_alpha84/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 dev-python/pywcs/files/pywcs-1.11-wcslib.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/pywcs/files/pywcs-1.11-wcslib.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/pywcs/files/pywcs-1.11-wcslib.patch?rev=1.1&content-type=text/plain
14
15 Index: pywcs-1.11-wcslib.patch
16 ===================================================================
17 --- defsetup.py
18 +++ defsetup.py
19 @@ -78,73 +78,27 @@
20
21 ######################################################################
22 # WCSLIB
23 -WCSVERSION = "4.8.2"
24 -WCSLIB = "wcslib" # Path to wcslib
25 -WCSLIB_PATCHED = "wcslib"
26 -WCSLIBC = join(WCSLIB_PATCHED, "C") # Path to wcslib source files
27 -WCSFILES = [ # List of wcslib files to compile
28 - 'flexed/wcsbth.c',
29 - 'flexed/wcspih.c',
30 - 'flexed/wcsulex.c',
31 - 'flexed/wcsutrn.c',
32 - 'cel.c',
33 - 'lin.c',
34 - 'log.c',
35 - 'prj.c',
36 - 'spc.c',
37 - 'sph.c',
38 - 'spx.c',
39 - 'tab.c',
40 - 'wcs.c',
41 - 'wcserr.c',
42 - 'wcsfix.c',
43 - 'wcshdr.c',
44 - 'wcsprintf.c',
45 - 'wcsunits.c',
46 - 'wcsutil.c']
47 -WCSFILES = [join(WCSLIBC, x) for x in WCSFILES]
48 +from subprocess import Popen, PIPE
49 +from re import match
50
51 -######################################################################
52 -# WCSLIB CONFIGURATION
53 -
54 -# The only configuration parameter needed at compile-time is how to
55 -# specify a 64-bit signed integer. Python's ctypes module can get us
56 -# that information, but it is only available in Python 2.5 or later.
57 -# If we can't be absolutely certain, we default to "long long int",
58 -# which is correct on most platforms (x86, x86_64). If we find
59 -# platforms where this heuristic doesn't work, we may need to hardcode
60 -# for them.
61 -def determine_64_bit_int():
62 - try:
63 - try:
64 - import ctypes
65 - except ImportError:
66 - raise ValueError()
67 -
68 - if ctypes.sizeof(ctypes.c_longlong) == 8:
69 - return "long long int"
70 - elif ctypes.sizeof(ctypes.c_long) == 8:
71 - return "long int"
72 - elif ctypes.sizeof(ctypes.c_int) == 8:
73 - return "int"
74 - else:
75 - raise ValueError()
76 -
77 - except ValueError:
78 - return "long long int"
79 +def pkgconfig(*packages, **kw):
80 + flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
81 + arg = "--libs --cflags --modversion %s" % ' '.join(packages)
82 + for tok in Popen(["pkg-config "+ arg],stdout=PIPE, shell=True).communicate()[0].split():
83 + token = tok.decode("utf-8")
84 + if(match("[0-9]",token)):
85 + kw.setdefault("version",[]).append(token)
86 + else:
87 + kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
88 + return kw
89
90 -h_file = StringIO()
91 -h_file.write("""
92 -/* WCSLIB library version number. */
93 -#define WCSLIB_VERSION %s
94 -
95 -/* 64-bit integer data type. */
96 -#define WCSLIB_INT64 %s
97 -""" % (WCSVERSION, determine_64_bit_int()))
98 -write_if_different(join(srcroot, 'src', 'wcsconfig.h'), h_file.getvalue())
99 +WCSLIB = pkgconfig('wcslib')
100 +WCSVERSION = WCSLIB['version'][0]
101
102 ######################################################################
103 # GENERATE DOCSTRINGS IN C
104 +
105 +######################################################################
106 docstrings = {}
107 with open(join(srcroot, 'doc', 'docstrings.py'), 'rb') as fd:
108 docstrings_content = fd.read()
109 @@ -233,7 +186,8 @@
110
111 ######################################################################
112 # DISTUTILS SETUP
113 -libraries = []
114 +libraries = WCSLIB['libraries']
115 +include_dirs = [numpy_include, join(srcroot, "src")] + WCSLIB['include_dirs']
116 define_macros = [('ECHO', None),
117 ('WCSTRIG_MACRO', None),
118 ('PYWCS_BUILD', None),
119 @@ -282,13 +236,8 @@
120
121 PYWCS_EXTENSIONS = [
122 Extension('pywcs._pywcs',
123 - WCSFILES + PYWCS_SOURCES,
124 - include_dirs =
125 - [numpy_include,
126 - join(srcroot, WCSLIBC),
127 - WCSLIBC,
128 - join(srcroot, "src")
129 - ],
130 + PYWCS_SOURCES,
131 + include_dirs=include_dirs,
132 define_macros=define_macros,
133 undef_macros=undef_macros,
134 extra_compile_args=extra_compile_args,
135 @@ -309,7 +258,6 @@
136 'ext_modules' : PYWCS_EXTENSIONS,
137 'data_files' : [
138 ( 'pywcs/include', ['src/*.h']),
139 - ( 'pywcs/include/wcslib', [ WCSLIBC + '/*.h'] ),
140 ( 'pywcs/tests/maps', ['lib/pywcs/tests/maps/*.hdr']),
141 ( 'pywcs/tests/spectra', ['lib/pywcs/tests/spectra/*.hdr']),
142 ( 'pywcs/tests/data', ['lib/pywcs/tests/data/*.hdr'])