[py2app] packaging an egg using pkg_resources

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[py2app] packaging an egg using pkg_resources

carbncl
Hi,

First of all, not being experienced with python, my apologies if this question answer was obvious, but I couldn't find a clear answer / solution to this.

I'm currently trying to package a pyGtk application as an OSX one.
This application is distributed as an egg and use pkg_resources facilities to get things like app version and glade resources.
Having pkg_resources errors, from what I understand and found searching and reading this mailing list, I came to the following conclusions:
  • py2app is not designed to use eggs
  • pkg_resources requires a distribution format like eggs to have the required metadata to introspect a package.

Does this assumptions are true? > Does that means I have to purge code from pkg_resources calls?
Any good suggestion / recommended implementation is welcome.

Vincent.

_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|

Re: [py2app] packaging an egg using pkg_resources

Ronald Oussoren

On 20 Oct, 2011, at 10:58, carbncl wrote:

Hi,

First of all, not being experienced with python, my apologies if this question answer was obvious, but I couldn't find a clear answer / solution to this.

I'm currently trying to package a pyGtk application as an OSX one.
This application is distributed as an egg and use pkg_resources facilities to get things like app version and glade resources.
Having pkg_resources errors, from what I understand and found searching and reading this mailing list, I came to the following conclusions:
  • py2app is not designed to use eggs

That's corrrect. Py2app currently does not copy egg metadata into the application bundle.

  • pkg_resources requires a distribution format like eggs to have the required metadata to introspect a package.

That's correct as well. 


Does this assumptions are true? > Does that means I have to purge code from pkg_resources calls?
Any good suggestion / recommended implementation is welcome.

The easiest solutions are to either remove pkg_resources calls, or add custom pkg_resources.py file that
loads the resource data without using setuptools metadata. Either way you have to ensure that the resource files
get copied into the application bundle.

The "proper" solution is to teach py2app how to copy eggs with their metadata and resources into the 
application bundle. That's on my todo list, but I don't know when I'll get around to actually implementing this.

Ronald


Vincent.
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

