From 056fc996760a6b0085308848bea5d9d316fb3e56 Mon Sep 17 00:00:00 2001 From: Sinan Date: Wed, 18 Mar 2020 11:19:27 -0700 Subject: Use python extend_path as pyqt sip fix (#15297) * try extend path to solve PyQt5.sip not found issue * disable private sip installation in sippackage class * undo manual PyQt5 dir creation in py-sip site-packages dir * fix typo * fix typo * also apply fix to PyQt4 * tidy up * flake8 and tidy up * tidy and undo hardcoding of python_include_dir * replace hardcoded python inc dir * fix minor issues * rethink include dir variable name * improve style * add new versions * implement new sip setup to qsci installation * set sip-incdir correctly for the new setup * setup extend_path thing before qsci python bindings * take care of conflict * flake8 * also extend for PyQt4 * improve style * improve style * SipPackage build sys should depend on py-sip * consolidate extend_path fixes into SipPackage * fix typo * fix bugs * flake8 * revert sip doc to pre-resource setup * import os module * flake8 Co-authored-by: Sinan81 --- lib/spack/docs/build_systems/sippackage.rst | 12 ++------ lib/spack/spack/build_systems/sip.py | 48 +++++++++++++---------------- 2 files changed, 24 insertions(+), 36 deletions(-) (limited to 'lib') diff --git a/lib/spack/docs/build_systems/sippackage.rst b/lib/spack/docs/build_systems/sippackage.rst index b8c08ec513..ddf9a26ab9 100644 --- a/lib/spack/docs/build_systems/sippackage.rst +++ b/lib/spack/docs/build_systems/sippackage.rst @@ -51,10 +51,8 @@ Build system dependencies ``SIPPackage`` requires several dependencies. Python is needed to run the ``configure.py`` build script, and to run the resulting Python libraries. Qt is needed to provide the ``qmake`` command. SIP is also -needed to build the package. SIP is an unusual dependency in that it -must be installed in the same installation directory as the package, -so instead of a ``depends_on``, we use a ``resource``. All of these -dependencies are automatically added via the base class +needed to build the package. All of these dependencies are automatically +added via the base class .. code-block:: python @@ -62,11 +60,7 @@ dependencies are automatically added via the base class depends_on('qt', type='build') - resource(name='sip', - url='https://www.riverbankcomputing.com/static/Downloads/sip/4.19.18/sip-4.19.18.tar.gz', - sha256='c0bd863800ed9b15dcad477c4017cdb73fa805c25908b0240564add74d697e1e', - destination='.') - + depends_on('py-sip', type='build') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Passing arguments to ``configure.py`` diff --git a/lib/spack/spack/build_systems/sip.py b/lib/spack/spack/build_systems/sip.py index 314f91d5d2..f814ef1837 100644 --- a/lib/spack/spack/build_systems/sip.py +++ b/lib/spack/spack/build_systems/sip.py @@ -5,9 +5,10 @@ import inspect -from llnl.util.filesystem import working_dir -from spack.directives import depends_on, extends, resource -from spack.package import PackageBase, run_before, run_after +from llnl.util.filesystem import working_dir, join_path +from spack.directives import depends_on, extends +from spack.package import PackageBase, run_after +import os class SIPPackage(PackageBase): @@ -40,33 +41,12 @@ class SIPPackage(PackageBase): extends('python') depends_on('qt') - - resource(name='sip', - url='https://www.riverbankcomputing.com/static/Downloads/sip/4.19.18/sip-4.19.18.tar.gz', - sha256='c0bd863800ed9b15dcad477c4017cdb73fa805c25908b0240564add74d697e1e', - destination='.') + depends_on('py-sip') def python(self, *args, **kwargs): """The python ``Executable``.""" inspect.getmodule(self).python(*args, **kwargs) - @run_before('configure') - def install_sip(self): - args = [ - '--sip-module={0}'.format(self.sip_module), - '--bindir={0}'.format(self.prefix.bin), - '--destdir={0}'.format(inspect.getmodule(self).site_packages_dir), - '--incdir={0}'.format(inspect.getmodule(self).python_include_dir), - '--sipdir={0}'.format(self.prefix.share.sip), - '--stubsdir={0}'.format(inspect.getmodule(self).site_packages_dir), - ] - - with working_dir('sip-4.19.18'): - self.python('configure.py', *args) - - inspect.getmodule(self).make() - inspect.getmodule(self).make('install') - def configure_file(self): """Returns the name of the configure file to use.""" return 'configure.py' @@ -77,12 +57,15 @@ class SIPPackage(PackageBase): args = self.configure_args() + python_include_dir = 'python' + str(spec['python'].version.up_to(2)) + args.extend([ '--verbose', '--confirm-license', '--qmake', spec['qt'].prefix.bin.qmake, - '--sip', prefix.bin.sip, - '--sip-incdir', inspect.getmodule(self).python_include_dir, + '--sip', spec['py-sip'].prefix.bin.sip, + '--sip-incdir', join_path(spec['py-sip'].prefix.include, + python_include_dir), '--bindir', prefix.bin, '--destdir', inspect.getmodule(self).site_packages_dir, ]) @@ -131,3 +114,14 @@ class SIPPackage(PackageBase): # Check that self.prefix is there after installation run_after('install')(PackageBase.sanity_check_prefix) + + @run_after('install') + def extend_path_setup(self): + # See github issue #14121 and PR #15297 + module = self.spec['py-sip'].variants['module'].value + if module != 'sip': + module = module.split('.')[0] + with working_dir(inspect.getmodule(self).site_packages_dir): + with open(os.path.join(module, '__init__.py'), 'a') as f: + f.write('from pkgutil import extend_path\n') + f.write('__path__ = extend_path(__path__, __name__)\n') -- cgit v1.2.3-70-g09d2