[Distutils] Using Wheel with zipimport
Paul Moore
p.f.moore at gmail.com
Wed Jan 29 10:40:14 CET 2014
On 29 January 2014 04:14, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
> When this topic came up before, I asked for specific failure modes which
> were causing concern, but I never got a response IIRC.
>From what I recall, the topic came up before in relation to distlib's
wheel mount functionality.
My specific concerns about that API (none of which have been
addressed, AFAIK, but most of which are somewhat non-specific, I
concede, for reasons see below) are:
1. It does *not* just use the fact that wheels are importable. It goes
beyond that and *extracts* C extensions to make them importable, too.
That is a workaround for a known and accepted limitation of zipimport,
and as a workaround, it has issues. If C extensions in zipfiles could
work reliably, this should go into zipimport itself, and *not* into
3rd party code. Then everyone would benefit.
2. It makes what should be a rare use case, to be used only when the
code in the wheel has been carefully checked to work from a zipfile,
seem like a common and straightforward operation. (The "attractive
nuisance" argument). I believe that people using this API will
typically *not* check the code, and will blame the wheel format, or
distlib, when their application does not work as expected.
3. It is no easier than sys.path.insert(0, wheelname). All it adds
over that is compatibility checking and the ability to import C
extensions (see above on why I think that's a bad thing). As for
compatibility checking, I'd prefer a distlib.wheel.check_compatibility
API that people could call *before* manually inserting the wheel onto
sys.path. That's a better separation of concerns, in my view.
I can't give specific examples of "failure modes" because I don't use
the wheel mount functions, nor do I typically add wheels to sys.path.
When I did (in virtualenv) I hit a number of issues, but all of these
were ones I fixed in user code (either in virtualenv itself, or in
pip, which was the wheel I was importing). So you could reasonably
dismiss these as "not related to the mount API" to which all I can say
is that if I'd been able to do wheel.mount(wheelname) I would likely
have put less thought into whether what I was doing was a good idea -
and *that's* what I think is the bad aspect of the API.
Ultimately, I'll just never use the distlib mount functionality, and
I'll recommend not using it when (if) people ask. But I'd rather it
were not there to prompt the question.
I hope this helps,
Paul
More information about the Distutils-SIG
mailing list