Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f7082d1

Browse files
committed
Fix some win32 differences
svn path=/trunk/matplotlib/; revision=3660
1 parent 7cc50d2 commit f7082d1

1 file changed

Lines changed: 33 additions & 5 deletions

File tree

setupext.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ def add_gd_flags(module):
358358
def add_ft2font_flags(module):
359359
'Add the module flags to ft2font extension'
360360
if not get_pkgconfig(module, 'freetype2'):
361-
module.libraries.append('freetype')
361+
module.libraries.extend(['freetype', 'z'])
362+
add_base_flags(module)
362363

363364
basedirs = module.include_dirs[:] # copy the list to avoid inf loop!
364365
for d in basedirs:
@@ -372,9 +373,8 @@ def add_ft2font_flags(module):
372373
for d in basedirs:
373374
p = os.path.join(d, 'freetype2/lib')
374375
if os.path.exists(p): module.library_dirs.append(p)
375-
376-
module.libraries.append('z')
377-
add_base_flags(module)
376+
else:
377+
add_base_flags(module)
378378

379379
if sys.platform == 'win32' and win32_compiler == 'mingw32':
380380
module.libraries.append('gw32c')
@@ -451,10 +451,38 @@ def add_pygtk_flags(module):
451451
'C:/GTK/include/gtk',
452452
])
453453

454-
add_base_flags(module)
454+
add_base_flags(module)
455+
456+
if not os.environ.has_key('PKG_CONFIG_PATH'):
457+
# If Gtk+ is installed, pkg-config is required to be installed
458+
os.environ['PKG_CONFIG_PATH'] = 'C:\GTK\lib\pkgconfig'
459+
460+
pygtkIncludes = getoutput('pkg-config --cflags-only-I pygtk-2.0').split()
461+
gtkIncludes = getoutput('pkg-config --cflags-only-I gtk+-2.0').split()
462+
includes = pygtkIncludes + gtkIncludes
463+
module.include_dirs.extend([include[2:] for include in includes])
464+
465+
pygtkLinker = getoutput('pkg-config --libs pygtk-2.0').split()
466+
gtkLinker = getoutput('pkg-config --libs gtk+-2.0').split()
467+
linkerFlags = pygtkLinker + gtkLinker
468+
469+
module.libraries.extend(
470+
[flag[2:] for flag in linkerFlags if flag.startswith('-l')])
471+
472+
module.library_dirs.extend(
473+
[flag[2:] for flag in linkerFlags if flag.startswith('-L')])
474+
475+
module.extra_link_args.extend(
476+
[flag for flag in linkerFlags if not
477+
(flag.startswith('-l') or flag.startswith('-L'))])
478+
479+
# visual studio doesn't need the math library
480+
if sys.platform == 'win32' and win32_compiler == 'msvc' and 'm' in module.libraries:
481+
module.libraries.remove('m')
455482

456483
if sys.platform != 'win32':
457484
# If Gtk+ is installed, pkg-config is required to be installed
485+
add_base_flags(module)
458486
get_pkgconfig(module, 'pygtk-2.0 gtk+-2.0')
459487

460488
# visual studio doesn't need the math library

0 commit comments

Comments
 (0)