From afc84c41aaed5e244b7bfb8d049ec7d2f83c727b Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 14 Mar 2013 01:16:32 +0000 Subject: [PATCH] Additional tweaks for magic on Linux: In the bdist_egg build, if one of the libwx* symlinks is actually the soname then we need to keep that one as the real file instead of removing it. No need to do a wx install if we're using magic. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73661 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build.py | 22 ++++++++++++++-------- buildtools/config.py | 16 ++++++++++++++++ setup.py | 34 +++++++++++++++++++++++++++------- wscript | 2 +- 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/build.py b/build.py index 31518fb3..1800460c 100755 --- a/build.py +++ b/build.py @@ -1168,17 +1168,23 @@ def cmd_install(options, args): def cmd_install_wx(options, args): cmdTimer = CommandTimer('install_wx') - if not isWindows and options.use_syswx: + if isWindows: + msg('No wxWidgets installation required on Windows') + return + + if options.use_syswx: msg("use_syswx option specified, skipping wxWidgets install") return - # On Windows the DLLs are always copied to the wxPython package, and so there - # is no installing needed - if not isWindows: - BUILD_DIR = getBuildDir(options) - DESTDIR = '' if not options.destdir else 'DESTDIR=' + options.destdir - pwd = pushDir(BUILD_DIR) - runcmd("make install %s %s" % (DESTDIR, options.extra_make)) + if not options.no_magic: + msg('Magic is in use, wxWidgets will be installed with wxPython') + return + + # Otherwise, run 'make install' in the wx build folder + BUILD_DIR = getBuildDir(options) + DESTDIR = '' if not options.destdir else 'DESTDIR=' + options.destdir + pwd = pushDir(BUILD_DIR) + runcmd("make install %s %s" % (DESTDIR, options.extra_make)) diff --git a/buildtools/config.py b/buildtools/config.py index ba43092d..d108a4be 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -15,6 +15,7 @@ import sys import os import glob import fnmatch +import re import tempfile import shutil import codecs @@ -851,3 +852,18 @@ def getVisCVersion(): else: return 'FIXME' + +_haveObjDump = None +def canGetSOName(): + global _haveObjDump + if _haveObjDump is None: + _haveObjDump = findCmd('objdump') is not None + return _haveObjDump + + +def getSOName(filename): + output = runcmd('objdump -p %s' % filename, True) + result = re.search('^\s+SONAME\s+(.+)$', output, re.MULTILINE) + if result: + return result.group(1) + return None \ No newline at end of file diff --git a/setup.py b/setup.py index 3c40dded..263a3016 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ from setuptools.command.install import install as orig_install from setuptools.command.bdist_egg import bdist_egg as orig_bdist_egg from setuptools.command.build_py import build_py as orig_build_py -from buildtools.config import Config, msg, opj, runcmd +from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName #---------------------------------------------------------------------- @@ -61,6 +61,10 @@ Programming Language :: Python Topic :: Software Development :: User Interfaces """ + +isWindows = sys.platform.startswith('win') +isDarwin = sys.platform == "darwin" + #---------------------------------------------------------------------- # Classes used in place of some distutils/setuptools classes. @@ -113,17 +117,33 @@ class wx_bdist_egg(orig_bdist_egg): # TODO: can eggs have post-install scripts that would allow us to # restore the links? # - #builddir = opj('build', 'lib.%s-%s' % (self.plat_name, sys.version[:3]), 'wx') build_lib = self.get_finalized_command('build').build_lib build_lib = opj(build_lib, 'wx') for libname in glob.glob(opj(build_lib, 'libwx*')): - # TODO: This should check which lib is the actual soname referred - # to from the extension modules and delete the others. It may not - # actually be the one that is not a link... - if os.path.islink(libname): - os.unlink(libname) + if isDarwin: + # On Mac the name used by the extension module is the real + # file, so we can just get rid of all the links. + os.unlink(libname) + + elif canGetSOName(): + # On linux the soname used in the extension modules may + # be (probably is) one of the symlinks, so we have to be + # more tricky here. If the named file is a link and it is + # the soname, then remove the link and rename the + # linked-to file to this name. + soname = getSOName(libname) + if soname == os.path.basename(libname): + realfile = os.path.join(build_lib, os.readlink(libname)) + os.unlink(libname) + os.rename(realfile, libname) + else: + os.unlink(libname) + else: + # Otherwise just leave the symlink there since we don't + # know what to do with it. + pass # Run the default bdist_egg command orig_bdist_egg.run(self) diff --git a/wscript b/wscript index d6dc6023..64005704 100644 --- a/wscript +++ b/wscript @@ -152,7 +152,7 @@ def configure(conf): cfg.finishSetup(conf.env.wx_config, conf.env.debug) # Check wx-config exists and fetch some values from it - rpath = ' --no-rpath' if not cmd.options.no_magic else '' + rpath = ' --no-rpath' if not conf.options.no_magic else '' conf.check_cfg(path=conf.options.wx_config, package='', args='--cxxflags --libs core,net' + rpath, uselib_store='WX', mandatory=True)