On Fri, Nov 20, 2020 at 7:20 PM Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
On 21/11/20 3:03 am, Paul Moore wrote:
> For my own purposes, what I *actually* want is to specify a list of
> 3rd party packages ...
> I *don't* want clever logic to decide how to strip out "unused" bits.

I concur.

With venvs, it seems like it should be possible to have a very
simple tool that just packages up everything in your venv. Such
a tool ought to be quite small and shouldn't require anything like
the amount of maintenance that PyInstaller and its ilk seem to

Am I wrong about this?

This is the approach we take for OSX where pyinstaller didn't seem to work as well (as opposed to windows where you can dump all the dlls in a directory and add it to the path, it doesn't work as well with dylibs) so we rolled our own [1]. But it still is not as simple.

E.g. the overall steps are:

- Make a skeleton app with platypus [2], this will allow it to run like a native osx app.
- Download and install all the dependency frameworks, including python dmg to the app.
- Relocate all dylibs such that the paths are relative to the app rather than using builtin hardcoded paths. This easily requires a fair bit of troubleshooting.
- Make venv with virtualenv and make it relocatable. Virtualenv does not support a relocatable venv anymore [3] so this has to be hacked a little and hope for the best.
- Install pip packages.
- Make pip scripts relocatable with sed (they normally contain hardcoded paths) and hopefully don't break these scripts.
- Strip whatever you don't need.
- Make into dmg.


[1] https://github.com/kivy/kivy-sdk-packager/tree/master/osx
[2] https://sveinbjorn.org/platypus
[3] https://github.com/pypa/virtualenv/issues/1549