win: installation directory of FreeCAD.pyd

This subforum is specifically to discuss packaging issues on different platforms (windows, mac, linux), and using different packaging systems (conda, etc...)
Post Reply
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

win: installation directory of FreeCAD.pyd

Post by looo »

I wonder why FreeCAD.pyd is installed into "bin". I guess it should be installed into "lib" to be consistent with other platforms. I also assumed this here, which is currently failing on windows.
https://github.com/FreeCAD/FreeCAD/blob ... mplate#L15
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: win: installation directory of FreeCAD.pyd

Post by wmayer »

On Windows the handling is easier if FreeCAD.pyd is kept in the bin directory and it's very uncommon to have DLLs in the lib directory.

Also when starting the shipped python.exe you can directly import the FreeCAD module. If the file were somewhere else you would have to extend the Python search paths.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: win: installation directory of FreeCAD.pyd

Post by looo »

wmayer wrote: Mon May 18, 2020 12:52 pm On Windows the handling is easier if FreeCAD.pyd is kept in the bin directory and it's very uncommon to have DLLs in the lib directory.
I guess it's best to add a cmake-option to allow installing to lib instead of bin.
Also when starting the shipped python.exe you can directly import the FreeCAD module. If the file were somewhere else you would have to extend the Python search paths.
For conda-packages this is not the case. At least I cannot import FreeCAD from the python-interpreter without modifying sys.path. Not sure where python.exe is located. I will have a look the next time launching windows.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: win: installation directory of FreeCAD.pyd

Post by sgrogan »

looo wrote: Mon May 18, 2020 3:37 pm For conda-packages this is not the case. At least I cannot import FreeCAD from the python-interpreter without modifying sys.path. Not sure where python.exe is located. I will have a look the next time launching windows.
Inside a conda env the python.exe is located at Miniconda3/envs/<env-name>
The FreeCAD.exe and FreeCAD.pyd are located in Miniconda/envs/<env-name>/Library/bin

The trick to copying the stuff out of a conda env and making it portable is to copy all of the above to <bundle-name>/bin
Then starting python.exe and import FreeCAD works.
"fight the good fight"
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: win: installation directory of FreeCAD.pyd

Post by looo »

sgrogan wrote: Mon May 18, 2020 7:31 pm
looo wrote: Mon May 18, 2020 3:37 pm For conda-packages this is not the case. At least I cannot import FreeCAD from the python-interpreter without modifying sys.path. Not sure where python.exe is located. I will have a look the next time launching windows.
Inside a conda env the python.exe is located at Miniconda3/envs/<env-name>
The FreeCAD.exe and FreeCAD.pyd are located in Miniconda/envs/<env-name>/Library/bin

The trick to copying the stuff out of a conda env and making it portable is to copy all of the above to <bundle-name>/bin
Then starting python.exe and import FreeCAD works.
Hmm, I would like to have this as consistent as possible, and I prefer linux over windows in terms of consistencs. Anyway, I guess it's best to use the install location of the FreeCAD.pyd file as input for the freecad-python-interface (`import freecad`). So the question is: How to retrive the install directory of FreeCAD.pyd / FreeCAD.so platform independent with cmake?
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: win: installation directory of FreeCAD.pyd

Post by sgrogan »

wmayer wrote: Mon May 18, 2020 12:52 pm On Windows the handling is easier if FreeCAD.pyd is kept in the bin directory and it's very uncommon to have DLLs in the lib directory.

Also when starting the shipped python.exe you can directly import the FreeCAD module. If the file were somewhere else you would have to extend the Python search paths.
When running the INSTALL project the WB .pyd's are installed in lib. Moving FreeCAD.pyd and FreeCADGui.pyd to lib doesn't seem to cause a problem when running FreeCAD. Indeed when running FreeCAD's bundled python.exe, import FreeCAD doesn't work without modifying syspath.
looo wrote: Tue May 19, 2020 8:34 am Hmm, I would like to have this as consistent as possible, and I prefer linux over windows in terms of consistencs. Anyway, I guess it's best to use the install location of the FreeCAD.pyd file as input for the freecad-python-interface (`import freecad`). So the question is: How to retrive the install directory of FreeCAD.pyd / FreeCAD.so platform independent with cmake?
The issue is that on Win there is no package/dependency manager, an average Win user has multiple python versions installed, so FreeCAD must avoid all of these and use it's own. Maybe this offers a hint to find it https://github.com/FreeCAD/FreeCAD/blob ... s.txt#L303
"fight the good fight"
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: win: installation directory of FreeCAD.pyd

Post by looo »

Importing FreeCAD from python will never work perfectly on all plattforms. An abstraction layer is the easiest way to create something consistent. Anyway, I created a PR to adress this issue without touching the install dir of FreeCAd.pyd:
https://github.com/FreeCAD/FreeCAD/pull ... 55469b2ece
Post Reply