tixi: add python variant (sets PYTHONPATH and LD_LIBRARY_PATH) (#44592)
This commit is contained in:
parent
c5d1c9ae61
commit
c1f22ca5cb
@ -3,6 +3,8 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from spack.package import *
|
from spack.package import *
|
||||||
|
|
||||||
|
|
||||||
@ -14,6 +16,8 @@ class Tixi(CMakePackage):
|
|||||||
url = "https://github.com/DLR-SC/tixi/archive/v3.0.3.tar.gz"
|
url = "https://github.com/DLR-SC/tixi/archive/v3.0.3.tar.gz"
|
||||||
git = "https://github.com/DLR-SC/tixi.git"
|
git = "https://github.com/DLR-SC/tixi.git"
|
||||||
|
|
||||||
|
maintainers("melven", "joergbrech")
|
||||||
|
|
||||||
license("Apache-2.0")
|
license("Apache-2.0")
|
||||||
|
|
||||||
version("3.3.0", sha256="988d79ccd53c815d382cff0c244c0bb8e393986377dfb45385792766adf6f6a9")
|
version("3.3.0", sha256="988d79ccd53c815d382cff0c244c0bb8e393986377dfb45385792766adf6f6a9")
|
||||||
@ -30,17 +34,42 @@ class Tixi(CMakePackage):
|
|||||||
"shared", default=True, description="Enables the build of shared libraries", when="@3.0.3:"
|
"shared", default=True, description="Enables the build of shared libraries", when="@3.0.3:"
|
||||||
)
|
)
|
||||||
variant("fortran", default=True, description="Enable Fortran bindings", when="@3.1.1:")
|
variant("fortran", default=True, description="Enable Fortran bindings", when="@3.1.1:")
|
||||||
|
variant("python", default=True, description="Add python bindings to PYTHONPATH")
|
||||||
|
|
||||||
depends_on("python", type="build")
|
depends_on("python", when="~python", type="build")
|
||||||
|
depends_on("python", when="+python", type=("build", "run"))
|
||||||
|
conflicts("~shared", when="+python")
|
||||||
depends_on("expat")
|
depends_on("expat")
|
||||||
depends_on("curl")
|
depends_on("curl")
|
||||||
depends_on("libxml2")
|
depends_on("libxml2")
|
||||||
depends_on("libxslt")
|
depends_on("libxslt")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def libs(self):
|
||||||
|
# different library names for tixi@2 and tixi@3
|
||||||
|
libname = "libtixi3" if "@3" in self.spec else "libTIXI"
|
||||||
|
shared = "~shared" not in self.spec
|
||||||
|
return find_libraries(libname, root=self.prefix, shared=shared, recursive=True)
|
||||||
|
|
||||||
def cmake_args(self):
|
def cmake_args(self):
|
||||||
args = []
|
return [
|
||||||
if self.spec.satisfies("+shared"):
|
self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
|
||||||
args.append("-DBUILD_SHARED_LIBS=ON")
|
self.define_from_variant("TIXI_ENABLE_FORTRAN", "fortran"),
|
||||||
if self.spec.satisfies("+fortran"):
|
]
|
||||||
args.append("-DTIXI_ENABLE_FORTRAN=ON")
|
|
||||||
return args
|
def setup_run_environment(self, env):
|
||||||
|
"""Allow to import tixi3wrapper in python"""
|
||||||
|
|
||||||
|
if "+python" in self.spec:
|
||||||
|
# add tixi3wrapper.py to the PYTHONPATH
|
||||||
|
if "@3" in self.spec:
|
||||||
|
env.prepend_path("PYTHONPATH", self.spec.prefix.share.tixi3.python)
|
||||||
|
else:
|
||||||
|
env.prepend_path("PYTHONPATH", self.spec.prefix.share.tixi.python)
|
||||||
|
|
||||||
|
# allow ctypes to find the tixi library
|
||||||
|
libs = ":".join(self.spec["tixi"].libs.directories)
|
||||||
|
if sys.platform == "darwin":
|
||||||
|
env.prepend_path("DYLD_FALLBACK_LIBRARY_PATH", libs)
|
||||||
|
else:
|
||||||
|
env.prepend_path("LD_LIBRARY_PATH", libs)
|
||||||
|
Loading…
Reference in New Issue
Block a user