libraries/stfl: Add Python 3 support.

Signed-off-by: Benjamin Trigona-Harany <bosth@alumni.sfu.ca>
This commit is contained in:
Benjamin Trigona-Harany 2018-03-18 21:16:11 -07:00 committed by Willy Sudiarto Raharjo
parent 2d1259a9a2
commit de11fe585d
3 changed files with 115 additions and 21 deletions

View File

@ -1,13 +0,0 @@
diff -Nur stfl-0.22.a/python/Makefile.snippet stfl-0.22.b/python/Makefile.snippet
--- stfl-0.22.a/python/Makefile.snippet 2009-06-18 01:27:16.000000000 -0700
+++ stfl-0.22.b/python/Makefile.snippet 2012-10-05 18:24:00.912721777 -0700
@@ -33,8 +33,7 @@
install_python: python/_stfl.so python/stfl.py python/stfl.pyc
mkdir -p $(DESTDIR)$(PYTHON_SITEARCH)/
- mkdir -p $(DESTDIR)$(PYTHON_SITEARCH)/lib-dynload/
- cp python/_stfl.so $(DESTDIR)$(PYTHON_SITEARCH)/lib-dynload/
+ cp python/_stfl.so $(DESTDIR)$(PYTHON_SITEARCH)/
cp python/stfl.pyc $(DESTDIR)$(PYTHON_SITEARCH)/
cp python/stfl.py $(DESTDIR)$(PYTHON_SITEARCH)/

View File