smime.p7s (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [py2app] packaging an egg using pkg_resources

Chris Barker
On 10/20/2011 2:35 AM, Ronald Oussoren wrote:

>>   * py2app is not designed to use eggs
>
> That's corrrect. Py2app currently does not copy egg metadata into the
> application bundle.
>
>>   * pkg_resources requires a distribution format like eggs to have the
>>     required metadata to introspect a package.
>
> That's correct as well.
>
>>
>> Does this assumptions are true? > Does that means I have to purge code
>> from pkg_resources calls?
>> Any good suggestion / recommended implementation is welcome.
>
> The easiest solutions are to either remove pkg_resources calls, or add
> custom pkg_resources.py file that
> loads the resource data without using setuptools metadata.

actually, even easier is to copy the full eggs into your app bundle by
hand (by hand I mean code in your setup.py) -- a bit ugly, but it works.

> The "proper" solution is to teach py2app how to copy eggs with their
> metadata and resources into the
> application bundle.

That would be nice, but I don't know that it's really the "best" solution.

I've dealt with this for an app that was heavily dependent on setuptools
features like pkg_resources, and I think setuptools is really pretty
ugly, at least when you want to use things like py2app and friends.

The assumption that you're packages are fully installed as part of a
nice big python install is really built in, so the only solution is to
copy huge chunks of stuff, much of which you don't need, into your app
bundle -- whether py2app does this automatically, or you do it in your
scripts, it's still a lot of extra stuff.

Personally, I like setuptools for install time stuff, but not so much
for run time stuff -- if you can avoid run time calls to setuptolls, I
would.

AS for resources, personally I like to use python files for data -- and
then "import" to get it - this makes for nice, clean integeration with
py2app, etc.

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|

Re: [py2app] packaging an egg using pkg_resources

carbncl

Le 20 oct. 2011 à 17:38, Chris Barker a écrit :

> On 10/20/2011 2:35 AM, Ronald Oussoren wrote:
>>>  * py2app is not designed to use eggs
>>
>> That's corrrect. Py2app currently does not copy egg metadata into the
>> application bundle.
>>
>>>  * pkg_resources requires a distribution format like eggs to have the
>>>    required metadata to introspect a package.
>>
>> That's correct as well.
>>
>>>
>>> Does this assumptions are true? > Does that means I have to purge code
>>> from pkg_resources calls?
>>> Any good suggestion / recommended implementation is welcome.
>>
>> The easiest solutions are to either remove pkg_resources calls, or add
>> custom pkg_resources.py file that
>> loads the resource data without using setuptools metadata.
>
> actually, even easier is to copy the full eggs into your app bundle by hand (by hand I mean code in your setup.py) -- a bit ugly, but it works.

I thought that I had already tried this workaround w/o any success...
...Just tried it again to make sure... And that worked?!

Thanks a lot Chris for pointing this to me, how can I have missed this...
And ofc, thanks Ronald for your work and for the quick reply.

>> The "proper" solution is to teach py2app how to copy eggs with their
>> metadata and resources into the
>> application bundle.
>
> That would be nice, but I don't know that it's really the "best" solution.
>
> I've dealt with this for an app that was heavily dependent on setuptools features like pkg_resources, and I think setuptools is really pretty ugly, at least when you want to use things like py2app and friends.
>
> The assumption that you're packages are fully installed as part of a nice big python install is really built in, so the only solution is to copy huge chunks of stuff, much of which you don't need, into your app bundle -- whether py2app does this automatically, or you do it in your scripts, it's still a lot of extra stuff.
>
> Personally, I like setuptools for install time stuff, but not so much for run time stuff -- if you can avoid run time calls to setuptolls, I would.
>
> AS for resources, personally I like to use python files for data -- and then "import" to get it - this makes for nice, clean integeration with py2app, etc.
>
> -Chris
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> [hidden email]
> _______________________________________________
> Pythonmac-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|

Re: [py2app] packaging an egg using pkg_resources

Ronald Oussoren
In reply to this post by Chris Barker

On 20 Oct, 2011, at 17:38, Chris Barker wrote:

> On 10/20/2011 2:35 AM, Ronald Oussoren wrote:
>>>  * py2app is not designed to use eggs
>>
>> That's corrrect. Py2app currently does not copy egg metadata into the
>> application bundle.
>>
>>>  * pkg_resources requires a distribution format like eggs to have the
>>>    required metadata to introspect a package.
>>
>> That's correct as well.
>>
>>>
>>> Does this assumptions are true? > Does that means I have to purge code
>>> from pkg_resources calls?
>>> Any good suggestion / recommended implementation is welcome.
>>
>> The easiest solutions are to either remove pkg_resources calls, or add
>> custom pkg_resources.py file that
>> loads the resource data without using setuptools metadata.
>
> actually, even easier is to copy the full eggs into your app bundle by hand (by hand I mean code in your setup.py) -- a bit ugly, but it works.
>
>> The "proper" solution is to teach py2app how to copy eggs with their
>> metadata and resources into the
>> application bundle.
>
> That would be nice, but I don't know that it's really the "best" solution.
Eggs exist and py2app should support them, otherwise people have to resort to ugly workarounds like copying files manually.  Adding an option for copying a set of eggs into the application bundle would be fairly easy.

>
> I've dealt with this for an app that was heavily dependent on setuptools features like pkg_resources, and I think setuptools is really pretty ugly, at least when you want to use things like py2app and friends.
>
> The assumption that you're packages are fully installed as part of a nice big python install is really built in, so the only solution is to copy huge chunks of stuff, much of which you don't need, into your app bundle -- whether py2app does this automatically, or you do it in your scripts, it's still a lot of extra stuff.

That can be a problem, especially with older codebases that haven't been split into a number of smallish packages.

>
> Personally, I like setuptools for install time stuff, but not so much for run time stuff -- if you can avoid run time calls to setuptolls, I would.
>
> AS for resources, personally I like to use python files for data -- and then "import" to get it - this makes for nice, clean integeration with py2app, etc.

I use python files for resources on Windows to get single-file executables with py2exe, but prefer to use real data files on OSX for easier maintenance.  

Ronald

>
> -Chris
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> [hidden email]
> _______________________________________________
> Pythonmac-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

smime.p7s (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [py2app] packaging an egg using pkg_resources

Chris Barker
On 10/23/11 10:52 PM, Ronald Oussoren wrote:
>>> The "proper" solution is to teach py2app how to copy eggs with their
>>> metadata and resources into the
>>> application bundle.
>>
>> That would be nice, but I don't know that it's really the "best" solution.
>
> Eggs exist and py2app should support them, otherwise people have to resort to ugly workarounds like copying files manually.  Adding an option for copying a set of eggs into the application bundle would be fairly easy.

I wasn't clear -- I agree that copying the egg into the bundle is the
best solution for py2app itself.

I was arguing that it would be better to not use setuptools features in
that way at all -- but if they're used, it's nice for py2app to support
them.


>> AS for resources, personally I like to use python files for data -- and then "import" to get it - this makes for nice, clean integeration with py2app, etc.
>
> I use python files for resources on Windows to get single-file executables with py2exe, but prefer to use real data files on OSX for easier maintenance.

I guess what I think causes difficulties is data files required by a
third-party package, rather than the one my app uses -- I don't have any
issue with data files for my app -- it's the ones in third party
packages that you then need to install properly with py2app or py2exe --
that's a pain.

-CHB



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|

Re: [py2app] packaging an egg using pkg_resources

Ronald Oussoren

On 26 Oct, 2011, at 20:46, Chris.Barker wrote:

> On 10/23/11 10:52 PM, Ronald Oussoren wrote:
>>>> The "proper" solution is to teach py2app how to copy eggs with their
>>>> metadata and resources into the
>>>> application bundle.
>>>
>>> That would be nice, but I don't know that it's really the "best" solution.
>>
>> Eggs exist and py2app should support them, otherwise people have to resort to ugly workarounds like copying files manually.  Adding an option for copying a set of eggs into the application bundle would be fairly easy.
>
> I wasn't clear -- I agree that copying the egg into the bundle is the best solution for py2app itself.
>
> I was arguing that it would be better to not use setuptools features in that way at all -- but if they're used, it's nice for py2app to support them.
>
>
>>> AS for resources, personally I like to use python files for data -- and then "import" to get it - this makes for nice, clean integeration with py2app, etc.
>>
>> I use python files for resources on Windows to get single-file executables with py2exe, but prefer to use real data files on OSX for easier maintenance.
>
> I guess what I think causes difficulties is data files required by a third-party package, rather than the one my app uses -- I don't have any issue with data files for my app -- it's the ones in third party packages that you then need to install properly with py2app or py2exe -- that's a pain.
That's one thing that setuptools tries to solve: the egg should contain all data and pkg_resources provides an API to get at the data without having to assume that they are at a fixed location in the filesystem. In theory this means py2app can stuff all code into the site-packages.zip file while storing resources as files without breaking application code. That would likely break existing code though.

Distutils2/packaging has a simular (but different) solution to the same problem.

Ronald

>
> -CHB
>
>
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> [hidden email]
> _______________________________________________
> Pythonmac-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

smime.p7s (6K) Download Attachment