auto installing dependencies with pip to run a python zip application ?

Paul Moore p.f.moore at gmail.com
Wed Sep 27 03:50:12 EDT 2017


On 26 September 2017 at 23:48, Irmen de Jong <irmen at nospam.xs4all.nl> wrote:
> On 09/26/2017 10:49 PM, Paul Moore wrote:
>> On 26 September 2017 at 19:47, Irmen de Jong <irmen at nospam.xs4all.nl> wrote:
>>> Any thoughts on this? Is it a good idea or something horrible? Has
>>> someone attempted something like this before perhaps?
>>
>> When I've done this, I've bundled my dependencies in with my zipapp.
>> Of course that's trickier if you have binary dependencies like pillow.
>
> Yeah I've considered that for a moment but I think sometimes you've also
> got to deal with licensing issues. I'd rather avoid this.

I'd assume you're simply bundling for convenience, but I agree that
avoiding the treacherous waters of licensing is always a good idea ;-)

>> What you could do is pip install your binary dependencies into a
>> directory in $TEMP using --target, then add that directory to
>> sys.path. Probably easier than building a full virtualenv. Bundle pip
>> with your app if you can't assume your users will have pip available.
>
> Interesting idea, although like this wouldn't I have to download the
> dependencies every time I launch my game? (unless I re-use the same
> temporary directory every time)

Ah, I'd assumed that's what you were doing with the virtualenv, I
hadn't realised you were talking about a one-off setup step. Yeah,
re-using a temporary directory doesn't buy you much compared to using
a virtualenv (particularly if you can target versions of Python that
have the built in venv module).

Paul



More information about the Python-list mailing list