How to install the tortoisehg in Ubuntu20.04
Update: I now do have a working package. It is available on github:
https://github.com/glaure/tortoisehg4ubuntu
Please give feedback!
Old:
I do not have a working package or snap. But using these instructions, it is rather easy to get tortoisehg
working from source.
-
Check that
python --version
returns a Python 3 interpreter. If not, you have to change the symlink/usr/bin/python
to/usr/bin/python3
.OK:
$ python --version Python 3.8.2
Not OK:
$ python --version Python 2.7.18rc1
Change the symlink:
$ sudo rm /usr/bin/python $ sudo ln -s /usr/bin/python3 /usr/bin/python
-
pip3
is needed to fulfill all the build dependencies.sudo apt install python3-pip build-essential
-
Clone tortoisehg repository.
hg clone https://foss.heptapod.net/mercurial/tortoisehg/thg
-
Change into
thg
directory.cd thg
-
Install PyQt5.
pip3 install pyqt5
-
Install
mercurial
.pip3 install mercurial
-
Install
Qscintilla
.pip3 install qscintilla sudo apt install pyqt5.qsci-dev
-
Lets build
tortoisehg
for inplace usage.make local
-
Start
tortoisehg
../thg
I got tortoisehg
working on three different Ubuntu 20.04 installations using this recipe.
Update: https://github.com/glaure/tortoisehg4ubuntu
Contains scripts for automating the tasks listed above..
When I tried to do the flow suggested by Gunter something went wrong and I got an error:
No module named 'PyQt5.Qsci'
None of the installation options proposed previously here worked.
I managed to eliminate it by running
sudo apt-get install python3-pyqt5.qsci
For those running Ubuntu 20.04 on Windows Subsystem for Linux 2. Assuming you installed and launched an X Server on Windows (e.g. Vcxsrv), on Ubuntu do the following:
- Configure the
DISPLAY
environment variable in~/.bashrc
IP=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}')
export DISPLAY=$IP:0.0
- Compile TortoiseHg
sudo apt install mercurial python3-pip build-essential pyqt5.qsci-dev
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo ln -s /usr/bin/pip3 /usr/bin/pip
pip install pyqt5 mercurial qscintilla iniparse
sudo apt install libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxkbcommon-x11-0
hg clone https://foss.heptapod.net/mercurial/tortoisehg/thg
cd thg
make local
You may want to install WSL Windows Toolbar Launcher to launch TortoiseHg from Windows. In this case, create the file /usr/share/applications/tortoisehg.desktop
[Desktop Entry]
Name=TortoiseHg
Exec=/path/to/thg_repo/thg
Type=Application
Terminal=false
Categories=GNOME;GTK;Mercurial;Development
Icon=/path/to/thg_repo/icons/thg_logo.ico
Apart from confirming that the steps described by Gunther work well, I want to add that you also need to install iniparse
to ensure TortoiseHg work properly. It needs iniparse
to parse and update the Mercurial configuration.
Either
sudo apt-get install python3-iniparse
or
pip3 install iniparse
Also, if you want to make TortoiseHg available as desktop application from menu or so, you can first copy thg
into /usr/bin
or /usr/local/bin
. You must also copy the Python module tortoisehg
inside the directory where you built TortoiseHg to one of the paths in PYTHONPATH
(PYTHONPATH is the path where Python searches for module files). Otherwise, TortoiseHg won't start with the following error.
$ thg
No module named 'tortoisehg'
abort: couldn't find tortoisehg libraries in [/usr/bin:/usr/lib/python38.zip:/usr/lib/python3.8:/usr/lib/python3.8/lib-dynload:/home/xxx/.local/lib/python3.8/site-packages:/usr/local/lib/python3.8/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.8/dist-packages]
You can do:
sudo cp -R tortoisehg /usr/local/lib/python3.8/dist-packages
Then add a file ~/.local/share/applications/thg.desktop
(for current user) or /usr/share/applications/thg.desktop
(for system-wide usage).
[Desktop Entry]
Name=TortoiseHg
Exec=/usr/bin/thg
Type=Application
Terminal=false
Categories=GNOME;GTK;Mercurial;Development
Update to set the Exec
to the correct path of thg
.
Also see: https://foss.heptapod.net/mercurial/tortoisehg/thg/-/wikis/developers/Linux
I decided to do this all with tortoisehg in a virtualenv. So here is a guide to do it that way, along with the desktop file. This is very much based on the guide in the earlier answer, with some bits and pieces from other answers to this question.
First install the required packages using apt:
sudo apt install python3-pip python3-venv build-essential pyqt5.qsci-dev
Then create your virtualenv and start using it:
python3 -m venv ~/.venv/thg
source ~/.venv/thg/bin/activate
(You can create your virtualenv where ever you want.)
Install packages into the virtualenv:
pip install pyqt5 mercurial==5.4 qscintilla iniparse
Note I have pinned mercurial at 5.4 because at the time of writing tortoisehg does not work with 5.5
Then we can clone the thg repository and build it:
hg clone https://foss.heptapod.net/mercurial/tortoisehg/thg
cd thg
make local
At this point we can run it directly
./thg
Or we can run it from anywhere, without activating the virtualenv, by using the python from the virtualenv. You could type the following at the command line, or put it in a shell script, say in ~/bin/
$HOME/.venv/thg/bin/python path/to/thg/thg
If you want to launch it as a desktop app you can put the following in a file at either ~/.local/share/applications/tortoisehg.desktop
(just for your user) or at /usr/share/applications/tortoisehg.desktop
(for all users of the system).
[Desktop Entry]
Name=TortoiseHg
Exec=/home/youruser/.venv/thg/bin/python /home/youruser/path/to/thg/thg
Type=Application
Terminal=false
Categories=GNOME;GTK;Mercurial;Development
Icon=/home/youruser/path/to/thg/icons/thg_logo.ico
Obviously update the paths on the Exec=
and Icon=
lines to match your actual path.