Skip to content

Commit

Permalink
adds build setup for Python 2 on RPi
Browse files Browse the repository at this point in the history
  • Loading branch information
myTonino committed Jun 6, 2017
1 parent e7af9ac commit e0532f1
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 6 deletions.
136 changes: 136 additions & 0 deletions src/build-rpi2-pi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#!/bin/sh
#
# build-rpi3-pi.sh
#
# Copyright (c) 2016, Paul Holleis, Marko Luther
# All rights reserved.
#
#
# LICENSE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


export QT_SELECT="default"
export QTTOOLDIR="/usr/lib/arm-linux-gnueabihf/qt4/bin"
export QTLIBDIR="/usr/lib/arm-linux-gnueabihf"
export QT_PATH=/usr/share/qt4

export QT=/usr/lib/arm-linux-gnueabihf/qt4

rm -f ui/.*.ui
rm -f qrc/.*.qrc

# ui
find ui -iname "*.ui" | while read f
do
fullfilename=$(basename $f)
fn=${fullfilename%.*}
pyuic4 -o uic/${fn}.py --from-imports ui/${fn}.ui
done

# qrc
find qrc -iname "*.qrc" | while read f
do
fullfilename=$(basename $f)
fn=${fullfilename%.*}
pyrcc4 -o uic/${fn}_rc.py qrc/${fn}.qrc
done

# translations
pylupdate4 conf/tonino.pro
lrelease -qt=5 -verbose conf/tonino.pro

# clean build
rm -rf build dist

#pyinstaller
# --noconfirm \
# --clean \
# --log-level=WARN \
# -D \
# tonino-linux.spec
pyinstaller --runtime-hook rthook_pyqt4.py -D -n tonino -y -c --log-level=WARN "tonino.py"

mv dist/tonino dist/tonino.d
mv dist/tonino.d/* dist
rm -rf dist/tonino.d

cp -R /usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/ dist
rm -rf dist/mpl-data/sample_data
cp conf/tonino-toni.xml dist
cp -R icons dist
cp doc/README.txt dist
cp doc/LICENSE.txt dist
mkdir dist/includes
mkdir dist/includes/linux
cp includes/tonino-*.hex dist/includes
cp includes/tinyTonino-*.hex dist/includes
## sudo apt-get install avrdude
cp /usr/bin/avrdude dist/includes/linux
cp /etc/avrdude.conf dist/includes/linux
cp conf/qt.conf dist
mkdir dist/translations
cp translations/*.qm dist/translations
cp $QT_PATH/translations/qt_de.qm dist/translations
cp $QT_PATH/translations/qt_es.qm dist/translations
cp $QT_PATH/translations/qt_fr.qm dist/translations
#cp $QT_PATH/translations/qt_it.qm dist/translations



## generate the .deb package

cp raspbian/DEBIAN/control debian/DEBIAN/
VERSION=$(python -c 'import lib; print(lib.__version__)')
NAME=tonino-linux-${VERSION}

# fix debian/DEBIAN/control _VERSION_
sed -i "s/_VERSION_/${VERSION}/g" debian/DEBIAN/control


# prepare debian directory

cp doc/changelog debian/usr/share/doc/tonino
cp doc/copyright debian/usr/share/doc/tonino
cp doc/tonino.1 debian/usr/share/man/man1/tonino.1

rm -f debian/usr/share/man/man1/tonino.1.gz
gzip -9 debian/usr/share/man/man1/tonino.1
chmod +r debian/usr/share/man/man1/tonino.1.gz
rm -f debian/usr/share/doc/tonino/changelog.gz
gzip -9 debian/usr/share/doc/tonino/changelog
chmod +r debian/usr/share/doc/tonino/changelog.gz

chmod +r debian/usr/share/applications/tonino.desktop
chmod -x debian/usr/share/applications/tonino.desktop
chmod +rx debian/usr/bin/tonino
chmod -R +r dist
chmod +x dist/icons

# buid .deb package (into /usr/share)

tar -cf dist-rpi.tar dist
rm -rf debian/usr/share/tonino
tar -xf dist-rpi.tar -C debian/usr/share
mv debian/usr/share/dist debian/usr/share/tonino
find debian -name .svn -exec rm -rf {} \; > /dev/null 2>&1
chown -R root:root debian
chmod -R go-w debian
rm ${NAME}_raspbian-jessie.deb
chmod 755 debian/DEBIAN
chmod 755 debian/DEBIAN/postinst
chmod 755 debian/DEBIAN/prerm
dpkg-deb --build debian ${NAME}_raspbian-jessie-py2.deb

14 changes: 8 additions & 6 deletions src/build-rpi3-pi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
export QT_SELECT="default"
export QTTOOLDIR="/usr/lib/arm-linux-gnueabihf/qt5/bin"
export QTLIBDIR="/usr/lib/arm-linux-gnueabihf"
export QT_PATH=/usr/share/qt5

export QT=/usr/lib/arm-linux-gnueabihf/qt5

Expand Down Expand Up @@ -60,7 +61,7 @@ rm -rf build dist
# --log-level=WARN \
# -D \
# tonino-linux.spec
pyinstaller -D -n tonino -y -c --log-level=WARN "tonino.py"
pyinstaller3 -D -n tonino -y -c --log-level=WARN "tonino.py"

mv dist/tonino dist/tonino.d
mv dist/tonino.d/* dist
Expand All @@ -82,10 +83,10 @@ cp /etc/avrdude.conf dist/includes/linux
cp conf/qt.conf dist
mkdir dist/translations
cp translations/*.qm dist/translations
cp /usr/share/qt5/translations/qt_de.qm dist/translations
cp /usr/share/qt5/translations/qt_es.qm dist/translations
cp /usr/share/qt5/translations/qt_fr.qm dist/translations
cp /usr/share/qt5/translations/qt_it.qm dist/translations
cp $QT_PATH/translations/qt_de.qm dist/translations
cp $QT_PATH/translations/qt_es.qm dist/translations
cp $QT_PATH/translations/qt_fr.qm dist/translations
cp $QT_PATH/translations/qt_it.qm dist/translations



Expand All @@ -110,6 +111,7 @@ gzip -9 debian/usr/share/man/man1/tonino.1
chmod +r debian/usr/share/man/man1/tonino.1.gz
rm -f debian/usr/share/doc/tonino/changelog.gz
gzip -9 debian/usr/share/doc/tonino/changelog
chmod +r debian/usr/share/doc/tonino/changelog.gz

chmod +r debian/usr/share/applications/tonino.desktop
chmod -x debian/usr/share/applications/tonino.desktop
Expand All @@ -130,5 +132,5 @@ rm ${NAME}_raspbian-jessie.deb
chmod 755 debian/DEBIAN
chmod 755 debian/DEBIAN/postinst
chmod 755 debian/DEBIAN/prerm
dpkg-deb --build debian ${NAME}_raspbian-jessie.deb
dpkg-deb --build debian ${NAME}_raspbian-jessie-py3.deb

5 changes: 5 additions & 0 deletions src/rthook_pyqt4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# runtime hook for PyInstaller and PyQt4
# needs to be done before any other PyQt import
import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)

0 comments on commit e0532f1

Please sign in to comment.