@ -0,0 +1,106 @@
diff -Nur stfl-0.24/Makefile stfl-0.24-py3/Makefile
--- stfl-0.24/Makefile 2015-02-12 05:14:33.000000000 -0800
+++ stfl-0.24-py3/Makefile 2018-03-18 20:44:29.103012040 -0700
@@ -48,6 +48,8 @@
rm -f perl5/stfl_wrap.c perl5/stfl.pm perl5/build_ok
rm -f python/stfl.py python/stfl.pyc python/_stfl.so
rm -f python/stfl_wrap.c python/stfl_wrap.o
+ rm -f python3/stfl.py python3/stfl.pyc python3/_stfl.so
+ rm -f python3/stfl_wrap.c python3/stfl_wrap.o
rm -f ruby/Makefile ruby/stfl_wrap.c ruby/stfl_wrap.o
rm -f ruby/stfl.so ruby/build_ok Makefile.deps_new
rm -f stfl.pc libstfl.so libstfl.so.*
@@ -81,6 +83,10 @@
include python/Makefile.snippet
endif
+ifeq ($(FOUND_SWIG)$(FOUND_PYTHON3),11)
+include python3/Makefile.snippet
+endif
+
ifeq ($(FOUND_SWIG)$(FOUND_RUBY),11)
include ruby/Makefile.snippet
endif
diff -Nur stfl-0.24/Makefile.cfg stfl-0.24-py3/Makefile.cfg
--- stfl-0.24/Makefile.cfg 2009-05-31 11:20:39.000000000 -0700
+++ stfl-0.24-py3/Makefile.cfg 2018-03-18 20:59:24.365022626 -0700
@@ -46,6 +46,12 @@
FOUND_PYTHON = 0
endif
+ifneq ($(shell python3 -c 'print(1)' 2>/dev/null),)
+FOUND_PYTHON3 = 1
+else
+FOUND_PYTHON3 = 0
+endif
+
ifneq ($(shell ruby -e 'puts 1' 2>/dev/null),)
FOUND_RUBY = 1
else
diff -Nur stfl-0.24/python/Makefile.snippet stfl-0.24-py3/python/Makefile.snippet
--- stfl-0.24/python/Makefile.snippet 2009-06-18 01:27:16.000000000 -0700
+++ stfl-0.24-py3/python/Makefile.snippet 2018-03-18 21:04:57.805026569 -0700
@@ -33,8 +33,7 @@
install_python: python/_stfl.so python/stfl.py python/stfl.pyc
mkdir -p $(DESTDIR)$(PYTHON_SITEARCH)/
- mkdir -p $(DESTDIR)$(PYTHON_SITEARCH)/lib-dynload/
- cp python/_stfl.so $(DESTDIR)$(PYTHON_SITEARCH)/lib-dynload/
+ cp python/_stfl.so $(DESTDIR)$(PYTHON_SITEARCH)/
cp python/stfl.pyc $(DESTDIR)$(PYTHON_SITEARCH)/
cp python/stfl.py $(DESTDIR)$(PYTHON_SITEARCH)/
diff -Nur stfl-0.24/python3/Makefile.snippet stfl-0.24-py3/python3/Makefile.snippet
--- stfl-0.24/python3/Makefile.snippet 2018-03-18 21:02:25.523024769 -0700
+++ stfl-0.24-py3/python3/Makefile.snippet 2018-03-18 20:56:37.624020655 -0700
@@ -18,23 +18,22 @@
# MA 02110-1301 USA
#
-PYTHON_VERSION = $(shell python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d'.')
-PYTHON_SITEARCH = $(shell python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")
+PYTHON3_VERSION = $(shell python3 -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d'.')
+PYTHON3_SITEARCH = $(shell python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
-all: python/_stfl.so python/stfl.py python/stfl.pyc
+all: python3/_stfl.so python3/stfl.py python3/stfl.pyc
-install: install_python
+install: install_python3
-python/_stfl.so python/stfl.py python/stfl.pyc: libstfl.a stfl.h python/stfl.i swig/*.i
- cd python && swig -python -threads stfl.i
- gcc -shared -pthread -fPIC python/stfl_wrap.c -I/usr/include/python$(PYTHON_VERSION) \
- -I. libstfl.a -lncursesw -o python/_stfl.so
- cd python && python -c 'import stfl'
-
-install_python: python/_stfl.so python/stfl.py python/stfl.pyc
- mkdir -p $(DESTDIR)$(PYTHON_SITEARCH)/
- mkdir -p $(DESTDIR)$(PYTHON_SITEARCH)/lib-dynload/
- cp python/_stfl.so $(DESTDIR)$(PYTHON_SITEARCH)/lib-dynload/
- cp python/stfl.pyc $(DESTDIR)$(PYTHON_SITEARCH)/
- cp python/stfl.py $(DESTDIR)$(PYTHON_SITEARCH)/
+python3/_stfl.so python3/stfl.py python3/stfl.pyc: libstfl.a stfl.h python3/stfl.i swig/*.i
+ cd python3 && swig -python -threads stfl.i
+ gcc -shared -pthread -fPIC python3/stfl_wrap.c -I/usr/include/python$(PYTHON3_VERSION)m \
+ -I. libstfl.a -lncursesw -o python3/_stfl.so
+ cd python3 && python3 -c 'import stfl'
+
+install_python3: python3/_stfl.so python3/stfl.py python3/stfl.pyc
+ mkdir -p $(DESTDIR)$(PYTHON3_SITEARCH)/
+ cp python3/_stfl.so $(DESTDIR)$(PYTHON3_SITEARCH)/
+ cp -r python3/__pycache__ $(DESTDIR)$(PYTHON3_SITEARCH)/
+ cp python3/stfl.py $(DESTDIR)$(PYTHON3_SITEARCH)/
diff -Nur stfl-0.24/python3/example.py stfl-0.24-py3/python3/example.py
--- stfl-0.24/python3/example.py 2018-03-18 21:02:25.523024769 -0700
+++ stfl-0.24-py3/python3/example.py 2018-03-18 20:38:11.053007569 -0700
@@ -52,7 +52,7 @@
if __name__=="__main__":
if len(sys.argv) not in [2,3]:
- print "Usage: %s file.csv [delimiter]"%sys.argv[0]
+ print("Usage: %s file.csv [delimiter]"%sys.argv[0])
sys.exit(1)
c=CSV(sys.argv[1], len(sys.argv)==3 and sys.argv[2] or ",")

View File

@ -47,15 +47,16 @@ tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 \
-o -perm 400 \) -exec chmod 644 {} \;
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
# Allow custom options in Makefile
patch -p1 < $CWD/allow-custom-opts-in-Makefile.patch
# Fix the install directory for Python
patch -p1 < $CWD/fix-python-install-in-Makefile.patch
# Add proper Python 2/3 support
cp -r python python3
patch -p1 < $CWD/python-support.patch
make install \
OPTS="$SLKCFLAGS" \
@ -67,7 +68,7 @@ make install \
find $PKG -name perllocal.pod -o -name ".packlist" -o -name "*.bs" | xargs rm -f || true
find $PKG -depth -type d -empty -delete || true
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
# make installs an example for perl in the lib path
@ -80,7 +81,7 @@ cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
# install all examples into the doc directory
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/examples
cp -a \
example.{c,stfl} perl5/example*.pl python/example.* ruby/example.rb spl/*.spl \
example.{c,stfl} perl5/example*.pl python/example*.* ruby/example*.rb \
$PKG/usr/doc/$PRGNAM-$VERSION/examples
mkdir -p $PKG/install