gaphor/venv

89 lines
2.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
#
# An easy way to set up a virtualenv.
#
# Source this file to work inside this venv:
#
# source ./venv [-f]
#
# Call `./venv -f` to force a new development installation.
#
(
# Do the whole installation process in a sub-shell, so we can safely fail when
# this file is sourced in the parent shell.
set -euo pipefail
check() {
echo Checking: $@
$@ >/dev/null 2>&1
}
NO_FORCE_INSTALL=true
while getopts 'fh' OPTION
do
case "$OPTION" in
f)
NO_FORCE_INSTALL=false
;;
esac
done
# If on Macos with brew, make sure we can find the brewed libffi (which is not "linked"):
check brew --version && {
libffi_path="$(brew ls libffi | grep pkgconfig | xargs dirname)"
echo "Adding libffi pkg-config path ${libffi_path} to \$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="${libffi_path}:${PKG_CONFIG_PATH:-}"
}
check python3 --version || {
echo "==> Python 3.x not found"
exit 1
}
check pkg-config --print-errors --exists 'gobject-introspection-1.0 >= 1.46.0' || {
echo "==> GObject-Introspection not found, Please check above errors and correct them"
exit 1
}
PYTHON_VER="$(python3 --version | sed 's/^Python \([0-9]\.[0-9]\).[0-9]$/\1/')"
test -d .venv || {
echo "Setting up a virtual env for Gaphor..."
python3 -m venv --prompt Gaphor .venv
}
source .venv/bin/activate
{ ${NO_FORCE_INSTALL} && test -f .venv/lib/python${PYTHON_VER}/site-packages/gaphor.egg-link; } || {
echo "Installing Gaphor in the virtualenv..."
Update dependencies and add Briefcase to lockfile Signed-off-by: Dan Yeaw <dan@yeaw.me> Move xvfb to services, remove deployment for testing Signed-off-by: Dan Yeaw <dan@yeaw.me> Brew install Python3, osx only has 2.7 Signed-off-by: Dan Yeaw <dan@yeaw.me> Set macOS language to generic to prevent downloading Python Signed-off-by: Dan Yeaw <dan@yeaw.me> Break commands over multiple lines properly Signed-off-by: Dan Yeaw <dan@yeaw.me> Services are not support in Travis for macOS Signed-off-by: Dan Yeaw <dan@yeaw.me> Linux has no xvfb start command Signed-off-by: Dan Yeaw <dan@yeaw.me> Upgrade python instead of installing it Signed-off-by: Dan Yeaw <dan@yeaw.me> Use pip3 command to get Python3 in macOS Signed-off-by: Dan Yeaw <dan@yeaw.me> Add libffi as a brew install dependency Signed-off-by: Dan Yeaw <dan@yeaw.me> Run venv to install libffi Signed-off-by: Dan Yeaw <dan@yeaw.me> Fix xvfb command in macOS Signed-off-by: Dan Yeaw <dan@yeaw.me> Change Xvfb command again Signed-off-by: Dan Yeaw <dan@yeaw.me> Move display to env variable Signed-off-by: Dan Yeaw <dan@yeaw.me> Fix .local/share doesn't exist in macOS, bad apt-get command in Linux Signed-off-by: Dan Yeaw <dan@yeaw.me> Don't force poetry installation location Signed-off-by: Dan Yeaw <dan@yeaw.me> Let venv script install and run poetry Signed-off-by: Dan Yeaw <dan@yeaw.me> Cache homebrew and run poetry as a module Signed-off-by: Dan Yeaw <dan@yeaw.me> Fix poetry isn't found Signed-off-by: Dan Yeaw <dan@yeaw.me> Try building macos using Briefcase Signed-off-by: Dan Yeaw <dan@yeaw.me> Add libffi to PKG_CONFIG_PATH manually Signed-off-by: Dan Yeaw <dan@yeaw.me> Fix gaphor icns not found Signed-off-by: Dan Yeaw <dan@yeaw.me> Add the gaphor icon Signed-off-by: Dan Yeaw <dan@yeaw.me> Add PyPI deployment, cleanup formatting Signed-off-by: Dan Yeaw <dan@yeaw.me>
2019-03-16 14:26:41 -04:00
pip --disable-pip-version-check install --upgrade poetry && poetry install
}
test_module() {
python3 -c "$1" 2>&- || {
echo "$2"
echo
echo "The Command used to test this:"
echo
echo " >>> $1"
echo
exit 1
}
}
test_module \
"import gi" \
"PyGobject3 (gobject-introspection) can not be loaded"
test_module \
"from gi.repository import Gtk" \
"Gtk3 is not installed in a way it can be loaded in Python"
test_module \
"import gaphor.UML" \
"Gaphor was not installed properly, that should not have happened. Please open an issue on GitHub"
) && source .venv/bin/activate