[SOLVED] Portable FreeCAD(user.cfg, system.cfg and Addon Manager)

Having trouble installing or compiling FreeCAD? Get help here.
Smiling_user
Posts: 191
Joined: Tue Jul 28, 2020 7:31 am

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

CHANGES MADE in the AddonManager:
getUserAppDataDir -> FreeCAD.getHomePath
Mod -> ModM -> User-downloaded addons will be stored in the folder ModM

These changes are intended to make FC completely portable - in a single folder. Did similar changes several times.
Sometimes they worked normally and without interference with any other install - all was working in a single folder.
Once AddonManager worked perfectly - with all functionality (workbenches download, upgrade, review, use).
But without VCS/GIT I lost that version of code and did not yet recover.
Now working on linux - so further work in this direction is postponed. But if this is so important for you I may try some modifications again.
User avatar
sgrogan
Veteran
Posts: 6503
Joined: Wed Oct 22, 2014 5:02 pm

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by sgrogan »

Let's try to test what has been implemented.
I post a build here: https://github.com/sgrogan/FreeCAD/rele ... g/Portable
Always use the FreeCAD.bat file. Don't double click on a FreeCAD file as obviously the portable version will not write any thing to the registery and FreeCAD will use the file association in the registery.

I suggest extracting in the Downloads folder and testing.
Then move the folder to Documents to test portability.
I have no issues with normal preferences or Addons-manager.
The only issues I've seen is when setting a Path in preferences as it is hardcoded in user.cfg. For me the Macros directory suffers from this.
We can most likely overcome this by running a starter.py macro that writes the relative path as a hard coded path at each startup.

Please try to explain exactly what you did when you get an error. "It doesn't work sometimes" isn't going to advance the solution.

EDIT: And if this isn't solved, please remove this from the OP
"fight the good fight"
Smiling_user
Posts: 191
Joined: Tue Jul 28, 2020 7:31 am

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

// First to mention - I did not use the *.bat


In general modifying the code of AddonManager code there were next issues:
  • Addon manager item disappears from Tools-menu
  • Does not start
  • Starts, but no plugins downloaded nor installed plugins shown // copy-paste to Mod - installed plugins are available.
  • Starts, downloads list of plugins, but does not highlight installed. // copy-paste to Mod - installed plugins are available.
The last version ( in the pack)
  • Starts, downloads, highlights and updates plugins in FreeCad-0.19_pre//ModM (Custom folder).
BUT! Installed plugins are not available in workbenches list not in the WB-selection, no in the Tools>Customize.

The wished functionality of AddonManager would be at first to have it reading the Mod-path from user.cfg.
This would also ease development: possible to easily change combinations of WB-s installed.
Also this is needed for the case, to use some not updated(Py2) add-ons with previous versions of FC.
example: 0.17 - on the same machine.
In the dreaming-case would be to have ModPy2 directory, ModPy3 and ModPyNeutral directories and use some addons with both versions, and some - separately, having AddonManager to take more than one path from user.cfg.
Smiling_user
Posts: 191
Joined: Tue Jul 28, 2020 7:31 am

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

sgrogan wrote: Fri Sep 11, 2020 8:51 pm EDIT: And if this isn't solved, please remove this from the OP
Did I understand you right - to change the heading of the topic? Or you meant the files pack with incomplete AddonManager change?

How deep are changes to the code in your portable version?
Will try this pack as soon as start windows again.

// Installed docker+VSCode - now going to install FC source-code. If any recommendations...
User avatar
sgrogan
Veteran
Posts: 6503
Joined: Wed Oct 22, 2014 5:02 pm

Re: Portable FreeCAD(user.cfg, system.cfg and Addon Manager)

Post by sgrogan »

Smiling_user wrote: Fri Sep 11, 2020 11:08 pm Did I understand you right - to change the heading of the topic?
Yes, thank-you.
Smiling_user wrote: Fri Sep 11, 2020 11:08 pm How deep are changes to the code in your portable version?
There are no changes to the FreeCAD Source. I simply use a .bat file to set some env-variables as suggested by wmayer (his name is on the splash screen we should heed his advice).

If you just want an isolated version of FreeCAD on a machine, I cannot find anything that does not work.
If the version is to be seemlessly portable the hardcoded paths in user.cfg needs to be addressed. This is to be expected. These paths are user setable so FreeCAD must respect the absolute path.

On Linux this will be more difficult as FreeCAD uses system libraries for the dependencies. This can probably be overcome using the .AppImage.
"fight the good fight"
User avatar
sgrogan
Veteran
Posts: 6503
Joined: Wed Oct 22, 2014 5:02 pm

Re: Portable FreeCAD(user.cfg, system.cfg and Addon Manager)

Post by sgrogan »

Smiling_user wrote: Fri Sep 11, 2020 11:08 pm // Installed docker+VSCode - now going to install FC source-code. If any recommendations...
The directions here are excellent: Compile_on_Windows

I use the following tool chain.
git (source version control), CMake (Build system), VS2019 CE (IDE, linker, compiler), FreeCADLibs_12.1.4_x64_VC15.7z (FreeCAD Dependencies)
I use 7zip (file compression extraction) and Notepad++ (text editor)

