On 19 August 2016 at 07:58, Donald Stufft <don...@stufft.io> wrote:
>> On Aug 18, 2016, at 5:53 PM, Barry Warsaw <ba...@python.org> wrote:
>> I'm very sure I don't understand something, because I thought wheels were 
>> just
>> fine for the import-from-sys.path use case.  I mean, pip does this and in
>> Debian, we have a program (dirtbike) that turns installed package's file
>> system layouts back into wheels so they can be put on sys.path and imported
>> from.
>
> It “Works”, sometimes, if the thing in the wheel doesn’t do something that
> might cause that to break. Thus it will work sometimes, but often times it
> won’t. It’s not an officially supported feature, but more of a thing where
> some decisions were made not to preclude it from working entirely.
>
> As an example, your Debian dirtbike’d pip only actually fully works because
> you’ve patched requests. If you didn’t have the patches you’ve applied to
> requests, it wouldn’t work. Additionally, pip only works at all because we’ve
> been careful to *only* depends on pure Python items that generally work when
> zipped (besides the requests thing, which we end up working around in 
> get-pip.py
> and just flat out avoiding in ensurepip).
>
> Basically, we don’t go out of our way to prevent it, but if you do it and it
> breaks, you get to keep both pieces.

+1

There's actually a somewhat analogous capability in the standard
library's test suite: test.support.import_fresh_module

This is a way of doing imports that effectively bypasses the normal
sys.modules cache, which lets us test both pure Python implementations
and C accelerator modules in the same run of the test suite.

It's also a marvelous foot gun that can mess up your Python process
state in a spectacularly hard to debug way if you don't know *exactly*
what you're doing.

However, it's just Python code, so anyone that wants to can go look at
how we do it, and do the same thing themselves, they're just on their
own when it comes to figuring out the precise boundaries of what does
and doesn't work, and which modules are written in such a way that
they will tolerate that kind of handling :)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
https://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to