aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-09-14 20:26:14 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2017-01-09 21:07:23 +0200
commit24221d71ccd341759b008cf1918826910c40247c (patch)
tree16edc7011ba57678fbe8393d7076966dc70564df /mesonbuild/modules
parent9cf0991a1d332cb1f492376bf718aa75020519e4 (diff)
downloadmeson-24221d71ccd341759b008cf1918826910c40247c.zip
meson-24221d71ccd341759b008cf1918826910c40247c.tar.gz
meson-24221d71ccd341759b008cf1918826910c40247c.tar.bz2
Created a Python 3 module for simpler building of Python extension modules.
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/python3.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/mesonbuild/modules/python3.py b/mesonbuild/modules/python3.py
new file mode 100644
index 0000000..370e925
--- /dev/null
+++ b/mesonbuild/modules/python3.py
@@ -0,0 +1,40 @@
+# Copyright 2016-2017 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .. import coredata, build
+from .. import mesonlib
+import os
+
+class Python3Module:
+
+ def extension_module(self, state, args, kwargs):
+ if 'name_prefix' in kwargs:
+ raise mesonlib.MesonException('Name_prefix is set automatically, specifying it is forbidden.')
+ if 'name_suffix' in kwargs:
+ raise mesonlib.MesonException('Name_suffix is set automatically, specifying it is forbidden.')
+ host_system = state.host_machine.system
+ if host_system == 'darwin':
+ # Default suffix is 'dylib' but Python does not use it for extensions.
+ suffix = 'so'
+ elif host_system == 'windows':
+ # On Windows the extension is pyd for some unexplainable reason.
+ suffix = 'pyd'
+ else:
+ suffix = []
+ kwargs['name_prefix'] = ''
+ kwargs['name_suffix'] = suffix
+ return state.interpreter.func_shared_module(None, args, kwargs)
+
+def initialize():
+ return Python3Module()