I typically use the latest versions of the toolchain, but if you want a more bullet-proof process follow the version recommendations and instructions from Compile_on_Windows exactly.
"fight the good fight"
Smiling_user
Posts: 191
Joined: Tue Jul 28, 2020 7:31 am

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

sgrogan wrote: Fri Sep 11, 2020 8:51 pm Let's try to test what has been implemented. I post a build here: https://github.com/sgrogan/FreeCAD/rele ... g/Portable
Tried to use your version. something did not work for me in the downloaded.
But!! The FreeCad.bat worked well!!. The only thing - made little change to place it alongside the "bin" folder.

And now it looks like FreeCad.bat:

Code: Select all

set CURRENTDIR=%cd%
set FREECAD_USER_HOME=%CURRENTDIR%
start bin\FreeCAD.exe --write-log
This file will be attached to the header post of topic.
chrisb
Veteran
Posts: 43729
Joined: Tue Mar 17, 2015 9:14 am

Re: [SOLVED] Portable FreeCAD(user.cfg, system.cfg and Addon Manager)

Post by chrisb »

This topic is not quite current, but to keep the information in one place I add here how to setup a portable call of FreeCAD on MacOS.
Making FreeCAD store all config data and addons below this config folder needs three small steps:

Step 1: Setup the folder structure. If the config folder is not found, then FreeCAD falls back to the defaults. If the required subdirectories are missing, it doesn't start, so you have to create the required subdirs.
This step has to be done only once.

Step 2: Set the environment variable FREECAD_USER_HOME

Step 3: Call FreeCAD

Let's assume you already have a folder ~/modeling/config, and now you want to keep your config stuff in a subfolder of this called config. Let's further assume you have installed FreeCAD in the /Applications folder. Execute the following commands in a terminal:

Code: Select all

# Step 1, to be executed only once:
cd ~/modeling
mkdir config
mkdir config/Library
mkdir config/Library/Preferences

# Step 2:
export FREECAD_USER_HOME=~/modeling/config

# Step 3:
open /Applications/FreeCAD.app

# Step 3, alternate take, if you want to start a new instance of FreeCAD in case you have another one already running:
/Applications/FreeCAD.app/Contents/MacOS/FreeCAD
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Smiling_user
Posts: 191
Joined: Tue Jul 28, 2020 7:31 am

Re: [SOLVED] Portable FreeCAD(user.cfg, system.cfg and Addon Manager)

Post by Smiling_user »

Congratulations about the FC 0.20
After a longer delay in using the FC, ran again in a similar problem:
How to use the same folder containing Addons and Macros from different FC versions/installations.
With the FreeCAD_Start.bat, which is figured out in this topic (gratefuliness to all participants), it is made possible to keep FC inside a single folder, which is GREAT.... BUT
The FC-home folder is 14.64Gb, the "FC-home//MOD" folder is 13.45 Gb now.
Mainly on the count of parts_library (~12GB) and DesignSPHysics (~500Mb)
So keeping a separate folder for each FC Install is not convenient and not always possible.
Yes there was a solution to setup the part_library folder separately (minus 12 gigs) But still....
More of this, the PC is in dual boot (Win and Linux) - so I'd prefer to use the same FC-Home for both.
And also - to sometimes move-copy-share the installation.
So there is a need to be able to easily setup folder paths, and they should be possible also as relative (../../FC0.20/bin/freecad.exe), not only fixed.
After a delay in using FC - got back and feel that some tricks are forgotten, so "tricks" as un-obvious thing are not the solution.

It seems to me, that for the future ease of use and settings, there should be possible to setup paths to all important folders with a intuitively predictable procedure.
for the simplicity it seems to be one of the following:
1) FC_Start*.bat + FC_Start*.ini( or FC_Start*.cfg) + system*.cfg+user*.cfg
- the most flexible solution: it is easy to keep several packs (like *1.bat, *2.bat...) to run same install with different settings.
FC_Start*.bat: sets the %home_Folder%, %ConfigFolder%, %AddonsFolder%,
FC_Start*.ini( or FC_Start*.cfg) - if present - overrides default Path settings of the program
system*.cfg+user*.cfg - same as now
2) FC>Tools>Edit Parameters - create keys with default values, editable by user, and direct this to a separate file (*.ini or *.cfg)
So that several files can be set for booting from FreeCAD_Start.BAT.
And then make it possible to select the config file for the next boot.
3) In Edit >Preferences>AddonManager - make an option to select the path to Mod folder (May be the easiest solution, but not for experiments with different folders and settings)
4) prepare possibility to store all settings in a separate "config" folder, where for each big block of FC there will be a separate configuration file
for example: for main FC program, for AddonManager, for Python engine... // maybe through the solution 1: FC_start.bat // FC_start.sh which will define the working config folder.
Then just changing the current config folder will bring a new experience in FC usage.

The first solution would be easy for Windows. But the second would be cross-platform, and more professional/conventional.

As far as I understand, to accomplish this - some changes must be done in the very core core of FC. Right?

For the second solution, there should be one change prepared (especially for AppImage version):
In the case of:
var_firstboot == true
OR var_ask_settings_on_restart == true;
OR fExists( FC*#.ini or FC*#.cfg")== false //these files should be just next to *.AppImage file, or next to FC_Start.BAT, and should be the same
{ ask_for_the_settings_File()}


Grateful in advance.
Post Reply