[Distutils] Symlinks vs API -- question for developers
barry at python.org
Fri Oct 17 19:48:34 CEST 2008
-----BEGIN PGP SIGNED MESSAGE-----
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
> 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
> import os
> icondirectory = os.path.join(os.path.basename(__file__), 'icons')
s/basename/dirname/ I think.
> 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
> 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
> find out where a particular non-code file lives on this system will
> 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.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
-----END PGP SIGNATURE-----
More information about the Distutils-SIG