Python dependencies for FreeCAD Modules

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Python dependencies for FreeCAD Modules

Postby jreinhardt » Wed Jan 14, 2015 7:21 pm

Hi,

I am currently in the process of adapting some parts of BOLTS with the goal of eventually integrating BOLTS directly into FreeCAD. It would be very convenient for me to use some python dependencies (jsonschema for validation, constraining order for parameter resolution, pyyaml for parsing).

The good news is that these are all MIT licensed, so there should be no license problems.

But how problematic are dependencies for builds on the various platforms, and what is the best way to handle them? Or is it best to avoid them?
  • One could have a copy of the source in-tree. This is probably the most pragmatic way and would work for all platforms, but is kind of bloaty.
  • For linux one could handle some of these libraries by dependencies, but what about libraries that are not packaged for the distributions? Can one use pip or easyinstall somehow?
  • For Windows I guess they would go into the libpack?
  • How does that work for MacOS?
Thanks
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
drei
Posts: 479
Joined: Sun May 11, 2014 7:47 pm
Location: Mexico
Contact:

Re: Python dependencies for FreeCAD Modules

Postby drei » Thu Jan 15, 2015 12:16 am

How about adding it as a type of "workbench", set default to compile and search for the required libraries, allowing the user to specify the path for each?
Need help? Feel free to ask, but please read the guidelines first
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Python dependencies for FreeCAD Modules

Postby NormandC » Thu Jan 15, 2015 2:40 am

Hi,

python-jsonschema and python-yaml are packaged in Debian and Ubuntu.

constrainingorder is your own very new work, so obviously there is no package available. Not using readily packaged dependencies creates problems for FreeCAD packagers.
jreinhardt wrote:One could have a copy of the source in-tree. This is probably the most pragmatic way and would work for all platforms, but is kind of bloaty.
It would also go against Debian policy.
jreinhardt wrote:For linux one could handle some of these libraries by dependencies, but what about libraries that are not packaged for the distributions? Can one use pip or easyinstall somehow?
Just my own opinion but I would really prefer we not go that way. Basically it would mean that it would be unavailable to users who do not compile FreeCAD themselves.

I have never used pip nor easyinstall myself because I have never needed to. I wouldn't know where to start.

I guess I could try to package constrainingorder for our Ubuntu PPA, but Debian users and users of other Linux distros would be out of luck.
drei
Posts: 479
Joined: Sun May 11, 2014 7:47 pm
Location: Mexico
Contact:

Re: Python dependencies for FreeCAD Modules

Postby drei » Thu Jan 15, 2015 3:06 am

Comments according to OS:
LINUX
Within Debian or similar distros, could we reference them as external libraries? In Arch Linux each time you install a program the package manager scans the PKGBUILD to look for external dependencies that the user must install alongside the desired program.

Adding them within the code would add too much bloat.

I've no problem compiling the dependencies for my own use, but I don't know about the rest.

WINDOWS
The easiest path would be to add them to the Libpack.

MAC
I'm poor, I don have Mac. No idea how the system works.
Need help? Feel free to ask, but please read the guidelines first
peterl94
Posts: 1001
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Python dependencies for FreeCAD Modules

Postby peterl94 » Thu Jan 15, 2015 3:50 am

On OS X, every thing is bundled into the ".app" including the standard python library. For FreeCAD to find the python libraries they have to be in FreeCAD.app/Contents/lib/python2.7/site-packages, FreeCAD.app/Contents/bin or /Users/username/Library/Application Support/FreeCAD/Mod. However, for people that use Sam Nelson's homebrew recipe to install FreeCAD, instead of downloading the .app, they can use pip to install the python libraries.

I certainly don't mind adding the dependencies of BOLTS to the LibPack (and to my python install on OS X, so that they would be included in the .app). However, it doesn't solve the general issue of macro authors needing python modules that are not included with FreeCAD. I wonder if it would be a good idea to include setuptools or pip with the Windows and OS X builds so that users could install any python package that was required. I already have setuptools in the Libpack....