System-wide addon install

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
SIXe
Posts: 158
Joined: Sat Mar 16, 2019 3:10 pm

System-wide addon install

Post by SIXe »

Hi,

when using the AppImage the addons installed by the user are stored in $HOME/.FreeCAD/Mod. But how to install addons system-wide? I've tried /usr/local/share/freecad/Mod, but the modules are not recognised when placed there.

Is there a way to install addons once so they're available to *all* users when using the AppImage? If so, how?

Code: Select all

OS: Debian GNU/Linux bullseye/sid (X-Cinnamon/lightdm-xsession)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22522 (Git) AppImage
Build type: Release
Branch: master
Hash: d8e476ef428017900dfe0f9359ba448503c216f9
Python version: 3.8.5
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United Kingdom (en_GB)
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: System-wide addon install

Post by vocx »

SIXe wrote: Fri Oct 02, 2020 10:36 am when using the AppImage the addons installed by the user are stored in $HOME/.FreeCAD/Mod. But how to install addons system-wide? I've tried /usr/local/share/freecad/Mod, but the modules are not recognised when placed there.
FreeCAD looks for modules in two paths,

Code: Select all

>>> App.getResourceDir()
'/usr/share/freecad-daily/'

>>> App.getUserAppDataDir()
'/home/vocx/.FreeCAD/'
So you should place the new modules in /usr/share/freecad/Mod. The directory /usr/local is not searched, unless you compile FreeCAD yourself, and install there.

However, since you are using an AppImage, this directory is probably packed inside the AppImage. What you should do is unpack the AppImage, add the modules that you want inside the structure, and then repackage the AppImage. This is shown in AppImage.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
SIXe
Posts: 158
Joined: Sat Mar 16, 2019 3:10 pm

Re: System-wide addon install

Post by SIXe »

Thank you for the response.
vocx wrote: Sun Oct 04, 2020 2:49 pm So you should place the new modules in /usr/share/freecad/Mod.
This seems not to work. However, if placed in the AppImage /usr/Mod they are being picked up.

But I get a warning when FreeCAD is started (regardless of which addon is installed):

Code: Select all

/tmp/.mount_FreeCAGLzChr/usr/lib/python3.8/site-packages/mpmath/ctx_mp_python.py:892: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if other is 0:
/tmp/.mount_FreeCAGLzChr/usr/lib/python3.8/site-packages/mpmath/ctx_mp_python.py:986: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if other is 0:
Since I don't get this message when the modules are installed in $HOME/.FreeCAD/Mod, I assume something is not right.
vocx wrote: Sun Oct 04, 2020 2:49 pm The directory /usr/local is not searched, unless you compile FreeCAD yourself, and install there.
Which is very unfortunate. It would make for a much simpler global addon installation.
vocx wrote: Sun Oct 04, 2020 2:49 pm However, since you are using an AppImage, this directory is probably packed inside the AppImage. What you should do is unpack the AppImage, add the modules that you want inside the structure, and then repackage the AppImage. This is shown in AppImage.
That's quite an involved process and has to be done anew for every FreeCAD upgrade. Therefore I wrote a short script to do the task, which I tried to attach to this post, but the forum won't let me and throws an error (Invalid file extension) for whatever reason, so I'll post it inline below. But as I mentioned above, it throws a warning when FC launches, so there's an issue somewhere.

Code: Select all

#!/bin/sh

################
#
# Extracts the FreeCAD AppImage and loads a selection of addons into the
# AppImage. Then it repackages the AppImage so the modules are available
# out-of-the-box.
#
# Note: After this action the AppImage cannot be updated using regular methods
# any longer.
#
# Usage: freecad-add-addons <file>
#
################

# exit on error
set -e

if [ "$#" -lt 1 ]; then
  printf 'Error: not enough arguments provided.\n'
  printf '%s %s %s\n\n' 'Usage:' "$0" '<file>'
  exit 98
fi

# list of additional addons to include in the AppImage
addons='https://github.com/Zolko-123/FreeCAD_Assembly4.git Assembly4'
addons="$addons;https://github.com/boltsparts/BOLTSFC.git BOLTSFC"
addons="$addons;https://github.com/shaise/FreeCAD_FastenersWB Fasteners"

freecad_appimage="$PWD/$1"
freecad_appimage_new="${freecad_appimage%.AppImage}-addons.AppImage"

# we need the internet
nc -z -w 2 github.com 80 2>/dev/null || exit 97

# clean up after yourself
temp_dir=$(mktemp --directory --tmpdir=/dev/shm)
trap 'rm -rf "$temp_dir"' EXIT INT TERM

# unpacking
cd "$temp_dir"
"$freecad_appimage" --appimage-extract

# install addons
cd squashfs-root/usr/Mod
printf '%s\n' "$addons" | tr ';' '\n' | while read -r addon; do
  url="$(printf  '%s\n' "$addon" | cut -d' ' -f 1)"
  name="$(printf '%s\n' "$addon" | cut -d' ' -f 2)"
  git clone --depth=1 "$url" "$name"
done
cd ../../..

# fetch required tools
wget 'https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage'
appimagetool='./appimagetool-x86_64.AppImage'
chmod +x "$appimagetool"

# repacking
"$appimagetool" squashfs-root "$freecad_appimage_new"

exit 0
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: System-wide addon install

Post by sgrogan »

SIXe wrote: Thu Oct 08, 2020 11:21 am But I get a warning when FreeCAD is started (regardless of which addon is installed):
See here: https://forum.freecadweb.org/viewtopic. ... d217f4e2a3
"fight the good fight"
SIXe
Posts: 158
Joined: Sat Mar 16, 2019 3:10 pm

Re: System-wide addon install

Post by SIXe »

Thanks, then I'll ignore the warning for now.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: System-wide addon install

Post by vocx »

SIXe wrote: Thu Oct 08, 2020 11:21 am
vocx wrote: Sun Oct 04, 2020 2:49 pm So you should place the new modules in /usr/share/freecad/Mod.
This seems not to work. However, if placed in the AppImage /usr/Mod they are being picked up.
I wrote the wrong path. For some reason, FreeCAD calls its root directory "home", which is a bit confusing.

Code: Select all

>>> App.getHomePath()
'/usr/lib/freecad-daily/'
So you have to use /usr/lib/freecad-daily/Mod.

But as I said, since you are using the AppImage, you need to consider the correct path inside the AppImage.

And the syntax warning is just that, a syntax warning; it has nothing to do with FreeCAD. It's some issue about about the numpy version packaged with the AppImage.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Post Reply