From: Justin Cinkelj <justin.cink...@xlab.si>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master
Add python2.7
Based on @gberginc work.
Usage example:
./scripts/run.py -e "/python"
./scripts/run.py -e "/python -c \"aa={1:22,3:44}; print aa; print 'asdf'\""
Signed-off-by: Justin Cinkelj <justin.cink...@xlab.si>
Message-Id: <20170722230157.10742-1-justin.cink...@xlab.si>
---
diff --git a/python27/Makefile b/python27/Makefile
--- a/python27/Makefile
+++ b/python27/Makefile
@@ -0,0 +1,52 @@
+VERSION=2.7
+SOURCE=https://github.com/python/cpython.git
+
+PYTHON_PREFIX=$(PWD)/src/python-install
+
+
+.PHONY: module clean ROOTFS
+
+SRC=src/cpython
+
+module: usr.manifest
+
+usr.manifest: ROOTFS
+ echo '/**: $${MODULE_DIR}/ROOTFS/**' > usr.manifest
+
+clean:
+ rm -fr usr.manifest ROOTFS src
+
+# Note: the touch commands below are needed after commands which create
files
+# "in the past", like wget and tar, and can confuse Make to rebuild a
target
+# which is new, just pretends to be old.
+$(SRC)/.git/HEAD:
+ mkdir src
+ cd src; git clone $(SOURCE)
+ cd $(SRC); git checkout -b $(VERSION) origin/$(VERSION)
+ #touch $@
+
+$(SRC)/Makefile: $(SRC)/.git/HEAD
+ cd $(SRC); ./configure --enable-shared --prefix=$(PYTHON_PREFIX)
+ cd $(SRC); cp Makefile Makefile.orig;
+ cd $(SRC); sed -i 's/^LDFLAGS=.*/LDFLAGS=-shared/g' Makefile
+
+$(SRC)/python: $(SRC)/Makefile
+ cd $(SRC); $(MAKE) python
+ cd $(SRC); mv python python.so
+ # Re-link python, this time as ELF executable.
+ # This is required for make install to succeed.
+ cd $(SRC); $(MAKE) -f Makefile.orig install
+
+ROOTFS: $(SRC)/python
+ rm ROOTFS -rf
+ mkdir -p ROOTFS/usr/lib
+
+ cp $(SRC)/python.so ROOTFS/python
+ cp $(PYTHON_PREFIX)/lib/libpython$(VERSION).so.1.0 ROOTFS/usr/lib
+ # Copy the Python environment. Since we'd like to exclude some dirs,
rsync is used
+ rsync -a $(PYTHON_PREFIX)/lib/python$(VERSION) ROOTFS/lib --exclude test
--exclude unittest \
+ --exclude '*.pyc' --exclude '*.pyo' --exclude '*.egg-info'
--exclude '*.o' --exclude 'libpython'$(VERSION)'.a'
+ # TODO maybe .so files in ROOTFS/lib/python2.7/lib-dynload should be
stripped.
+ ./copy-required-system-libraries.sh
+
+.DELETE_ON_ERROR:
diff --git a/python27/copy-required-system-libraries.sh
b/python27/copy-required-system-libraries.sh
--- a/python27/copy-required-system-libraries.sh
+++ b/python27/copy-required-system-libraries.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# Copy required libraries from the build system.
+# Likely, we don't want to include all libs (and their dependencies) from
+# ldd ROOTFS/lib/python2.7/lib-dynload/*so | grep -v -e '^ROOTFS/' |
sed 's/(0x.*)//' | sort | uniq | awk '{print $3}'
+# So for now, only two (most obviously required) dependency libs will be
included.
+
+set -e
+
+PYLIBS=""
+PYLIBS+=" ROOTFS/lib/python2.7/lib-dynload/readline.so "
+PYLIBS+=" ROOTFS/lib/python2.7/lib-dynload/_curses.so "
+
+DEPLIBS=""
+for pylib in $PYLIBS
+do
+ DEPLIBS+=`ldd $pylib | egrep -v -e linux-vdso.so -e ld-linux-x86-64.so
-e 'lib(python[23]\.[0-9]|pthread|c|dl|m|util|).so.*'`
+ DEPLIBS+="\n"
+done
+#echo -e "DEPLIBS1:\n$DEPLIBS"
+DEPLIBS=`echo -e "$DEPLIBS" | sed '/^$/d' | awk '{print $3}' | sort | uniq`
+#echo -e "DEPLIBS2:\n$DEPLIBS"
+
+for deplib in $DEPLIBS
+do
+ /bin/cp $deplib ROOTFS/usr/lib
+done
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.