Skip to content

Commit

Permalink
Add a script to install PyQt4 QtWebKit on systems with no support
Browse files Browse the repository at this point in the history
  • Loading branch information
Mickaël Schoentgen committed Jan 18, 2017
1 parent e8a8f29 commit 2522f2e
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 1 deletion.
17 changes: 16 additions & 1 deletion DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,22 @@ When building/running Nuxeo Drive client from sources (i.e. not using the .msi o
You can install the `python-qt4` package directly:

```
sudo apt-get install python-qt4
sudo apt install python-qt4
```

##### PyQt4 QtWebKit

On recent Debian, the package [python-qt4.webkit has been deprecated](https://wiki.debian.org/Qt4WebKitRemoval) and removed from official repositories.
So, all Debian based distributions like Ubuntu 16.06+ will not serve this package anymore.
It means that you will not be able to launch Drive because of lack of support of Qt4 WebKit bundles.

We planned to upgrade to Qt5. In the mean time you can execute the script `dev-pyqt4.sh` at the root of this repository.
It will download necessary files and create a virtualenv with all needed libraries for Drive to work.
The resulting virtualenv will be created into `$HOME/drive-venv` but you can use a custom path:

```
chmod +x ./dev-pyqt4.sh
./dev-pyqt4.sh [DEST_DIR]
```

#### Mac OS X
Expand Down
158 changes: 158 additions & 0 deletions dev-pyqt4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#!/bin/sh
#
# 2017-01-18 Mickaël Schoentgen, Nuxeo SAS
#
# Install PyQt4 with QtWebKit support into a virtualenv for Drive.
# If it succeeds, you will be able to launch Drive from that virtualenv.
#
# Note: keep in mind that we will drop Qt4 support for Qt5, this helper
# script is for Drive developers/contributors or eventually users
# using Debian based distributions with no more QtWebKit support.
# source: https://wiki.debian.org/Qt4WebKitRemoval
#
### Dependencies
#
# You should have all binaries required for a full virtual environment
# using Python 2.7 and obvious system utilities like curl and tar.
#
# You will need these too (you can delete it after a successful installation):
#
# $ sudo apt install qt4-qmake libqt4-dev libqtwebkit-dev
#
### Usage
#
# $ chmod +x dev-pyqt4.sh
# $ ./dev-pyqt4.sh [DEST_DIR]
#
# Default virtualenv directory: $HOME/drive-venv
# You can override this parameter by setting DEST_DIR.
#

set -eu

# Global variable of the virtualenv ath installation
VENV="$HOME/drive-venv"


download() {
# Download one file and save its content to a given file name
local url="$1"
local output="$2"

echo ">>> Downloading $url to $output"

[ -f "$output" ] || \
curl -L "$url" > "$output"
}

extract() {
# Extract a downloaded file
local file="$1"
local folder="$2"

echo ">>> Extracting $file to $folder"

[ -d "$folder" ] || \
tar zxf "$file"
}

setup_venv() {
# Setup virtualenv
local action="--install"
[ "$#" -eq 1 ] && \
action="--no-install"

echo ">>> Setting up the virtualenv into $VENV"

[ -d "$VENV" ] || \
virtualenv \
-p /usr/bin/python2.7 \
--no-site-packages \
--always-copy \
"$VENV"

. "${VENV}/bin/activate"

# A simple use of the virtualenv for tests, no install required
[ "$action" = "--no-install" ] && \
return

pip install -r "requirements.txt"
pip install -r "unix-requirements.txt"
}

install_sip() {
# Install SIP
local url="https://sourceforge.net/projects/pyqt/files/sip/sip-4.19/sip-4.19.tar.gz"
local path="sip-4.19"
local output="${path}.tar.gz"

echo ">>> Installing SIP"

download "$url" "$output"
extract "$output" "$path"

cd "$path"
python configure.py
make
make install
cd ..
}

install_pyqt4() {
# Install PyQt4 + QtWebKit
local url="http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.12/PyQt4_gpl_x11-4.12.tar.gz"
local path="PyQt4_gpl_x11-4.12"
local output="${path}.tar.gz"

echo ">>> Installing PyQt4 with WebKit support"

download "$url" "$output"
extract "$output" "$path"

cd "$path"
python configure-ng.py \
--confirm-license \
--concatenate
make
make install
cd ..
}

check_qtwebkit() {
# Test if PyQt4.QtWebKit is installed and works
python -c 'from PyQt4 import QtWebKit' && \
echo ">>> Installation success!" && \
return

echo ">>> Installation failed."
return 1
}

check_install() {
# Check PyQt4.QtWebKit installation inside its virtualenv
setup_venv --no-install
check_qtwebkit
}

remove_tmp() {
# Delete downloaded files and extracted folders on successful installation
rm -rf PyQt4_gpl_x11-4.12* sip-4.19*
}

main() {
# Launch operations
[ $# -eq 1 ] && \
VENV="$1"

check_install && \
return

setup_venv
install_sip
install_pyqt4
check_qtwebkit && \
remove_tmp
}

main "$@"

0 comments on commit 2522f2e

Please sign in to comment.