[Distutils] entry points PEP
PJ Eby
pje at telecommunity.com
Thu Jul 18 23:34:44 CEST 2013
On Thu, Jul 18, 2013 at 1:50 PM, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
> Daniel Holth <dholth <at> gmail.com> writes:
>> For one thing you can have more than one mysql = in the same
>> sqlalchemy.dialects. I think in this instance the string parsing is
>
> Don't you say in the PEP about the key that "It must be locally unique
> within this distribution’s group."?
Setuptools requires this per-distribution uniqueness, but note that
uniqueness is not required across distributions. So more than one
distribution can export a 'mysql' in the 'sqlalchemy.dialects' group.
It's up to the application to decide how to handle multiple
definitions; typically one either uses all of them or the first one
found on sys.path, or some other tie-breaking mechanism. The
pkg_resources entry point APIs just provide operations for iterating
over entry points defined on either a single distribution, or across
all distributions on a specified set of directories. (Via the
WorkingSet API.)
> Note that I don't see necessarily a connection between extras and flags,
> though
> you've mentioned that they're extras. Does setuptools store, against an
> installed distribution, the extras it was installed with? AFAIK it doesn't.
> (Even if it did, it would need to keep that updated if one of the extras'
> dependencies were later uninstalled.) And if not, how would having extras in
> the specification help, since you can't test the "must be installed" part?
The pkg_resources implementation does a require() for the extras at
the time the entry point is loaded, i.e., just before importing. This
allows it to dynamically add requirements to sys.path, or
alternatively raise an error to indicate the extras aren't available.
In addition, various entry point API functions take an 'installer'
keyword argument, specifying a callback to handle installation of
missing extras. Setuptools uses this feature internally, so that if
you use a setup.py command whose entry point needs additional
dependencies, those will be fetched on-the-fly.
More information about the Distutils-SIG
mailing list