Lines 56-66
Link Here
|
56 |
return None |
56 |
return None |
57 |
|
57 |
|
58 |
|
58 |
|
59 |
def _lib_include(root): |
|
|
60 |
# map root to (root/lib, root/include) |
61 |
return os.path.join(root, "lib"), os.path.join(root, "include") |
62 |
|
63 |
|
64 |
def _read(file): |
59 |
def _read(file): |
65 |
return open(file, 'rb').read() |
60 |
return open(file, 'rb').read() |
66 |
|
61 |
|
Lines 105-206
Link Here
|
105 |
_add_directory(include_dirs, include_root) |
100 |
_add_directory(include_dirs, include_root) |
106 |
|
101 |
|
107 |
# |
102 |
# |
108 |
# add platform directories |
|
|
109 |
|
110 |
if sys.platform == "cygwin": |
111 |
# pythonX.Y.dll.a is in the /usr/lib/pythonX.Y/config directory |
112 |
_add_directory(library_dirs, os.path.join( |
113 |
"/usr/lib", "python%s" % sys.version[:3], "config")) |
114 |
|
115 |
elif sys.platform == "darwin": |
116 |
# attempt to make sure we pick freetype2 over other versions |
117 |
_add_directory(include_dirs, "/sw/include/freetype2") |
118 |
_add_directory(include_dirs, "/sw/lib/freetype2/include") |
119 |
# fink installation directories |
120 |
_add_directory(library_dirs, "/sw/lib") |
121 |
_add_directory(include_dirs, "/sw/include") |
122 |
# darwin ports installation directories |
123 |
_add_directory(library_dirs, "/opt/local/lib") |
124 |
_add_directory(include_dirs, "/opt/local/include") |
125 |
# freetype2 ships with X11 |
126 |
_add_directory(library_dirs, "/usr/X11/lib") |
127 |
_add_directory(include_dirs, "/usr/X11/include") |
128 |
|
129 |
elif sys.platform.startswith("linux"): |
130 |
for platform_ in (platform.processor(),platform.architecture()[0]): |
131 |
if not platform_: continue |
132 |
|
133 |
if platform_ in ["x86_64", "64bit"]: |
134 |
_add_directory(library_dirs, "/lib64") |
135 |
_add_directory(library_dirs, "/usr/lib64") |
136 |
_add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu") |
137 |
break |
138 |
elif platform_ in ["i386", "i686", "32bit"]: |
139 |
_add_directory(library_dirs, "/usr/lib/i386-linux-gnu") |
140 |
break |
141 |
else: |
142 |
raise ValueError("Unable to identify Linux platform: `%s`" % platform_) |
143 |
|
144 |
# XXX Kludge. Above /\ we brute force support multiarch. Here we |
145 |
# try Barry's more general approach. Afterward, something should |
146 |
# work ;-) |
147 |
self.add_multiarch_paths() |
148 |
|
149 |
_add_directory(library_dirs, "/usr/local/lib") |
150 |
# FIXME: check /opt/stuff directories here? |
151 |
|
152 |
prefix = sysconfig.get_config_var("prefix") |
103 |
prefix = sysconfig.get_config_var("prefix") |
153 |
if prefix: |
104 |
if prefix: |
154 |
_add_directory(library_dirs, os.path.join(prefix, "lib")) |
105 |
_add_directory(library_dirs, os.path.join(prefix, "lib")) |
155 |
_add_directory(include_dirs, os.path.join(prefix, "include")) |
106 |
_add_directory(include_dirs, os.path.join(prefix, "include")) |
156 |
|
107 |
|
157 |
# |
|
|
158 |
# locate tkinter libraries |
108 |
# locate tkinter libraries |
159 |
|
109 |
|
160 |
|
110 |
|
161 |
if _tkinter: |
111 |
if _tkinter: |
162 |
TCL_VERSION = _tkinter.TCL_VERSION[:3] |
112 |
TCL_VERSION = _tkinter.TCL_VERSION[:3] |
163 |
|
113 |
|
164 |
if _tkinter and not TCL_ROOT: |
|
|
165 |
# we have Tkinter but the TCL_ROOT variable was not set; |
166 |
# try to locate appropriate Tcl/Tk libraries |
167 |
PYVERSION = sys.version[0] + sys.version[2] |
168 |
TCLVERSION = TCL_VERSION[0] + TCL_VERSION[2] |
169 |
roots = [ |
170 |
# common installation directories, mostly for Windows |
171 |
# (for Unix-style platforms, we'll check in well-known |
172 |
# locations later) |
173 |
os.path.join("/py" + PYVERSION, "Tcl"), |
174 |
os.path.join("/python" + PYVERSION, "Tcl"), |
175 |
"/Tcl", "/Tcl" + TCLVERSION, "/Tcl" + TCL_VERSION, |
176 |
os.path.join(os.environ.get("ProgramFiles", ""), "Tcl"), |
177 |
] |
178 |
for TCL_ROOT in roots: |
179 |
TCL_ROOT = os.path.abspath(TCL_ROOT) |
180 |
if os.path.isfile(os.path.join(TCL_ROOT, "include", "tk.h")): |
181 |
# FIXME: use distutils logging (?) |
182 |
print("--- using Tcl/Tk libraries at", TCL_ROOT) |
183 |
print("--- using Tcl/Tk version", TCL_VERSION) |
184 |
TCL_ROOT = _lib_include(TCL_ROOT) |
185 |
break |
186 |
else: |
187 |
TCL_ROOT = None |
188 |
|
189 |
|
114 |
|
190 |
# |
115 |
# |
191 |
# add standard directories |
116 |
# add standard directories |
192 |
|
117 |
|
193 |
# look for tcl specific subdirectory (e.g debian) |
|
|
194 |
if _tkinter: |
195 |
tcl_dir = "/usr/include/tcl" + TCL_VERSION |
196 |
if os.path.isfile(os.path.join(tcl_dir, "tk.h")): |
197 |
_add_directory(include_dirs, tcl_dir) |
198 |
|
199 |
# standard locations |
118 |
# standard locations |
200 |
_add_directory(library_dirs, "/usr/local/lib") |
|
|
201 |
_add_directory(include_dirs, "/usr/local/include") |
202 |
|
203 |
_add_directory(library_dirs, "/usr/lib") |
204 |
_add_directory(include_dirs, "/usr/include") |
119 |
_add_directory(include_dirs, "/usr/include") |
205 |
|
120 |
|
206 |
# |
121 |
# |
Lines 333-360
Link Here
|
333 |
"_webp", ["_webp.c"], libraries=["webp"])) |
248 |
"_webp", ["_webp.c"], libraries=["webp"])) |
334 |
|
249 |
|
335 |
|
250 |
|
336 |
if sys.platform == "darwin": |
251 |
if feature.tcl and feature.tk: |
337 |
# locate Tcl/Tk frameworks |
|
|
338 |
frameworks = [] |
339 |
framework_roots = [ |
340 |
"/Library/Frameworks", |
341 |
"/System/Library/Frameworks"] |
342 |
for root in framework_roots: |
343 |
if (os.path.exists(os.path.join(root, "Tcl.framework")) and |
344 |
os.path.exists(os.path.join(root, "Tk.framework"))): |
345 |
print("--- using frameworks at %s" % root) |
346 |
frameworks = ["-framework", "Tcl", "-framework", "Tk"] |
347 |
dir = os.path.join(root, "Tcl.framework", "Headers") |
348 |
_add_directory(self.compiler.include_dirs, dir, 0) |
349 |
dir = os.path.join(root, "Tk.framework", "Headers") |
350 |
_add_directory(self.compiler.include_dirs, dir, 1) |
351 |
break |
352 |
if frameworks: |
353 |
exts.append(Extension( |
354 |
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], |
355 |
extra_compile_args=frameworks, extra_link_args=frameworks)) |
356 |
feature.tcl = feature.tk = 1 # mark as present |
357 |
elif feature.tcl and feature.tk: |
358 |
exts.append(Extension( |
252 |
exts.append(Extension( |
359 |
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], |
253 |
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], |
360 |
libraries=[feature.tcl, feature.tk])) |
254 |
libraries=[feature.tcl, feature.tk])) |
Lines 445-474
Link Here
|
445 |
if m.group(1) < "1.2.3": |
339 |
if m.group(1) < "1.2.3": |
446 |
return m.group(1) |
340 |
return m.group(1) |
447 |
|
341 |
|
448 |
# http://hg.python.org/users/barry/rev/7e8deab93d5a |
|
|
449 |
def add_multiarch_paths(self): |
450 |
# Debian/Ubuntu multiarch support. |
451 |
# https://wiki.ubuntu.com/MultiarchSpec |
452 |
# self.build_temp |
453 |
tmpfile = os.path.join(self.build_temp, 'multiarch') |
454 |
if not os.path.exists(self.build_temp): |
455 |
os.makedirs(self.build_temp) |
456 |
ret = os.system('dpkg-architecture -qDEB_HOST_MULTIARCH > %s' % |
457 |
tmpfile) |
458 |
ret = os.system( |
459 |
'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' % |
460 |
tmpfile) |
461 |
try: |
462 |
if ret >> 8 == 0: |
463 |
fp = open(tmpfile, 'r') |
464 |
multiarch_path_component = fp.readline().strip() |
465 |
_add_directory(self.compiler.library_dirs, |
466 |
'/usr/lib/' + multiarch_path_component) |
467 |
_add_directory(self.compiler.include_dirs, |
468 |
'/usr/include/' + multiarch_path_component) |
469 |
finally: |
470 |
os.unlink(tmpfile) |
471 |
|
472 |
setup( |
342 |
setup( |
473 |
name=NAME, |
343 |
name=NAME, |
474 |
version=VERSION, |
344 |
version=VERSION, |