I get u'/usr/' instead of u'/usr/share/freecad/ witch is where the files belonging in HomePath is residing.
This problem is somewhat mitigated by the PKGBUILD script building and installing FreeCAD by the following sed command.
Code: Select all
prepare() {
sed -i \
-e "46i\\\tModDir = '/usr/share/freecad/Mod'" \
-e "50i\\\tLibDir = '/usr/lib/freecad'" \
"${srcdir}/freecad/src/App/FreeCADInit.py"
This seams to fix the problem for Mod and Lib folders, but anything else that relies on FreeCAD.getHomePath() in other ways fails.
One example is PartDesign:Involutegear this fails with:
Code: Select all
Traceback (most recent call last):
File "/usr/share/freecad/Mod/PartDesign/InvoluteGearFeature.py", line 114, in setEdit
taskd = _InvoluteGearTaskPanel(self.Object,mode)
File "/usr/share/freecad/Mod/PartDesign/InvoluteGearFeature.py", line 136, in __init__
self.form=FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/PartDesign/InvoluteGearFeature.ui")
File "<string>", line 4, in <module>
<type 'exceptions.RuntimeError'>: Cannot open file
Running the Python command 'PartDesign_InvoluteGear' failed:
Traceback (most recent call last):
File "/usr/share/freecad/Mod/PartDesign/InvoluteGearFeature.py", line 59, in Activated
FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name,0)")
File "<string>", line 1, in <module>
Failed to set object 'InvoluteGear' in edit modeActive view is Unnamed : 1[*] (at 0x349d640)
Searching for where FreeCAD.getHomePath() gets it information :
Code: Select all
void Application::initConfig(int argc, char ** argv)
{
// find the home path....
mConfig["AppHomePath"] = FindHomePath(argv[0]);
Code: Select all
const char* Application::getHomePath(void) const
{
return _mConfig["AppHomePath"].c_str();
}
Code: Select all
std::string Application::FindHomePath(const char* sCall)
{
// We have three ways to start this application either use one of the both executables or
// import the FreeCAD.so module from a running Python session. In the latter case the
// Python interpreter is already initialized.
std::string absPath;
std::string homePath;
if (Py_IsInitialized()) {
// Note: realpath is known to cause a buffer overflow because it
// expands the given path to an absolute path of unknown length.
// Even setting PATH_MAX does not necessarily solve the problem
// for sure but the risk of overflow is rather small.
char resolved[PATH_MAX];
char* path = realpath(sCall, resolved);
if (path)
absPath = path;
}
else {
// Find the path of the executable. Theoretically, there could occur a
// race condition when using readlink, but we only use this method to
// get the absolute path of the executable to compute the actual home
// path. In the worst case we simply get q wrong path and FreeCAD is not
// able to load its modules.
char resolved[PATH_MAX];
int nchars = readlink("/proc/self/exe", resolved, PATH_MAX);
if (nchars < 0 || nchars >= PATH_MAX)
throw Base::Exception("Cannot determine the absolute path of the executable");
resolved[nchars] = '\0'; // enfore null termination
absPath = resolved;
}
// should be an absolute path now
std::string::size_type pos = absPath.find_last_of("/");
homePath.assign(absPath,0,pos);
pos = homePath.find_last_of("/");
homePath.assign(homePath,0,pos+1);
return homePath;
}
If anyone could see some way this could be made better, I will bring it to the Aur FreeCAD maintainer.