[Twisted-Python] mktap searchpath
Jp Calderone
exarkun at intarweb.us
Tue Jun 10 00:25:05 MDT 2003
On Tue, Jun 10, 2003 at 04:07:26PM +1000, Andrew Bennetts wrote:
> On Tue, Jun 10, 2003 at 01:15:54AM -0400, Jp Calderone wrote:
> > On Tue, Jun 10, 2003 at 01:29:28PM +1000, Andre Perry wrote:
> > > When calling mktap with a twisted dir in the current directory the real
> > > twisted dir is not searched for plugins.tml. The twisted dir in the
> > > current directory does not contain a plugins.tml file.
> > >
> > > Is this the desired behaviour or a bug?
> >
> > This is the desired behavior. You cannot have them both searched, or you
> > will end up with doubly registered plugins, each of which refer to whatever
> > modules come first in the python import search path -- which means we should
> > pick up the information from whichever plugins.tml file we find first too,
> > and ignore anything found later.
>
> You're assuming his ~/twisted directory contains the Twisted source, rather
> than just being a directory with random stuff in it. If that directory
> contained a __init__.py file, then it would be a Python package and
> presumably Python would then be unable to import the real Twisted, so that's
> not a problem with mktap. But if the directory *doesn't* contain
> __init__.py, then there's no ambiguity in Python's import search path, but
> mktap still will check ~/twisted for plugins.tml, but not
> os.path.basename(twisted.__file__).
>
> So mktap will treat the search path differently to Python's import
> mechanisms, at least in the case where a directory has a name that conflicts
> with a later python package, but doesn't have an __init__.py.
>
> This smells like a bug to me, but I could be wrong.
>
Close -- the directory won't be added to the seen-directory-cache unless
it also contains a file named "plugins.tml". It is true that it is added to
this cache even if it does not contain __init__.py. This is to keep it from
taking one hundred million years to run (if it checked to see if it was a
package in Python's eyes, it would need to do between 1 and 6 extra
os.path.exists() calls: utterly unacceptable in terms of performance).
Jp
--
In the days when Sussman was a novice Minsky once came to him as he sat
hacking at the PDP-6. "What are you doing?" asked Minsky. "I am training a
randomly wired neural net to play Tic-Tac-Toe." "Why is the net wired
randomly?" asked Minsky. "I do not want it to have any preconceptions of how
to play." Minsky shut his eyes. "Why do you close your eyes?" Sussman asked
his teacher. "So the room will be empty." At that moment, Sussman was
enlightened.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20030610/727e5f57/attachment.sig>
More information about the Twisted-Python
mailing list