Running pip from within FreeCAD

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Running pip from within FreeCAD

Post by sgrogan »

chennes wrote: Fri Jan 14, 2022 6:07 pm Any obvious additions I should make?
Some to consider?
matplotlib - FEM WB
ply - OpenSCAD WB
pycollada - Open SCAD WB
"fight the good fight"
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Running pip from within FreeCAD

Post by chennes »

sgrogan wrote: Sat Jan 15, 2022 3:53 pm
chennes wrote: Fri Jan 14, 2022 6:07 pm Any obvious additions I should make?
Some to consider?
matplotlib - FEM WB
ply - OpenSCAD WB
pycollada - Open SCAD WB
To support this we'd have to have a "meta" Workbench whose only job was to supply dependencies -- right now the built-in WBs don't talk to the Addon Manager (though I guess we could add that sort of communication... I had never considered it before).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Running pip from within FreeCAD

Post by sgrogan »

chennes wrote: Sat Jan 15, 2022 3:56 pm To support this we'd have to have a "meta" Workbench whose only job was to supply dependencies -- right now the built-in WBs don't talk to the Addon Manager (though I guess we could add that sort of communication... I had never considered it before).
I don't know if its necessary.
These are already runtime dependencies, or at least add functionality if present.
It wouldn't be unreasonable for the Add-on developer to assume they are available. By this argument maybe numpy should be removed from the list?
"fight the good fight"
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Running pip from within FreeCAD

Post by chennes »

I think numpy is optional, in that it's only required by some workbenches, so if you compile without them it may be missing.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Running pip from within FreeCAD

Post by sgrogan »

chennes wrote: Sat Jan 15, 2022 4:43 pm I think numpy is optional, in that it's only required by some workbenches, so if you compile without them it may be missing.
This is true. But for a long time we have pulled in numpy because it is a dependency of matplotlib.
See for example the Debian Control file https://salsa.debian.org/science-team/f ... ontrol#L54

I would say the default runtime dependencies are those required when compiling the default workbenches in CMake.
This isn't definitive though. Sometimes the feature is "greyed out", sometimes an error is thrown if the package isn't present.

Technically PySide2 is optional. We certainly don't want users installing the present PYPI PySide2 package.

I'm just starting to test, so all my observations are preliminary.
"fight the good fight"
nic
Posts: 135
Joined: Thu Apr 18, 2019 1:14 pm
Location: France

Re: Running pip from within FreeCAD

Post by nic »

it's a workbench I'm currently developing. Sure they will go to requirements file. But will it be enough to pass through the "allowed" official whitelist? Maybe I missed something in the process you set up, but I thought that any package out of this official list would be blocked...

[edit] this post was an answer to:
chennes wrote: Sat Jan 15, 2022 3:16 pm Which workbench are you using these in? Can you add them to a requirements.txt file when you have a moment?
Last edited by nic on Sun Jan 16, 2022 7:44 am, edited 1 time in total.
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Running pip from within FreeCAD

Post by chennes »

Yes, they need to be added to this Allowed file, as well as be in a requirements.txt file.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Running pip from within FreeCAD

Post by sgrogan »

chennes wrote: Sat Jan 15, 2022 4:43 pm I think numpy is optional, in that it's only required by some workbenches, so if you compile without them it may be missing.
What is a good add-on to test? One that has a good requirements.txt file.
"fight the good fight"
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Running pip from within FreeCAD

Post by keithsloan52 »

chennes wrote: Fri Jan 14, 2022 6:07 pm For the initial allowed list of Python packages, I've got:

Code: Select all

ezdxf
markdown
numpy
olefile
pillow
pygit2
requests
scipy
xlrd
xlutils
xlwt
PyYAML
That covers all of the packages that are currently specified in metadata files in "official" addons. I would guess there are also dependencies out there that are not yet set in a metadata file, but I have no way of knowing what those are. Any objections to this initial list? Any obvious additions I should make?
ImportNURBS uses rhino3dm
GDML uses gmsh ( python library) and lxml
user1234
Veteran
Posts: 3337
Joined: Mon Jul 11, 2016 5:08 pm

Re: Running pip from within FreeCAD

Post by user1234 »

onekk wrote: Fri Jan 07, 2022 8:33 am A side note pip is not very "integrated" in many distribution, as example on Debian and Arch Linux this is not the recommended way to install packages, and sometimes pip supplied by the distribution is patched do avoid some operation.
+1

Whitelisted or not, FreeCAD must ask if if you want to run pip install. On Debian if have only troubles with pip. When python dependencies are needed, i install them from the apt-get, else it often does not work correctly in FreeCAD or other programs.

Greetings
user1234
Post Reply