[Distutils] Symlinks vs API -- question for developers

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


-----BEGIN PGP SIGNED MESSAGE-----
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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iQCVAwUBSPjP8nEjvBPtnXfVAQKOeQP/eJywpz1CUxJhUD9NhUj68rpoHbato8W4
fP2ZNRmKOSGUmtaj9hM1vduMoCszCN/vz8fX+gGZFu9ySkWyQfO5Q6Hh/kBrKSRN
IzVYcd3lbV+e63+twk3Ht4gSX8j2iWnt375976kFgvmMc2iB7zn0r/TDblMIqvxV
NUUi3d3zaPs=
=5yrx
-----END PGP SIGNATURE-----


More information about the Distutils-SIG mailing list