[Distutils] Re: [PSA MEMBERS] packages in Python

Michel Sanner sanner@scripps.edu
Fri, 21 May 1999 09:42:28 -0700


On May 21, 11:11am, Fred L. Drake wrote:
> Subject: [Distutils] Re: [PSA MEMBERS] packages in Python
>
> Konrad Hinsen writes:
>  > Shouldn't that be the other way round? I'd expect to be able to override
>  > general modules by platform-specific modules.
>
>   Greg Ward and I were talking about this stuff the other day, and I
> think we decided that there was no good way to have multiple
> implementations of a module installed such that the platform dependent
> version was sure to take precedence over a platform independent
> version; this relies on the sequence of directories in the relevant
> search path (whether it be sys.path or a package's __path__).
>   The general solution seems to be that two things need to be done: a
> package's __path__ needs to include *all* the appropriate directories
> found along the search path, not just the one holding __init__.py*,
> AND the platform dependent modules should have different names from
> the platform independent modules.  The platform independent module
> should be the public interface, and it can load platform dependent
> code the same way that string loads functions from strop.
>   The problem here is that the package's __path__ is not being created
> this way now; if anyone has time to work on a patch for
> Python/import.c, I'd be glad to help test it!  ;-)
>
I take care of this in my extension module. If I have a platform dependent
implementation of a module I:

try:
  import extension
Fail:
   use common

This requires minimal amount of coding. Personally I did not see the need of
this being automatic

-Michel