From 326a3d7a434e8af8bf08db36b76c7ffbd64e07c1 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 2 Apr 2022 03:04:37 -0700 Subject: [PATCH] darwin: install a virtualenv inside git-cola.app Make git-cola.app more self-contained by including a private virtualenv inside the .app bundle. Related-to: #1053 Signed-off-by: David Aguilar --- Makefile | 24 +++++++++++++++--------- README.md | 43 ++++++++++++++----------------------------- contrib/darwin/git-cola | 13 +++++++++---- 3 files changed, 38 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index 1ebc3515..d191aee8 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ all:: # make V=1 # V=1 increases verbosity # make develop # pip install --editable . # make test [flags=...] # run tests; flags=-x fails fast, --ff failed first -# make test V=2 # V=2 increases test verbosity +# make test V=2 # run tests; V=2 increases test verbosity # make doc # build docs # make flake8 # python style checks # make pylint [color=1] # run pylint; color=1 colorizes output @@ -27,10 +27,6 @@ all:: # make prefix= install # DESTDIR is also supported. # -# To disable distutil's replacement of "#!/usr/bin/env python" with -# the path to the build environment's python, pass USE_ENV_PYTHON=1 -# when invoking make. -# # The external commands used by this Makefile are... BLACK = black CP = cp @@ -43,6 +39,7 @@ MSGMERGE = msgmerge MKDIR_P = mkdir -p PIP = pip PYTHON ?= python +PYTHON3 ?= python3 PYLINT = $(PYTHON) -B -m pylint PYTEST = $(PYTHON) -B -m pytest RM = rm -f @@ -97,6 +94,7 @@ pythondir = $(prefix)/lib/$(python_lib) cola_base := git-cola cola_app_base= $(cola_base).app cola_app = $(CURDIR)/$(cola_app_base) +cola_app_resources = $(cola_app)/Contents/Resources # Read $(VERSION) from cola/_version.py and strip quotes. include cola/_version.py @@ -232,15 +230,23 @@ po:: \ done +# Build a git-cola.app bundle. .PHONY: git-cola.app git-cola.app:: $(MKDIR_P) $(cola_app)/Contents/MacOS - $(MKDIR_P) $(cola_app)/Contents/Resources - $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \ - $(cola_app)/Contents + $(MKDIR_P) $(cola_app_resources) + $(PYTHON3) -m venv $(cola_app_resources) + $(cola_app_resources)/bin/pip install --requirement requirements/requirements.txt + $(cola_app_resources)/bin/pip install --requirement requirements/requirements-optional.txt + $(cola_app_resources)/bin/pip install --requirement requirements/requirements-dev.txt + + $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo $(cola_app)/Contents $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources - $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc + $(MAKE) PIP=$(cola_app_resources)/bin/pip \ + prefix=$(cola_app_resources) install + $(MAKE) SPHINXBUILD=$(cola_app_resources)/bin/sphinx-build \ + prefix=$(cola_app_resources) install-doc .PHONY: app-tarball app-tarball:: git-cola.app diff --git a/README.md b/README.md index e68743d8..0ff8db6d 100644 --- a/README.md +++ b/README.md @@ -158,46 +158,30 @@ but it has not been updated for a while. # build from source cd /usr/ports/devel/git-cola && make clean install -## macOS - -[Homebrew](https://brew.sh/) is the easiest way to install -Git Cola's PyQt5 dependencies. We will use Homebrew to install -the git-cola recipe, but build our own .app bundle from source. -[Sphinx](http://sphinx-doc.org/latest/install.html) is used to build the -documentation. - - brew install sphinx-doc - brew install git-cola +## macOS -Once brew has installed `git-cola` you can: +You can install Git Cola using the same `Makefile` steps above to install from source. -1. Clone the git-cola repositroy +### git-cola.app - git clone https://github.com/git-cola/git-cola - cd git-cola +If you'd like to build a `git-cola.app` bundle for `/Applications` run this command: -2. Build the git-cola.app application bundle + make git-cola.app - make \ - PYTHON=$(brew --prefix python3)/bin/python3 \ - PYTHON_CONFIG=$(brew --prefix python3)/bin/python3-config \ - SPHINXBUILD=$(brew --prefix sphinx-doc)/bin/sphinx-build \ - git-cola.app +### Homebrew -3. Copy it to /Applications +An easy way to install Git Cola is to use [Homebrew](https://brew.sh/) . +Use Homebrew to install the git-cola recipe: - rsync -ar --delete git-cola.app/ /Applications/git-cola.app/ + brew install git-cola -Newer versions of Homebrew install their own `python3` installation and -provide the `PyQt5` modules for `python3` only. You have to use -`python3 ./bin/git-cola` when running from the source tree. +### Updating macOS and Homebrew -### Upgrading using Homebrew +Updating macOS can often break Homebrew-managed software. -If you upgrade using `brew` then it is recommended that you re-install -Git Colaa's dependencies when upgrading. Re-installing ensures that the -Python modules provided by Homebrew will be properly set up. +If you upgrade your macOS version and Git Cola no longer runs then then it is +recommended that you re-install Git Cola's dependencies after upgrading. A quick fix when upgrading to newer versions of XCode or macOS is to reinstall pyqt5. @@ -226,6 +210,7 @@ scratch using the instructions below should get things back in shape. # re-install git-cola and its dependencies brew install git-cola + ## Windows IMPORTANT If you have a 64-bit machine, install the 64-bit versions only. diff --git a/contrib/darwin/git-cola b/contrib/darwin/git-cola index fb91589b..8c90f839 100755 --- a/contrib/darwin/git-cola +++ b/contrib/darwin/git-cola @@ -1,10 +1,15 @@ #!/bin/sh -# Setup PATH for git-osx-installer and other common locations -PATH="$PATH":/usr/local/bin:/usr/local/git/bin -export PATH # $0 = Contents/MacOS/git-cola +# macos = Contents/MacOS macos="$(dirname "$0")" +# contents = Contents contents="$(dirname "$macos")" +# resources = Contents/Resources +resources="${contents}/Resources" + +# Setup PATH for git-osx-installer and other common locations +PATH="${resources}/bin:${PATH}:/usr/local/bin:/usr/local/git/bin" +export PATH -exec "$contents/Resources/bin/git-cola" --prompt +exec python "${contents}/Resources/bin/git-cola" --prompt -- 2.11.4.GIT