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

pip-integration in addon-manager

Post by looo »

Installing FreeCAD-wokbenches with pip is supported for quite some time. But until now it wasn't very easy to use this feature. (At least for someone not used to pip-command-line tools) To change this we need a GUI similar to the addon-manager.

As pip allready handles all the difficult stuff, implementing this is much simpler compared to the traditional addon-manager.
The tool is not yet fully ready, but I think there is not much missing. The current implementation looks like this:
we simple provide a list of package-names which can be installed with this tool. This list is fetched by the installer and represented in the gui. Currently this list exists in the module, but once we add the widget to the addon-manager we should think about providing the list in the FreeCAD-AddonManager repo [2].

I am not yet sure how to add this to the addon-manager, but I think we find a solution.

[1] https://github.com/looooo/freecad_pipintegration
[2] https://github.com/FreeCAD/FreeCAD-addons

edit:
ref: https://github.com/FreeCAD/FreeCAD-addons/issues/71
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: pip-integration in addon-manager

Post by Kunda1 »

This is an awesome idea. Thanks looo :)
Edit: we should also think about the Addon Manager Pre-requisite checker https://github.com/FreeCAD/FreeCAD-addons/issues/29 moving forward with this.
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:Edit: we should also think about the Addon Manager Pre-requisite checker https://github.com/FreeCAD/FreeCAD-addons/issues/29 moving forward with this.
yes I guess checking dependencies is still necessary. I am not sure if it's a good idea to use the dependency-handling of pip. pip tries to install also more difficult dependency (like numpy) which are not working on all plattforms/ distros and often it's better to install these deps with the system package-manager.
User avatar
yorik
Founder
Posts: 13630
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: pip-integration in addon-manager

Post by yorik »

Sorry for my ignorance, but what is the advantage of using pip? Also, it doesn't handle updating, or using threads to download in the background, or fetching workbench info, so we would end up having to recreate all that, which would be duplicating all the work done in the addon manager, no?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pip-integration in addon-manager

Post by looo »

yorik wrote:Sorry for my ignorance, but what is the advantage of using pip? Also, it doesn't handle updating, or using threads to download in the background, or fetching workbench info, so we would end up having to recreate all that, which would be duplicating all the work done in the addon manager, no?
yes there are quite some things missing. But integrating this in the addon-manager would need at least 10x more time. (It's pretty hard to understand the concept)
My tool runs in the background with python threads, updating should be no problem...

While I absolutely appreciate the work done on the addon-manager, I think the addon-manager is already duplicated work. pip was always there and we simple couldn't use it because Workbenches for freecad were implemented in a way not compatible with normal python-modules.
This introduce several problems like name-clashes. The workarounds are not difficult, but it's realy not an ideal design.

A usecase of a freecad-package installed with pip is freecad_glider with openglider and pyrates with the additional freecad_packages. With pip it's possible to install everything with one command (python-packages get installed as a normal python module and freecad-packages get installed as namespace packages) How would you solve this with the addon-manager.

Then there are tools to create packages from standard-python modules for different distributions. I know there are tools for ubuntu and debian to do this (Ever wondered how they package all the python-.... packages?)
You may ask: why to we need this?
We don't need this for pure python-modules. The addon-manager is perfect for this. (As long as we don't have to deal with addons depending on different versions of freecad) But if an addon is compiled or depends on compiled (non common) libraries things get more difficult.

So in my opinion the addon-manager works good and is nice as long as things stay simple. But the pip approach for freecad-addons is for sure the more future-prove concept.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: pip-integration in addon-manager

Post by triplus »

Likely you should create a PR and just add the proposed GUI feature as a new tab. Code likely should stay separated for now (two files). And by doing that to further develop and maintain the "pip part" of the addon manager as the need arises. As likely both module types will need to coexist for years to come.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pip-integration in addon-manager

Post by looo »

yes exactly this is the idea. I don't want to make this a replacement of the addon installer. It should simple be another option (tab) next to the existing two tabs.
User avatar
yorik
Founder
Posts: 13630
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: pip-integration in addon-manager

Post by yorik »

looo wrote: Tue Jul 03, 2018 10:15 pm We don't need this for pure python-modules. The addon-manager is perfect for this. (As long as we don't have to deal with addons depending on different versions of freecad) But if an addon is compiled or depends on compiled (non common) libraries things get more difficult.
looo wrote: Wed Jul 04, 2018 1:19 am yes exactly this is the idea. I don't want to make this a replacement of the addon installer. It should simple be another option (tab) next to the existing two tabs.
Okay got it. Seems fine!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: pip-integration in addon-manager

Post by DeepSOIC »

Hi there. I'm trying to use pip to install an example workbench, like for development. From here: https://github.com/FreeCAD/Workbench-St ... to-freecad
I have an unzipped portable freecad (typical dev snapshot):
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13935 (Git)
Build type: Release
Branch: master
Hash: cb133767464337e4b5c8589a1fe33b4d7dad7721
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: Russian/RussianFederation (ru_RU)

Running pip in windows command propmt complains it has no clue what is pip. I can however import pip in freecad's console. So I tried this:

Code: Select all

>>> import pip
>>> pip.main(['install', '-e', r'S:\_vt\dev\PC\Qt\FreeCAD\macros\Workbench-Starterkit-master'])
Obtaining file:///S:/_vt/dev/PC/Qt/FreeCAD/macros/Workbench-Starterkit-master
2
    Error environment can only contain strings while executing command python setup.py egg_info
Exception:
Traceback (most recent call last):
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\site-packages\pip\commands\install.py", line 335, in run
    wb.build(autobuilding=True)
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\site-packages\pip\wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\site-packages\pip\req\req_set.py", line 518, in _prepare_file
    abstract_dist.prep_for_dist()
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\site-packages\pip\req\req_set.py", line 129, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\site-packages\pip\req\req_install.py", line 439, in run_egg_info
    command_desc='python setup.py egg_info')
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\site-packages\pip\utils\__init__.py", line 667, in call_subprocess
    cwd=cwd, env=env)
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "C:\FreeCAD\builds-snapshots\Default\bin\lib\subprocess.py", line 640, in _execute_child
    startupinfo)
TypeError: environment can only contain strings
You are using pip version 9.0.2, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
>>> pip.main(['install', '-e', r'S:\_vt\dev\PC\Qt\FreeCAD\macros\Workbench-Starterkit-master\freecad\template_extension'])
1
Directory 'S:\\_vt\\dev\\PC\\Qt\\FreeCAD\\macros\\Workbench-Starterkit-master\\freecad\\template_extension' is not installable. File 'setup.py' not found.
You are using pip version 9.0.2, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
>>> 
So far, no luck. Any ideas? I am attempting to use pip for the first time ever, please forgive my stupidity.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: pip-integration in addon-manager

Post by sgrogan »

DeepSOIC wrote: Wed Aug 29, 2018 10:50 am So far, no luck. Any ideas? I am attempting to use pip for the first time ever, please forgive my stupidity.
Packaging of pip is still messed in your version. It should be fixed in the newest x64 builds.
Or you can add it yourself, see here: https://forum.freecadweb.org/viewtopic.php?t=16851
Also see here for ongoing integration of pip on Win https://forum.freecadweb.org/viewtopic. ... 60#p253175
"fight the good fight"
Post Reply