pip-integration in addon-manager

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pip-integration in addon-manager

Post by looo »

I also think it's not the best way to do it only for FreeCAD. I guess we should modify the path for python directly. Found this: https://stackoverflow.com/questions/114 ... tup-script . So we can add some content to python/site-packages/site-customize.py.

Maybe conda does all the path modification in the activation step...
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pip-integration in addon-manager

Post by looo »

tested, works:

simple add a file bin/lib/sitepackages/sitecustomize.py with this content:

Code: Select all

import os
import site
scripts_path = os.path.join(os.path.dirname(__file__), "..", "..", "Scripts") + ";"
scripts_path += os.path.join(site.USER_SITE, "..", "Scripts") + ";"
os.environ["PATH"] += scripts_path
and the problems for calling pip are gone.

edit: we also need to add the path to the user Scripts directory.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pip-integration in addon-manager

Post by looo »

feel free to try the pip integration tools. I added a description how to install with freecad console (assuming pip is directly available):
https://github.com/looooo/freecad_pipin ... on-console
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: pip-integration in addon-manager

Post by Kunda1 »

Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: pip-integration in addon-manager

Post by Kunda1 »

What can be installed via pip?

Code: Select all

OpenFOAM ?
Fenics ?
CalculiX X
Elmer X
Graphiz X
Gdal ✓
ezdxf ✓
opencv ?
cv2 ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: pip-integration in addon-manager

Post by sgrogan »

Kunda1 wrote: Fri Sep 21, 2018 9:46 pm What can be installed via pip?
PYPI packages
https://pypi.org/project/opencv-python/
Does this work with your AppImage?
"fight the good fight"
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: pip-integration in addon-manager

Post by Kunda1 »

I actually have some errors:
After following the instructions from https://github.com/looooo/freecad_pipin ... on-console I see the following in the Report window:

Code: Select all

Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007ff87cb71740 (most recent call first):
OS: "Manjaro Linux"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14784 (Git) AppImage
Build type: Release
Branch: master
Hash: ac21bcc35c56b360e03c646f5cfdcf15e5769717
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)

I guess I'm not running the Py3 with this appimage
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: pip-integration in addon-manager

Post by Kunda1 »

I actually have some errors:
After following the instructions from https://github.com/looooo/freecad_pipin ... on-console I see the following in the Report window:

Code: Select all

Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007ff87cb71740 (most recent call first):
OS: "Manjaro Linux"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14784 (Git) AppImage
Build type: Release
Branch: master
Hash: ac21bcc35c56b360e03c646f5cfdcf15e5769717
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)

I guess I'm not running the Py3 with this appimage
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pip-integration in addon-manager

Post by looo »

Kunda1 wrote: Fri Sep 21, 2018 11:21 pm I guess I'm not running the Py3 with this appimage
Mostlikely the py2 appimage has no pip included. So the system pip is called. And yes, I think it's best to make the pip-tools py3-only, as freecad with py2 on windows won't get pip support anyway.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: pip-integration in addon-manager

Post by sgrogan »

looo wrote: Sat Sep 22, 2018 5:39 am Mostlikely the py2 appimage has no pip included. So the system pip is called. And yes, I think it's best to make the pip-tools py3-only, as freecad with py2 on windows won't get pip support anyway.
Actually the 0.18-pre PY2 Win x64 have all the needed pip stuff. easyw-fc showed me how to make it work. It's not advertised because of the compiled extension limitations, but for pure python it's useful.

OSX has used pip for stuff like yaml for a while now with Py2.

For the Win portable builds and the AppImages, we should consider including this including your pip-integration work. This would allow to lighten the binary packages. If it's easy for the user to get the stuff into the right environment we (FreeCAD) don't need to provide it.

What does everyone think?
"fight the good fight"
Post Reply