Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip missing in Freecad 0.20 flatpak builds #88

Closed
AmeyaPatwardhan opened this issue Jul 5, 2022 · 13 comments · Fixed by #92
Closed

pip missing in Freecad 0.20 flatpak builds #88

AmeyaPatwardhan opened this issue Jul 5, 2022 · 13 comments · Fixed by #92

Comments

@AmeyaPatwardhan
Copy link

Unable to install Assembly3 in Freecad 0.20 (Flatpak) on Ubuntu 20.04

Upon using the addon manager-> Assembly3->Install,
and clicking yes to install the python dependencies (py-slvs) the following message pops up:

Failed to execute pip, which may be missing from your Python installation. Please ensure your system has pip installed and try again. The failed command was:

/usr/bin/python3 -m pip --version

Continue with installation of Assembly3 anyway?

Freecad version:
FreeCAD - An open source parametric 3D CAD modeler

ID: org.freecadweb.FreeCAD
Ref: app/org.freecadweb.FreeCAD/x86_64/stable
Arch: x86_64
Branch: stable
Version: 0.20.0.29177
License: LGPL-2.1
Origin: flathub
Collection: org.flathub.Stable
Installation: user
Installed: 1.0 GB
Runtime: org.kde.Platform/x86_64/5.15-21.08
Sdk: org.kde.Sdk/x86_64/5.15-21.08

@hfiguiere
Copy link
Contributor

And where would pip install things?

We could add pv-slvs to the flatpak, but there is no source package on pypi available.

@hfiguiere
Copy link
Contributor

IMHO the workbench should bundle it and not depend on "system wide" installation. (it's not the only one that require external python modules)

@luzpaz
Copy link

luzpaz commented Jul 8, 2022

Just CCing @realthunder on this as well so it's on his radar.

@realthunder
Copy link

py-slvs cannot by bundled because of licensing issue. Using system pip will only work if the system Python is compatible with the one used to build FreeCAD. So I think the problem should be fixed by bundling pip into FreeCAD build.

@hfiguiere
Copy link
Contributor

I couldn't find a source distribution on pypi.

And what is the licensing problem you are mentioning, because if you can bundle it, I don't think we can either.

@realthunder
Copy link

The pipy package home links to the repo. It is licensed under GPL, while FreeCAD is LGPL. I don't mean to bundle py-slvs. I mean to bundle pip itself, which is what I assume what's missing here. py-slvs will be installed on demand by user explicitly.

@hfiguiere
Copy link
Contributor

hfiguiere commented Jul 9, 2022

So I will reiterate the question #88 (comment): where will pip install this module?

Just to clarify. The file system is READ ONLY inside the sandbox.

And my armchair analysis of licensing is that if you can't bundle py_slvs with your workbench, then surely we can't with the Flatpak.

@realthunder
Copy link

realthunder commented Jul 9, 2022

I am not sure how flatpak works. For snap, it will store common data associated with a particular app in ~/snap/<app_name>/common directory. For user installed pip package, it will be installed in ~/snap/<app_name>/common/.local/lib/python<version>/site-packages.

@adrianinsaval
Copy link
Collaborator

adrianinsaval commented Jul 10, 2022

I think the add-on manager uses a freecad specific directory for pip packages, if I'm not mistaken they are installed somewhere in $XDG_DATA_HOME which should available to write for the flatpak.
@chennes would know better about this

@tinywrkb
Copy link

@AmeyaPatwardhan maybe try this with the adjustments for the FreeCAD app. You will need to override the PATH environment var and set it to /app/bin:/usr/bin:/var/data/python/bin.

@AmeyaPatwardhan
Copy link
Author

@tinywrkb tried using the suggested approach. I could not get it to work. However, this may be because of my lack of knowledge of flatpak environment variables, chroot etc. Is there any way to create a python virtual environment and simply add this to the flatpak path?

@chennes
Copy link

chennes commented Jul 13, 2022

The Addon Manager installs Python dependencies in a directory immediately adjacent to the Mod directory itself, called AdditionalPythonPackages. If you have write permissions to install mods, you have write permissions to install Python packages in that location. It does depend on the version of Python that is used by the FreeCAD installation having pip, however. We ship it with the Windows installation, for example. There is also a configuration variable in the Addon Manager preferences where you can set the path to that Python executable, so I suppose a possible workaround is to set that path to your system's Python and see if it will install the library you need.

@tinywrkb
Copy link

@AmeyaPatwardhan it works fine for me over here. I suggest that you wait for pip to be bundled with this Flatpak, but if really want to try, then it's pretty easy.

  • Install the SDK
$ flatpak install flathub $(flatpak info --show-sdk org.freecadweb.FreeCAD)
  • Install pip. It doesn't hurt to also have wheel.
$ flatpak run --devel --command=pip3 org.freecadweb.FreeCAD install --user --ignore-installed pip wheel
  • Remove the now unneeded SDK
$ flatpak uninstall $(flatpak info --show-sdk org.freecadweb.FreeCAD)
  • Start the app
$ flatpak run --env=PATH=/app/bin:/usr/bin:/var/data/python/bin org.freecadweb.FreeCAD

You can also explicitly set PYTHONUSERBASE=/var/data/python, but it's not really needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants