niess / python-appimage

AppImage distributions of Python
https://python-appimage.readthedocs.io/en/latest/
GNU General Public License v3.0
170 stars 24 forks source link

Option to copy requirements locally instead of using pip #49

Closed VladimirIvan closed 2 years ago

VladimirIvan commented 2 years ago

Usage in requirements.txt:

# Install using pip
numpy
# Install via local copy from host
local+serial
niess commented 2 years ago

Hello @VladimirIvan,

thank you for this contribution.

Indeed, pip should run with isolation in order to properly install to the AppImage. Thank you for patching this.

I slightly modified your PR since it was Python 3 specific, while python-appimage supports Python 2.7 as well. The modifications can be seen as a new branch. Would that work for your use case?

Concerning the local+ option, I am happy to add it since it might be convenient in some cases. However, I am assuming that you are aware of the limitations? Performing a direct copy only works in simple cases. E.g., if the package installs executable scripts, then those are not copied (since they are located out of the main package directory). A similar issue occurs e.g. with numpy that installs libraries outside of the package repository, under numpy.libs. In addition, one must be aware that binary compatibility is limited by the host in such cases. I.e. the resulting AppImages will not run on older Linuses. Furthermore, the RPATH of some copied binaries might need a patch in order to properly locate deps inside the AppImage. When installing from a proper binary wheel, in principle all these issues have been solved.

VladimirIvan commented 2 years ago

Hi @niess, thank you for the review. I pulled the python2.7 compatibility changes into into this branch. Thank you for implementing those.

I'm aware of the limitations. This is all fine for my current use case which only needs to bundle a single *.so file with no RPATH and no other dependencies that won't be available on older systems. I've seen other cross-platform python packaging systems that crawl through modules and query libraries using ldd or similar tools. Wheels are a better option still but the local copy is a should work OK where the wheels are not set up yet. Based on the objectives this module I wanted to keep this minimal. I'm sure that if this becomes a popular feature it can be extended further.

niess commented 2 years ago

@VladimirIvan,

fine then :) I merged your PR and briefly documented the new option.

Thank you for contributing.