Skip to content

Option to copy requirements locally instead of using pip - #49

Merged
niess merged 3 commits into
niess:masterfrom
VladimirIvan:local-requirements
Jul 21, 2022
Merged

niess merged 3 commits into
niess:masterfrom
VladimirIvan:local-requirements

Conversation

@VladimirIvan

Copy link
Copy Markdown
  • Adds the option to copy a local module from the host instead of pulling one from pip.
  • Prepend local+ to mark module for local copy (analogous to existing git+ syntax).
  • Copies either the the module directory (from modulename.__file__) or an *.so file for cpython wrapped modules.
  • Doesn't check for dependencies.
  • Runs pip install in an isolated environment (-I) to avoid skipping installing modules in host's environment.

Usage in requirements.txt:

# Install using pip
numpy
# Install via local copy from host
local+serial

@niess

niess commented Jul 20, 2022

Copy link
Copy Markdown
Owner

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

Copy link
Copy Markdown
Author

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
niess merged commit 061fd74 into niess:master Jul 21, 2022
@niess

niess commented Jul 21, 2022

Copy link
Copy Markdown
Owner

@VladimirIvan,

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

Thank you for contributing.

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 this pull request may close these issues.

3 participants