flathub / io.github.cudatext.CudaText-Qt5

https://flathub.org/apps/details/io.github.cudatext.CudaText-Qt5
1 stars 1 forks source link

Can't use system wide python with a CudaText-Qt5 flatpak install (limits use of cudatext plugins that require additional python packages) #3

Closed bogen85 closed 2 years ago

bogen85 commented 2 years ago

This was originally filed at https://github.com/Alexey-T/CudaText/issues/4357 but that is not the correct location.

For the most part the flatpak install of CudaText-Qt5 works great. I have been using for several months now on multiple Linux distributions.

However, there is no straight forward to use cudatext plugins (such as the ftp one that depends on the paramiko python package) that depend on more than just a generic python install.

CudaText ftp plugin: https://github.com/pohmelie/cuda_ftp

I'm not sure how this can be remedied (or if there is any possible solution for this), as I'm not familiar with making flatpak packages.

bogen85 commented 2 years ago

This issue is not the finding of python by CudaText. Python (not the system wide python) is found and most plugins work fine. That aspect is discussed in #2 and is not the problem here.

(What is found is a python that flatpak installs for the io.github.cudatext.CudaText-Qt5 package, which, as I said, works fine).

The issue is when a CudaText plugin depends on some pip module (such as the cudatext ftp plugin dependency on paramiko) and that pip module is not in the flatpak python installation that the io.github.cudatext.CudaText-Qt5 package uses.

Alexey-T commented 2 years ago

Since CudaText adds path "py" (location of this "py" - is shown in the Wiki), you can copy Paramiko lib and all other python libs to "py"! did you try it? note - use correct version of python lib if it has binary .so files.

bogen85 commented 2 years ago

Seems like a rabbit trail in regard to paths to dynamically linked paths in said binary .so files... (as they will be resolved in the flatpak sandbox for cudatext)

Alexey-T commented 2 years ago

I dont understand what you said here.

Alexey-T commented 2 years ago

Menu command "Plugins / addon manager / edit plugin" can open some plugin. it is opened in the "py" dir. so why not to put python libs there?

bogen85 commented 2 years ago

@Alexey-T I removed all my user pip modules so I'd start out fresh. I just installed paramiko. Did an ldd on all the .so files under the /.local/lib/python3.10 path. The so paths those .so files dependent on don't seem match exactly what is in the flatpak cudatext sandbox view.

By rabbit trail I mean going down the path of making it work this way I'd be trying to resolve paths between two system views.

Also, the python version used inside the io.github.cudatext.CudaText-Qt5 package is not the same as the system available versions in my distro.

Alexey-T commented 2 years ago

Why not to do this

bogen85 commented 2 years ago

I know what you mean (yes, I'm already familiar with the py path), but most python installs are not 100% self contained. So I would need to:

  1. Maintain a separate install of python 3.9 that can be mapped into the flatpak sandbox view
  2. Maintain a separate install of the system packages all that python module .so files depend on and map those in the flatpak sandbox view.

I called it a rabbit trail because I'd have no idea how long that would take and if it would even be practical to get what I need out of that.

bogen85 commented 2 years ago

Any file in a standard system path that is referred to by some python module (binary or not) in the py path will resolve to a path in the cudatext flatpak sandbox view.

bogen85 commented 2 years ago

Plugins that launch external apps from the system don't work either when using cudatext installed via flatpak (At least I've not gotten them to work) most likely for the same reason (they are not in the cudatext flatpak sandbox view).

bogen85 commented 2 years ago

I did a pip user install of just paramko. (deleted my user specific pip tree first)

$ pip list --user
Package  Version
-------- -------
bcrypt   4.0.0
paramiko 2.11.0
PyNaCl   1.5.0

I did not install bcrypt and PyNaCl, paramiko depends on them so they were installed automatically.

To do what you are suggesting I'd need to build all of those for python 3.9.9 (which is the python version flatpak is using for cudatext, not what is available on my system)

I'd need to copy/map all those into the py folder.

I'd need to make sure all the system paths in every file in those python packages is resolvable in the cudatext flatpak sandbox view.

hfiguiere commented 2 years ago

I did a pip user install of just paramko. (deleted my user specific pip tree first)

if done outside the sandbox, it's irrelevant. It won't see it.

the gist of the problem is that if you rely on system wide dependencies installed that way, it will not work.

bogen85 commented 2 years ago

if done outside the sandbox, it's irrelevant. It won't see it. the gist of the problem is that if you rely on system wide dependencies installed that way, it will not work.

@hfiguiere Yes, agreed. That is why I said trying to make it work in the way that @Alexey-T suggested would likely end up being a rabbit trail

bogen85 commented 2 years ago

So, if we all agree on the following:

  1. There is no way to escape the flatpak sandbox and use a system wide python install (that is outside the sandbox).
  2. All cudatext plugins can that will work the flatpak install can only rely on what is provided a by a generic python3 install (or other cudatext plugins)

Then I don't see a point in keeping this issue open and will just have accept these as limitations of the flatpak cudatext install.

bogen85 commented 2 years ago

@Alexey-T Oh, I meant rabbit hole when I said rabbit trail https://www.thefreedictionary.com/rabbit+hole

Something that is intricate or convoluted like a labyrinth and often has no outlet or resolution

hfiguiere commented 2 years ago

you can also work them out, it's problably some work, including upstream.

For example FreeCAD relies on pip (to be added to the package) to install the python dependencies as needed. Not sure the detail of their implementation, but I would just create a python venv in the XDG_DATA_HOME.

bogen85 commented 2 years ago

Seems like for this to work cohesively that all the flatpak cudatext modules (that are in the py directory) would have to be in said venv?

I'll look into the XDG_DATA_HOME python venv approach.

But it seems like overall to not have to rely completely on this closed sandbox that the CudaText flatpak install would need to use the approach used by FreeCAD, and this may not be easily solvable on a plugin by plugin basis.

bogen85 commented 2 years ago

I'm closing this as this would take a rework of io.github.cudatext.CudaText-Qt5 (or be an alternate flatpak) to make this work generically like was mentioned for FreeCAD.