From f9dc41f8061890b1d768eb2365ceede2c7bfc95b Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 5 Nov 2019 22:15:14 -0800 Subject: pybind11: correct get_include path (#13605) * pybind11: test get_include path Helper for non-CMake downstream projects to find the pybind11 header location. * pybind11: return proper get_include() use our prefix instead of letting pybind11 trying to self-determine it from given conda/virtualenv/global rules. Co-Authored-By: Adam J. Stewart --- .../repos/builtin/packages/py-pybind11/package.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/py-pybind11/package.py b/var/spack/repos/builtin/packages/py-pybind11/package.py index cd482ceb32..a0bcafca7f 100644 --- a/var/spack/repos/builtin/packages/py-pybind11/package.py +++ b/var/spack/repos/builtin/packages/py-pybind11/package.py @@ -56,7 +56,27 @@ class PyPybind11(CMakePackage): def setup_build_environment(self, env): env.set('PYBIND11_USE_CMAKE', 1) + def patch(self): + """ see https://github.com/spack/spack/issues/13559 """ + filter_file('import sys', + 'import sys; return "{0}"'.format(self.prefix.include), + 'pybind11/__init__.py', + string=True) + def install(self, spec, prefix): super(PyPybind11, self).install(spec, prefix) setup_py('install', '--single-version-externally-managed', '--root=/', '--prefix={0}'.format(prefix)) + + @run_after('install') + @on_package_attributes(run_tests=True) + def test(self): + with working_dir('spack-test', create=True): + # test include helper points to right location + python = self.spec['python'].command + inc = python( + '-c', + 'import pybind11 as py; ' + + self.spec['python'].package.print_string('py.get_include()'), + output=str) + assert inc.strip() == str(self.prefix.include) -- cgit v1.2.3-70-g09d2