summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorjoerg <joerg>2017-07-03 18:14:40 +0000
committerjoerg <joerg>2017-07-03 18:14:40 +0000
commit7b0a1923a68eadefe4a431cf4e46053601c6efb3 (patch)
tree472752e7f81dd3e053662bf0fbeaabaf2c5d346a /lang
parentd206124b0306c1047a6d53c5b6715a6a83d44fbd (diff)
downloadpkgsrc-7b0a1923a68eadefe4a431cf4e46053601c6efb3.tar.gz
Add DISTUTILS_BUILDDIR_IN_TEST_ENV as flag to get the build directory
into PYTHONPATH for testing.
Diffstat (limited to 'lang')
-rw-r--r--lang/python/distutils-builddir.py7
-rw-r--r--lang/python/extension.mk9
2 files changed, 15 insertions, 1 deletions
diff --git a/lang/python/distutils-builddir.py b/lang/python/distutils-builddir.py
new file mode 100644
index 00000000000..87a7700223b
--- /dev/null
+++ b/lang/python/distutils-builddir.py
@@ -0,0 +1,7 @@
+from os import getcwd
+from os.path import join
+from distutils.dist import Distribution
+from distutils.command.build import build
+b = build(Distribution())
+b.finalize_options()
+print(join(getcwd(), b.build_platlib))
diff --git a/lang/python/extension.mk b/lang/python/extension.mk
index 15d4d0ff4cd..6d612dc41f4 100644
--- a/lang/python/extension.mk
+++ b/lang/python/extension.mk
@@ -1,4 +1,4 @@
-# $NetBSD: extension.mk,v 1.50 2017/05/17 11:17:04 wiz Exp $
+# $NetBSD: extension.mk,v 1.51 2017/07/03 18:14:40 joerg Exp $
.include "../../lang/python/pyversion.mk"
@@ -76,3 +76,10 @@ PRINT_PLIST_AWK+= gsub(/__pycache__\//, "")
PRINT_PLIST_AWK+= gsub(/opt-1\.pyc$$/, "pyo")
PRINT_PLIST_AWK+= gsub(/\.cpython-${_PYTHON_VERSION}/, "")}
.endif
+
+DISTUTILS_BUILDDIR_IN_TEST_ENV?= no
+
+.if ${DISTUTILS_BUILDDIR_IN_TEST_ENV} == "yes"
+DISTUTILS_BUILDDIR_CMD= cd ${WRKSRC} && ${PYTHONBIN} ${.CURDIR}/../../lang/python/distutils-builddir.py
+TEST_ENV+= PYTHONPATH=${DISTUTILS_BUILDDIR_CMD:sh}
+.endif