aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2017-03-25 06:04:32 -0400
committerPatrick Griffis <tingping@tingping.se>2017-03-30 09:13:01 -0400
commita9c30ce8b54752caedacd1eacfcd9156f190101b (patch)
treed2c65e18002a8cdbbe4c0b595044b53a75820954
parentb6e06dd80be961c5924f331f9b6b3682a8e949c4 (diff)
downloadmeson-a9c30ce8b54752caedacd1eacfcd9156f190101b.zip
meson-a9c30ce8b54752caedacd1eacfcd9156f190101b.tar.gz
meson-a9c30ce8b54752caedacd1eacfcd9156f190101b.tar.bz2
python3: Add sysconfig_path() method
This returns the value of sysconfig paths, useful for installing modules for example.
-rw-r--r--mesonbuild/modules/python3.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/mesonbuild/modules/python3.py b/mesonbuild/modules/python3.py
index d7d03e3..9f01043 100644
--- a/mesonbuild/modules/python3.py
+++ b/mesonbuild/modules/python3.py
@@ -52,6 +52,20 @@ class Python3Module(ExtensionModule):
raise mesonlib.MesonException('language_version() takes no arguments.')
return ModuleReturnValue(sysconfig.get_python_version(), [])
+ def sysconfig_path(self, state, args, kwargs):
+ if len(args) != 1:
+ raise mesonlib.MesonException('sysconfig_path() requires passing the name of path to get.')
+ if kwargs:
+ raise mesonlib.MesonException('sysconfig_path() does not accept keywords.')
+ path_name = args[0]
+ valid_names = sysconfig.get_path_names()
+ if path_name not in valid_names:
+ raise mesonlib.MesonException('{} is not a valid path name {}.'.format(path_name, valid_names))
+
+ # Get a relative path without a prefix, e.g. lib/python3.6/site-packages
+ path = sysconfig.get_path(path_name, vars={'base': ''})[1:]
+ return ModuleReturnValue(path, [])
+
def initialize():
return Python3Module()