[OE-core] [PATCH 1/2] easyinstall: class to create and extend the easyinstall.pth file

Lukas Bulwahn lukas.bulwahn at oss.bmw-carit.de
Tue Dec 18 13:58:39 UTC 2012


From: Lukas Bulwahn <lukas.bulwahn at bmw-carit.de>

When installing python packages that are installed with python's easyinstall,
the installation creates easyinstall.pth files. This file must exist in the
root filesystem so that python 2.7 can locate and import the installed modules
in the host system.

Due to the import of the changeset aaaac4c545623d8818de2d3fa71d9d63b717c575
from the Classic OpenEmbedded Development Tree in changeset
733dc27ecf485a0ec5318534dfbbc9491c08df8f, the easyinstall.pth file is removed.
The original changeset claims that python 2.5 can import packages without the
easyinstall.pth file. However in my experience, python 2.7 cannot import
packages without this file. Furthermore, the easyinstall.pth file must
accumulate entries when multiple packages are installed with easyinstall.

The easyinstall class provides a simple postinst script that adds the content
of the variable EASYINSTALL_${PN} to the easyinstall.pth file and initializes
the file if necessary.
---
 meta/classes/easyinstall.bbclass |   11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 meta/classes/easyinstall.bbclass

diff --git a/meta/classes/easyinstall.bbclass b/meta/classes/easyinstall.bbclass
new file mode 100644
index 0000000..8ae975d
--- /dev/null
+++ b/meta/classes/easyinstall.bbclass
@@ -0,0 +1,11 @@
+
+pkg_postinst_${PN} () {
+       if test ! -e ${PYTHON_SITEPACKAGES_DIR}/easy-install.pth; then
+            cat > ${PYTHON_SITEPACKAGES_DIR}/easy-install.pth << EOF
+import sys; sys.__plen = len(sys.path)
+import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
+EOF
+        fi
+        sed -i '$ i ${EASYINSTALL_${PN}}' ${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
+}
+
-- 
1.7.9.5





More information about the Openembedded-core mailing list