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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
--- setup.py
+++ setup.py
@@ -56,11 +56,6 @@
return None
-def _lib_include(root):
- # map root to (root/lib, root/include)
- return os.path.join(root, "lib"), os.path.join(root, "include")
-
-
def _read(file):
return open(file, 'rb').read()
@@ -105,102 +100,17 @@
_add_directory(include_dirs, include_root)
#
- # add platform directories
-
- if sys.platform == "cygwin":
- # pythonX.Y.dll.a is in the /usr/lib/pythonX.Y/config directory
- _add_directory(library_dirs, os.path.join(
- "/usr/lib", "python%s" % sys.version[:3], "config"))
-
- elif sys.platform == "darwin":
- # attempt to make sure we pick freetype2 over other versions
- _add_directory(include_dirs, "/sw/include/freetype2")
- _add_directory(include_dirs, "/sw/lib/freetype2/include")
- # fink installation directories
- _add_directory(library_dirs, "/sw/lib")
- _add_directory(include_dirs, "/sw/include")
- # darwin ports installation directories
- _add_directory(library_dirs, "/opt/local/lib")
- _add_directory(include_dirs, "/opt/local/include")
- # freetype2 ships with X11
- _add_directory(library_dirs, "/usr/X11/lib")
- _add_directory(include_dirs, "/usr/X11/include")
-
- elif sys.platform.startswith("linux"):
- for platform_ in (platform.processor(),platform.architecture()[0]):
- if not platform_: continue
-
- if platform_ in ["x86_64", "64bit"]:
- _add_directory(library_dirs, "/lib64")
- _add_directory(library_dirs, "/usr/lib64")
- _add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu")
- break
- elif platform_ in ["i386", "i686", "32bit"]:
- _add_directory(library_dirs, "/usr/lib/i386-linux-gnu")
- break
- else:
- raise ValueError("Unable to identify Linux platform: `%s`" % platform_)
-
- # XXX Kludge. Above /\ we brute force support multiarch. Here we
- # try Barry's more general approach. Afterward, something should
- # work ;-)
- self.add_multiarch_paths()
-
- _add_directory(library_dirs, "/usr/local/lib")
- # FIXME: check /opt/stuff directories here?
-
- prefix = sysconfig.get_config_var("prefix")
- if prefix:
- _add_directory(library_dirs, os.path.join(prefix, "lib"))
- _add_directory(include_dirs, os.path.join(prefix, "include"))
-
- #
# locate tkinter libraries
if _tkinter:
TCL_VERSION = _tkinter.TCL_VERSION[:3]
- if _tkinter and not TCL_ROOT:
- # we have Tkinter but the TCL_ROOT variable was not set;
- # try to locate appropriate Tcl/Tk libraries
- PYVERSION = sys.version[0] + sys.version[2]
- TCLVERSION = TCL_VERSION[0] + TCL_VERSION[2]
- roots = [
- # common installation directories, mostly for Windows
- # (for Unix-style platforms, we'll check in well-known
- # locations later)
- os.path.join("/py" + PYVERSION, "Tcl"),
- os.path.join("/python" + PYVERSION, "Tcl"),
- "/Tcl", "/Tcl" + TCLVERSION, "/Tcl" + TCL_VERSION,
- os.path.join(os.environ.get("ProgramFiles", ""), "Tcl"),
- ]
- for TCL_ROOT in roots:
- TCL_ROOT = os.path.abspath(TCL_ROOT)
- if os.path.isfile(os.path.join(TCL_ROOT, "include", "tk.h")):
- # FIXME: use distutils logging (?)
- print("--- using Tcl/Tk libraries at", TCL_ROOT)
- print("--- using Tcl/Tk version", TCL_VERSION)
- TCL_ROOT = _lib_include(TCL_ROOT)
- break
- else:
- TCL_ROOT = None
-
#
# add standard directories
- # look for tcl specific subdirectory (e.g debian)
- if _tkinter:
- tcl_dir = "/usr/include/tcl" + TCL_VERSION
- if os.path.isfile(os.path.join(tcl_dir, "tk.h")):
- _add_directory(include_dirs, tcl_dir)
-
# standard locations
- _add_directory(library_dirs, "/usr/local/lib")
- _add_directory(include_dirs, "/usr/local/include")
-
- _add_directory(library_dirs, "/usr/lib")
_add_directory(include_dirs, "/usr/include")
#
@@ -333,28 +243,7 @@
"_webp", ["_webp.c"], libraries=["webp"]))
- if sys.platform == "darwin":
- # locate Tcl/Tk frameworks
- frameworks = []
- framework_roots = [
- "/Library/Frameworks",
- "/System/Library/Frameworks"]
- for root in framework_roots:
- if (os.path.exists(os.path.join(root, "Tcl.framework")) and
- os.path.exists(os.path.join(root, "Tk.framework"))):
- print("--- using frameworks at %s" % root)
- frameworks = ["-framework", "Tcl", "-framework", "Tk"]
- dir = os.path.join(root, "Tcl.framework", "Headers")
- _add_directory(self.compiler.include_dirs, dir, 0)
- dir = os.path.join(root, "Tk.framework", "Headers")
- _add_directory(self.compiler.include_dirs, dir, 1)
- break
- if frameworks:
- exts.append(Extension(
- "_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
- extra_compile_args=frameworks, extra_link_args=frameworks))
- feature.tcl = feature.tk = 1 # mark as present
- elif feature.tcl and feature.tk:
+ if feature.tcl and feature.tk:
exts.append(Extension(
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
libraries=[feature.tcl, feature.tk]))
@@ -445,30 +334,6 @@
if m.group(1) < "1.2.3":
return m.group(1)
- # http://hg.python.org/users/barry/rev/7e8deab93d5a
- def add_multiarch_paths(self):
- # Debian/Ubuntu multiarch support.
- # https://wiki.ubuntu.com/MultiarchSpec
- # self.build_temp
- tmpfile = os.path.join(self.build_temp, 'multiarch')
- if not os.path.exists(self.build_temp):
- os.makedirs(self.build_temp)
- ret = os.system('dpkg-architecture -qDEB_HOST_MULTIARCH > %s' %
- tmpfile)
- ret = os.system(
- 'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
- tmpfile)
- try:
- if ret >> 8 == 0:
- fp = open(tmpfile, 'r')
- multiarch_path_component = fp.readline().strip()
- _add_directory(self.compiler.library_dirs,
- '/usr/lib/' + multiarch_path_component)
- _add_directory(self.compiler.include_dirs,
- '/usr/include/' + multiarch_path_component)
- finally:
- os.unlink(tmpfile)
-
setup(
name=NAME,
version=VERSION,
|