aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST.in1
-rw-r--r--README.rst7
-rw-r--r--docs/building/linux.rst12
-rw-r--r--docs/building/macosx.rst13
-rw-r--r--docs/index.rst2
-rw-r--r--docs/installing/macosx.rst6
-rw-r--r--pyside_postinstall.py192
-rw-r--r--setup.py40
-rw-r--r--utils.py138
9 files changed, 146 insertions, 265 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
index 5c207c84d..6af7c8e4f 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -8,7 +8,6 @@ include CHANGES.rst
include README.rst
include ez_setup.py
include setup.py
-include pyside_postinstall.py
include popenasync.py
include qtinfo.py
include utils.py
diff --git a/README.rst b/README.rst
index 84a4bed1d..809354c7f 100644
--- a/README.rst
+++ b/README.rst
@@ -101,13 +101,6 @@ To install PySide on Mac OS X you can choose from the following options:
$ pip install -U PySide
-After the installation, the following call must be made manually:
-
-::
-
- $ pyside_postinstall.py -install
-
-
Installing PySide on a Linux System
-----------------------------------
diff --git a/docs/building/linux.rst b/docs/building/linux.rst
index 283579507..84166c244 100644
--- a/docs/building/linux.rst
+++ b/docs/building/linux.rst
@@ -109,12 +109,6 @@ Installing PySide distribution
PySide-1.2.2-cp27-none-linux-x86_64.whl
$ sudo pip2.7 install dist/PySide-1.2.2-cp27-none-linux-x86_64.whl
-#. Run the post-install script to finish the package configuration:
-
- ::
-
- $ sudo python2.7 pyside_postinstall.py -install
-
Installing PySide distribution into ``virtual`` Python environment
------------------------------------------------------------------
@@ -142,9 +136,3 @@ Installing PySide distribution into ``virtual`` Python environment
::
$ bin/pip2.7 install ../dist/PySide-1.2.2-cp27-none-linux-x86_64.whl
-
-#. Run the post-install script to finish the package configuration:
-
- ::
-
- $ bin/python bin/pyside_postinstall.py -install
diff --git a/docs/building/macosx.rst b/docs/building/macosx.rst
index e6ac00423..807b47b32 100644
--- a/docs/building/macosx.rst
+++ b/docs/building/macosx.rst
@@ -12,6 +12,7 @@ The supported Mac OS X versions created by `Apple <http://www.apple.com/>`_ are
- OS X 10.7 *Lion*
- OS X 10.8 *Mountain Lion*
- OS X 10.9 *Mavericks*
+- OS X 10.10 *Yosemite*
Mac OS X is a proprietary UNIX flavor of BSD Unix and only partially similar to
Linux. Therefore, the usual packages from Linux distributions cannot be used
@@ -226,12 +227,6 @@ Installing PySide distribution
$ sudo pip2.7 install dist/PySide-1.2.2-cp27-none-linux-x86_64.whl
-#. Run the post-install script to finish the package configuration:
-
- ::
-
- $ sudo python2.7 pyside_postinstall.py -install
-
Installing PySide distribution into ``virtual`` Python environment
------------------------------------------------------------------
@@ -260,12 +255,6 @@ Installing PySide distribution into ``virtual`` Python environment
(env) $ pip install ../dist/PySide-1.2.2-cp27-none-linux-x86_64.whl
-#. Run the post-install script to finish the package configuration:
-
- ::
-
- (env) $ pyside_postinstall.py -install
-
#. Leave the virtual environment (optional):
::
diff --git a/docs/index.rst b/docs/index.rst
index ac889c273..b918c6038 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -46,7 +46,7 @@ PySide requires Python 2.6 or later and Qt 4.6 or better.
.. note::
- Qt 5.x is currently not supported.
+ Qt 5.x is currently under construction.
Contents
diff --git a/docs/installing/macosx.rst b/docs/installing/macosx.rst
index 4e44e995f..214d52f9b 100644
--- a/docs/installing/macosx.rst
+++ b/docs/installing/macosx.rst
@@ -30,9 +30,3 @@ To install PySide on Mac OS X you can choose from the following options:
$ pip install -U PySide
-
-After the installation, the following call must be made manually:
-
-::
-
- $ pyside_postinstall.py -install
diff --git a/pyside_postinstall.py b/pyside_postinstall.py
deleted file mode 100644
index 125fbd3fb..000000000
--- a/pyside_postinstall.py
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/usr/bin/env python
-# Postinstall script for PySide
-#
-# TODO:
-# This file can be removed after OSX support
-# is implemented in pyside_build.update_rpath()
-
-import os, sys, traceback, shutil, fnmatch, stat
-from os.path import dirname, abspath
-from subprocess import Popen, PIPE
-import re
-
-
-def filter_match(name, patterns):
- for pattern in patterns:
- if pattern is None:
- continue
- if fnmatch.fnmatch(name, pattern):
- return True
- return False
-
-
-def back_tick(cmd, ret_err=False):
- """ Run command `cmd`, return stdout, or stdout, stderr if `ret_err`
-
- Roughly equivalent to ``check_output`` in Python 2.7
-
- Parameters
- ----------
- cmd : str
- command to execute
- ret_err : bool, optional
- If True, return stderr in addition to stdout. If False, just return
- stdout
-
- Returns
- -------
- out : str or tuple
- If `ret_err` is False, return stripped string containing stdout from
- `cmd`. If `ret_err` is True, return tuple of (stdout, stderr) where
- ``stdout`` is the stripped stdout, and ``stderr`` is the stripped
- stderr.
-
- Raises
- ------
- Raises RuntimeError if command returns non-zero exit code
- """
- proc = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
- out, err = proc.communicate()
- if not isinstance(out, str):
- # python 3
- out = out.decode()
- err = err.decode()
- retcode = proc.returncode
- if retcode is None:
- proc.terminate()
- raise RuntimeError(cmd + ' process did not terminate')
- if retcode != 0:
- raise RuntimeError(cmd + ' process returned code %d\n*** %s' %
- (retcode, err))
- out = out.strip()
- if not ret_err:
- return out
- return out, err.strip()
-
-
-OSX_OUTNAME_RE = re.compile(r'\(compatibility version [\d.]+, current version '
- '[\d.]+\)')
-
-def osx_get_install_names(libpath):
- """ Get OSX library install names from library `libpath` using ``otool``
-
- Parameters
- ----------
- libpath : str
- path to library
-
- Returns
- -------
- install_names : list of str
- install names in library `libpath`
- """
- out = back_tick('otool -L ' + libpath)
- libs = [line for line in out.split('\n')][1:]
- return [OSX_OUTNAME_RE.sub('', lib).strip() for lib in libs]
-
-
-OSX_RPATH_RE = re.compile(r"path (.+) \(offset \d+\)")
-
-def osx_get_rpaths(libpath):
- """ Get rpaths from library `libpath` using ``otool``
-
- Parameters
- ----------
- libpath : str
- path to library
-
- Returns
- -------
- rpaths : list of str
- rpath values stored in ``libpath``
-
- Notes
- -----
- See ``man dyld`` for more information on rpaths in libraries
- """
- lines = back_tick('otool -l ' + libpath).split('\n')
- ctr = 0
- rpaths = []
- while ctr < len(lines):
- line = lines[ctr].strip()
- if line != 'cmd LC_RPATH':
- ctr += 1
- continue
- assert lines[ctr + 1].strip().startswith('cmdsize')
- rpath_line = lines[ctr + 2].strip()
- match = OSX_RPATH_RE.match(rpath_line)
- if match is None:
- raise RuntimeError('Unexpected path line: ' + rpath_line)
- rpaths.append(match.groups()[0])
- ctr += 3
- return rpaths
-
-
-def osx_localize_libpaths(libpath, local_libs, enc_path=None):
- """ Set rpaths and install names to load local dynamic libs at run time
-
- Use ``install_name_tool`` to set relative install names in `libpath` (as
- named in `local_libs` to be relative to `enc_path`. The default for
- `enc_path` is the directory containing `libpath`.
-
- Parameters
- ----------
- libpath : str
- path to library for which to set install names and rpaths
- local_libs : sequence of str
- library (install) names that should be considered relative paths
- enc_path : str, optional
- path that does or will contain the `libpath` library, and to which the
- `local_libs` are relative. Defaults to current directory containing
- `libpath`.
- """
- if enc_path is None:
- enc_path = abspath(dirname(libpath))
- install_names = osx_get_install_names(libpath)
- need_rpath = False
- for install_name in install_names:
- if install_name[0] in '/@':
- continue
- back_tick('install_name_tool -change %s @rpath/%s %s' %
- (install_name, install_name, libpath))
- need_rpath = True
- if need_rpath and enc_path not in osx_get_rpaths(libpath):
- back_tick('install_name_tool -add_rpath %s %s' %
- (enc_path, libpath))
-
-
-def post_install_osx():
- # Try to find PySide package
- try:
- import PySide
- except ImportError:
- print("The PySide package not found: %s" % traceback.print_exception(*sys.exc_info()))
- return
- pyside_path = os.path.abspath(os.path.dirname(PySide.__file__))
- print("PySide package found in %s..." % pyside_path)
-
- pyside_libs = [lib for lib in os.listdir(pyside_path) if filter_match(
- lib, ["*.so", "*.dylib", "shiboken"])]
-
- # Update rpath in PySide libs
- for srcname in pyside_libs:
- srcpath = os.path.join(pyside_path, srcname)
- if os.path.isdir(srcpath):
- continue
- if not os.path.exists(srcpath):
- continue
- osx_localize_libpaths(srcpath, pyside_libs, pyside_path)
- print("Patched rpath in %s to %s." % (srcpath, pyside_path))
-
- # Check PySide installation status
- try:
- from PySide import QtCore
- print("PySide package successfully installed in %s..." % \
- os.path.abspath(os.path.dirname(QtCore.__file__)))
- except ImportError:
- print("The PySide package not installed: %s" % traceback.print_exception(*sys.exc_info()))
-
-
-if __name__ == '__main__':
- if sys.platform == "darwin":
- post_install_osx()
diff --git a/setup.py b/setup.py
index 1e3496b5e..27ea30eeb 100644
--- a/setup.py
+++ b/setup.py
@@ -111,6 +111,7 @@ from utils import update_env_path
from utils import init_msvc_env
from utils import regenerate_qt_resources
from utils import filter_match
+from utils import osx_localize_libpaths
# Declare options
OPTION_DEBUG = has_option("debug")
@@ -242,28 +243,6 @@ for pkg in ["pyside_package/PySide", "pyside_package/pysideuic"]:
pkg_dir = os.path.join(script_dir, pkg)
os.makedirs(pkg_dir)
-# TODO:
-# This class can be removed after OSX support
-# is implemented in pyside_build.update_rpath()
-class pyside_install(_install):
- def run(self):
- _install.run(self)
- # Custom script we run at the end of installing
- # If self.root has a value, it means we are being "installed" into
- # some other directory than Python itself (eg, into a temp directory
- # for bdist_wininst to use) - in which case we must *not* run our
- # installer
- if not self.dry_run and not self.root:
- filename = os.path.join(self.install_scripts, "pyside_postinstall.py")
- if not os.path.isfile(filename):
- raise RuntimeError("Can't find '%s'" % (filename,))
- print("Executing post install script '%s'..." % filename)
- cmd = [
- os.path.abspath(sys.executable),
- filename,
- ]
- run_process(cmd)
-
class pyside_develop(_develop):
def __init__(self, *args, **kwargs):
@@ -784,7 +763,7 @@ class pyside_build(_build):
filter=["*.qm"],
vars=vars)
# Update rpath to $ORIGIN
- if sys.platform.startswith('linux'):
+ if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
self.update_rpath("{dist_dir}/PySide".format(**vars), executables)
def prepare_packages_win32(self, vars):
@@ -952,12 +931,11 @@ class pyside_build(_build):
if run_process(cmd) != 0:
raise RuntimeError("Error patching rpath in " + srcpath)
- # TODO: Add support for OSX platform
- #elif sys.platform == 'darwin':
- # pyside_libs = [lib for lib in os.listdir(package_path) if filter_match(
- # lib, ["*.so", "*.dylib"])]
- # def rpath_cmd(srcpath):
- # utils.osx_localize_libpaths(srcpath, pyside_libs, None)
+ elif sys.platform == 'darwin':
+ pyside_libs = [lib for lib in os.listdir(package_path) if filter_match(
+ lib, ["*.so", "*.dylib"])]
+ def rpath_cmd(srcpath):
+ osx_localize_libpaths(srcpath, pyside_libs, None)
else:
raise RuntimeError('Not configured for platform ' +
@@ -990,9 +968,6 @@ setup(
version = __version__,
description = ("Python bindings for the Qt cross-platform application and UI framework"),
long_description = README + "\n\n" + CHANGES,
- scripts = [
- "pyside_postinstall.py"
- ],
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
@@ -1042,7 +1017,6 @@ setup(
'build_ext': pyside_build_ext,
'bdist_egg': pyside_bdist_egg,
'develop': pyside_develop,
- 'install': pyside_install,
},
# Add a bogus extension module (will never be built here since we are
diff --git a/utils.py b/utils.py
index 7b40bb2ac..a1634a139 100644
--- a/utils.py
+++ b/utils.py
@@ -1,5 +1,6 @@
import sys
import os
+import re
import stat
import errno
import time
@@ -233,7 +234,7 @@ def copyfile(src, dst, force=True, vars=None):
log.info("Copying file %s to %s." % (src, dst))
shutil.copy2(src, dst)
-
+
return dst
@@ -450,3 +451,138 @@ def regenerate_qt_resources(src, pyside_rcc_path, pyside_rcc_options):
run_process([pyside_rcc_path,
pyside_rcc_options,
srcname, '-o', dstname])
+
+
+def back_tick(cmd, ret_err=False):
+ """ Run command `cmd`, return stdout, or stdout, stderr if `ret_err`
+
+ Roughly equivalent to ``check_output`` in Python 2.7
+
+ Parameters
+ ----------
+ cmd : str
+ command to execute
+ ret_err : bool, optional
+ If True, return stderr in addition to stdout. If False, just return
+ stdout
+
+ Returns
+ -------
+ out : str or tuple
+ If `ret_err` is False, return stripped string containing stdout from
+ `cmd`. If `ret_err` is True, return tuple of (stdout, stderr) where
+ ``stdout`` is the stripped stdout, and ``stderr`` is the stripped
+ stderr.
+
+ Raises
+ ------
+ Raises RuntimeError if command returns non-zero exit code
+ """
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ out, err = proc.communicate()
+ if not isinstance(out, str):
+ # python 3
+ out = out.decode()
+ err = err.decode()
+ retcode = proc.returncode
+ if retcode is None:
+ proc.terminate()
+ raise RuntimeError(cmd + ' process did not terminate')
+ if retcode != 0:
+ raise RuntimeError(cmd + ' process returned code %d\n*** %s' %
+ (retcode, err))
+ out = out.strip()
+ if not ret_err:
+ return out
+ return out, err.strip()
+
+
+OSX_OUTNAME_RE = re.compile(r'\(compatibility version [\d.]+, current version '
+ '[\d.]+\)')
+
+def osx_get_install_names(libpath):
+ """ Get OSX library install names from library `libpath` using ``otool``
+
+ Parameters
+ ----------
+ libpath : str
+ path to library
+
+ Returns
+ -------
+ install_names : list of str
+ install names in library `libpath`
+ """
+ out = back_tick('otool -L ' + libpath)
+ libs = [line for line in out.split('\n')][1:]
+ return [OSX_OUTNAME_RE.sub('', lib).strip() for lib in libs]
+
+
+OSX_RPATH_RE = re.compile(r"path (.+) \(offset \d+\)")
+
+def osx_get_rpaths(libpath):
+ """ Get rpaths from library `libpath` using ``otool``
+
+ Parameters
+ ----------
+ libpath : str
+ path to library
+
+ Returns
+ -------
+ rpaths : list of str
+ rpath values stored in ``libpath``
+
+ Notes
+ -----
+ See ``man dyld`` for more information on rpaths in libraries
+ """
+ lines = back_tick('otool -l ' + libpath).split('\n')
+ ctr = 0
+ rpaths = []
+ while ctr < len(lines):
+ line = lines[ctr].strip()
+ if line != 'cmd LC_RPATH':
+ ctr += 1
+ continue
+ assert lines[ctr + 1].strip().startswith('cmdsize')
+ rpath_line = lines[ctr + 2].strip()
+ match = OSX_RPATH_RE.match(rpath_line)
+ if match is None:
+ raise RuntimeError('Unexpected path line: ' + rpath_line)
+ rpaths.append(match.groups()[0])
+ ctr += 3
+ return rpaths
+
+
+def osx_localize_libpaths(libpath, local_libs, enc_path=None):
+ """ Set rpaths and install names to load local dynamic libs at run time
+
+ Use ``install_name_tool`` to set relative install names in `libpath` (as
+ named in `local_libs` to be relative to `enc_path`. The default for
+ `enc_path` is the directory containing `libpath`.
+
+ Parameters
+ ----------
+ libpath : str
+ path to library for which to set install names and rpaths
+ local_libs : sequence of str
+ library (install) names that should be considered relative paths
+ enc_path : str, optional
+ path that does or will contain the `libpath` library, and to which the
+ `local_libs` are relative. Defaults to current directory containing
+ `libpath`.
+ """
+ if enc_path is None:
+ enc_path = os.path.abspath(os.path.dirname(libpath))
+ install_names = osx_get_install_names(libpath)
+ need_rpath = False
+ for install_name in install_names:
+ if install_name[0] in '/@':
+ continue
+ back_tick('install_name_tool -change %s @rpath/%s %s' %
+ (install_name, install_name, libpath))
+ need_rpath = True
+ if need_rpath and enc_path not in osx_get_rpaths(libpath):
+ back_tick('install_name_tool -add_rpath %s %s' %
+ (enc_path, libpath))