aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake/interpreter.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/cmake/interpreter.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/cmake/interpreter.py')
-rw-r--r--mesonbuild/cmake/interpreter.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
index 7e9873f..125f18b 100644
--- a/mesonbuild/cmake/interpreter.py
+++ b/mesonbuild/cmake/interpreter.py
@@ -15,6 +15,8 @@
# This class contains the basic functionality needed to run any interpreter
# or an interpreter-based tool.
+import pkg_resources
+
from .common import CMakeException, CMakeTarget
from .client import CMakeClient, RequestCMakeInputs, RequestConfigure, RequestCompute, RequestCodeModel
from .fileapi import CMakeFileAPI
@@ -789,7 +791,7 @@ class CMakeInterpreter:
raise CMakeException('Unable to find CMake')
self.trace = CMakeTraceParser(cmake_exe.version(), self.build_dir, permissive=True)
- preload_file = Path(__file__).resolve().parent / 'data' / 'preload.cmake'
+ preload_file = pkg_resources.resource_filename('mesonbuild', 'cmake/data/preload.cmake')
# Prefere CMAKE_PROJECT_INCLUDE over CMAKE_TOOLCHAIN_FILE if possible,
# since CMAKE_PROJECT_INCLUDE was actually designed for code injection.
@@ -1034,7 +1036,7 @@ class CMakeInterpreter:
root_cb.lines += [function('project', [self.project_name] + self.languages)]
# Add the run script for custom commands
- run_script = '{}/data/run_ctgt.py'.format(os.path.dirname(os.path.realpath(__file__)))
+ run_script = pkg_resources.resource_filename('mesonbuild', 'cmake/data/run_ctgt.py')
run_script_var = 'ctgt_run_script'
root_cb.lines += [assign(run_script_var, function('find_program', [[run_script]], {'required': True}))]