On Tue, Aug 14, 2018 at 1:47 PM, Waldek Kozaczuk <jwkozac...@gmail.com> wrote:
> This seems to be distribution specific. The original python27 did not work > on my Ubuntu 18.04 because of ‘/lib64/“-assumed-location-of-python-on-host > directory problem. Which I fixed by using os.* values from python itself. > > There are possibly other fedora vs ubuntu discrepancies which this patch > does not take account for. > Thanks. I committed your patch and my patch which makes it work on Fedora 28. Can you please check that my patch didn't break it again for Ubuntu? Thanks! > Waldek > > Sent from my iPhone > > On Aug 14, 2018, at 03:31, Nadav Har'El <n...@scylladb.com> wrote: > > > On Tue, Aug 14, 2018 at 6:42 AM, Waldemar Kozaczuk <jwkozac...@gmail.com> > wrote: > >> This patch renames python27 to python2x and improves it >> by discovering Python home directory by reading sys.* variables. >> > > I committed this, but it doesn't seem to actually work for me, on Fedora > 28: > > $ scripts/run.py -e /python > OSv v0.51.0-15-ge54f98e6 > eth0: 192.168.122.15 > Could not find platform independent libraries <prefix> > Could not find platform dependent libraries <exec_prefix> > Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] > ImportError: No module named site > > Do we perhaps need more symbolic links? I'll try to fix this and commit > another followup patch. > > > >> Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com> >> --- >> python27/README | 8 -------- >> {python27 => python2x}/GET | 17 ++++++++++------- >> {python27 => python2x}/Makefile | 0 >> python2x/README | 13 +++++++++++++ >> {python27 => python2x}/python.c | 0 >> {python27 => python2x}/usr.manifest | 0 >> 6 files changed, 23 insertions(+), 15 deletions(-) >> delete mode 100644 python27/README >> rename {python27 => python2x}/GET (67%) >> rename {python27 => python2x}/Makefile (100%) >> create mode 100644 python2x/README >> rename {python27 => python2x}/python.c (100%) >> rename {python27 => python2x}/usr.manifest (100%) >> >> diff --git a/python27/README b/python27/README >> deleted file mode 100644 >> index 3569e47..0000000 >> --- a/python27/README >> +++ /dev/null >> @@ -1,8 +0,0 @@ >> -This app builds an image containing the already-compiled Python shared >> -object (libpython2.7.so) installed on the build macine, and some of >> -the required libraries from the build machine. >> - >> -Example usage: >> - >> -./scripts/run.py -e "/python" >> -./scripts/run.py -e "/python -c \"aa={1:22,3:44}; print aa; print >> 'asdf'\"" >> diff --git a/python27/GET b/python2x/GET >> similarity index 67% >> rename from python27/GET >> rename to python2x/GET >> index 05774df..8942577 100755 >> --- a/python27/GET >> +++ b/python2x/GET >> @@ -1,10 +1,14 @@ >> #!/usr/bin/env bash >> set -e >> >> -VERSION=2.7 >> BASEDIR=$PWD >> ROOTFS=$BASEDIR/ROOTFS >> >> +PYTHON_PREFIX_DIR=`python -c 'import sys; print(sys.prefix)'` >> +PYTHON_MAJOR_VERSION=`python -c 'import sys; >> print(sys.version_info.major)'` >> +PYTHON_MINOR_VERSION=`python -c 'import sys; >> print(sys.version_info.minor)'` >> +PYTHON_VERSION="${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}" >> + >> install_shlibs() { >> SHLIBS="" >> SHLIBS+=" $ROOTFS/python.so " >> @@ -17,23 +21,22 @@ SHLIBS_COUNT="`echo \"$SHLIBS\" | wc -l`" >> ldd $SHLIBS | grep -Po '(?<=> )/[^ ]+' | sort | uniq | grep -Pv >> 'lib(c|gcc|dl|m|util|rt|pthread|stdc\+\+|selinux|krb5|gssapi_krb5)\.so' >> | xargs -I {} install {} $ROOTFS/usr/lib >> # ROOTFS/lib/python2.7/config/libpython2.7.so is a symlink to ../../ >> libpython2.7.so, >> # so create a valid destination to avoid ldd error due to dangling >> symlink. >> -(cd $ROOTFS/lib && ln -sf ../usr/lib/libpython$VERSION.so.1.0 >> libpython$VERSION.so) >> +(cd $ROOTFS/lib && ln -sf ../usr/lib/libpython${PYTHON_VERSION}.so.1.0 >> libpython${PYTHON_VERSION}.so) >> echo "$SHLIBS_COUNT" >> } >> >> main() { >> mkdir -p build/ >> -gcc -o build/python.so python.c -fPIC -shared -lpython${VERSION} >> +gcc -o build/python.so python.c -fPIC -shared -lpython${PYTHON_VERSION} >> >> rm -rf "$ROOTFS" >> mkdir -p "$ROOTFS/usr/lib" >> -mkdir -p "$ROOTFS/lib/python$VERSION" >> +mkdir -p "$ROOTFS/lib/python${PYTHON_VERSION}" >> >> cp build/python.so "$ROOTFS" >> install_shlibs >> -# TODO /lib64/python2.7/ should not be hardcoded? >> -PY_LIB1=/lib64/python$VERSION/ >> -rsync -a $PY_LIB1 $ROOTFS/lib/python$VERSION/ --exclude test --exclude >> unittest \ >> +PY_LIB1="${PYTHON_PREFIX_DIR}/lib/python${PYTHON_VERSION}/" >> +rsync -a $PY_LIB1 $ROOTFS/lib/python${PYTHON_VERSION}/ --safe-links >> --exclude test --exclude unittest \ >> --exclude '*.pyc' --exclude '*.pyo' --exclude '*.egg-info' >> >> SHLIBS_COUNT4=`install_shlibs` >> diff --git a/python27/Makefile b/python2x/Makefile >> similarity index 100% >> rename from python27/Makefile >> rename to python2x/Makefile >> diff --git a/python2x/README b/python2x/README >> new file mode 100644 >> index 0000000..217a00b >> --- /dev/null >> +++ b/python2x/README >> @@ -0,0 +1,13 @@ >> +This app builds an image containing the already-compiled Python shared >> +object for Python 2.x (libpython2.7.so for example) installed on the >> build macine, >> +and some of the required libraries from the build machine. >> + >> +The python home directory is assumed to be installed under >> +<sys.prefix>/lib/python<sys.version_info.major>.<sys.versio >> n_info.minor>/ >> +where sys is Python package this script reads the sys.* values from. >> + >> +Example usage: >> + >> +./scripts/run.py -e "/python" >> +./scripts/run.py -e "/python -c \"aa={1:22,3:44}; print aa; print >> 'asdf'\"" >> +./scripts/run.py --api -e "/python -m SimpleHTTPServer 8000" >> diff --git a/python27/python.c b/python2x/python.c >> similarity index 100% >> rename from python27/python.c >> rename to python2x/python.c >> diff --git a/python27/usr.manifest b/python2x/usr.manifest >> similarity index 100% >> rename from python27/usr.manifest >> rename to python2x/usr.manifest >> -- >> 2.17.1 >> >> -- >> 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. >> > > -- 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.