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

Fred L. Drake Fred L. Drake, Jr." <fdrake@acm.org
Fri, 21 May 1999 11:11:00 -0400 (EDT)


Konrad Hinsen writes:
 > > I would much more prefere have Python try to import from the
 > > paltform independant part of a package (installed under $prefix)
 > > and, if it cannot find what we are looking for, lookup
 > > "automatically" the platform-dependant part of that package.
 > 
 > 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!  ;-)


  -Fred

--
Fred L. Drake, Jr.	     <fdrake@acm.org>
Corporation for National Research Initiatives