aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/base.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-03-23 10:51:14 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2020-04-21 00:40:19 +0300
commit57b468c75ae90e09f8bd98da12a5c420ab49cd79 (patch)
tree92068579bf791fa343de5f8ca8601c77cf2041df /mesonbuild/dependencies/base.py
parentcd79ec2839ddef766b42e0653f8be2199b723e77 (diff)
downloadmeson-57b468c75ae90e09f8bd98da12a5c420ab49cd79.zip
meson-57b468c75ae90e09f8bd98da12a5c420ab49cd79.tar.gz
meson-57b468c75ae90e09f8bd98da12a5c420ab49cd79.tar.bz2
Use pkg_resource to find resources files (data)
Doing this by hand is fraught with corner cases, and we're running into some of those problems already. setuptools pkg_resource is a well tested solution for not running into corner cases, and we already rely on setuptools to make our entry point scripts work, so we might as well make us of the other things it can solve for us. Fixes #6801
Diffstat (limited to 'mesonbuild/dependencies/base.py')
-rw-r--r--mesonbuild/dependencies/base.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 8b452cd..c0ec089 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -28,6 +28,8 @@ import typing as T
from enum import Enum
from pathlib import Path, PurePath
+import pkg_resources
+
from .. import mlog
from .. import mesonlib
from ..compilers import clib_langs
@@ -1522,8 +1524,8 @@ class CMakeDependency(ExternalDependency):
build_dir = self._get_build_dir()
# Insert language parameters into the CMakeLists.txt and write new CMakeLists.txt
- src_cmake = Path(__file__).parent / 'data' / cmake_file
- cmake_txt = src_cmake.read_text()
+ # Per the warning in pkg_resources, this is *not* a path and os.path and Pathlib are *not* safe to use here.
+ cmake_txt = pkg_resources.resource_string('mesonbuild', 'dependencies/data/' + cmake_file).decode()
# In general, some Fortran CMake find_package() also require C language enabled,
# even if nothing from C is directly used. An easy Fortran example that fails