From 68a6ba8987ab0f1b99c18102723fb1890c0658f2 Mon Sep 17 00:00:00 2001
From: smlng <s@mlng.net>
Date: Fri, 10 Aug 2018 11:32:38 +0200
Subject: [PATCH] make: introduce common Python lib path

Introduce dist/pythonlibs directory to store RIOT python packages.
This directory is exported via PYTHONPATH by the build system to
make it commonly available.
---
 Makefile.include          | 3 +++
 dist/pythonlibs/README.md | 2 ++
 makefiles/vars.inc.mk     | 2 ++
 3 files changed, 7 insertions(+)
 create mode 100644 dist/pythonlibs/README.md

diff --git a/Makefile.include b/Makefile.include
index 7233704fdb..e1f8502960 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -70,6 +70,9 @@ BUILDRELPATH ?= $(CURDIR:$(RIOTPROJECT)/%=%)/
 # get host operating system
 OS := $(shell uname)
 
+# set python path, e.g. for tests
+PYTHONPATH := $(RIOTBASE)/dist/pythonlibs/:$(PYTHONPATH)
+
 # Include Docker settings near the top because we need to build the environment
 # command line before some of the variable origins are overwritten below when
 # using abspath, strip etc.
diff --git a/dist/pythonlibs/README.md b/dist/pythonlibs/README.md
new file mode 100644
index 0000000000..7fa8fbedb1
--- /dev/null
+++ b/dist/pythonlibs/README.md
@@ -0,0 +1,2 @@
+This directory is exported through PYTHONPATH environment variable in the build system.
+Put any RIOT specific Python packages here.
diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk
index 300fedbb2d..7194443c84 100644
--- a/makefiles/vars.inc.mk
+++ b/makefiles/vars.inc.mk
@@ -31,6 +31,8 @@ export BINDIR                # This is the folder where the application should b
 export APPDIR                # The base folder containing the application
 export PKGDIRBASE            # The base folder for building packages
 
+export PYTHONPATH            # Python default search path for module filesi, with RIOT specific packages
+
 export FEATURES_REQUIRED     # List of required features by the application
 export FEATURES_PROVIDED     # List of provided features by the board
 export FEATURES_OPTIONAL     # List of nice to have features
-- 
GitLab