[Distutils] Symlinks vs API -- question for developers

Barry Warsaw barry at python.org
Fri Oct 17 19:48:34 CEST 2008

Hash: SHA1

On Oct 17, 2008, at 1:32 PM, Toshio Kuratomi wrote:

> 7) Philip says that the reason pkg_resources does not see widespread
> adoption is that the developer cost of using an API is too high  
> compared
> to __file__.  I don't believe that the difference between file and API
> is that great.  An example of using an API could be something like  
> this:
> Symlinks::
>  import os
>  icondirectory = os.path.join(os.path.basename(__file__), 'icons')

s/basename/dirname/ I think.

> API::
>  import pkgdata
>  icondirectory = pkgdata.resource(pkg='setuptools', \
>      category='icon', resource='setuptools.png')

Having tried to be religious about using pkg_resources instead of  
__file__ in all my new code, I tend to agree that the API cost is not  
that high.  I don't particularly like the verbosity of the names  
chosen, but I actually like not having to use the __file__ idiom.

> * Distributions, further, don't want to install all-in-one egg
> directories on the system.  The pkg_resources API just gets in the way
> of doing things correctly in a distribution.  I've had to patch code  
> to
> not use pkg_resources if data is installed in the FHS mandated areas.
> Far from encouraging distributions to send patches upstream to make
> modules use pkg_resources this makes distributions actively discourage
> upstreams from using it.

I hadn't thought of this, but yes, this is a serious negative.

> So once again, I think this boils down to these questions: if we  
> have a
> small library whose sole purpose is to abstract a data store so you  
> can
> find out where a particular non-code file lives on this system will  
> you
> use it?

I would.  I apologize for not having followed the discussion that  
closely, but as an application developer, I would really like an API  
that hides all the location nonsense from me.  As familiar as __file__  
is, it's a fragile hack.

- -Barry

Version: GnuPG v1.4.9 (Darwin)


More information about the Distutils-SIG mailing list