[Distutils] Fixing the stdlib

Bob Ippolito bob at redivi.com
Fri Sep 2 02:36:55 CEST 2005

On Sep 1, 2005, at 5:26 PM, Trent Mick wrote:

> [Ian Bicking wrote]
>> Vaguely off-topic, but I figured someone here might know...
>> Anyway, I want to provide backported stdlib modules to older  
>> versions of
>> Python.  Most of these are trivial to backport, so it's just a  
>> matter of
>> accumulating them in one place.
> Is it important in your use case to magically stick them in the same
> place as the standard locations? I remember a few people mentioning  
> that
> they have their own "compat" (or "compat23", ...) modules kicking
> around. It might be nice to have a collective "compat" or "backported"
> package out there, then users could explicitly:
>     try:
>         from compat import tempfile
>     except ImportError:
>         import tempfile
> Dunno if that matches up with what you wanted to do.
>> Thoughts?
> An import hook that does the magic?

You can also install a .pth file that looks like this, which is a  
little bit less magical than an import hook:
import sys; sys.path.insert(0, 'modules-that-override-the-stdlib-are- 

Of course, you can't override anything that is imported before the  
site module is, but most of those are built-in or have baked-in  
references in the interpreter anyway.


More information about the Distutils-SIG mailing list