<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2800.1226" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>I have a reason to
generate parts of IDL modules into different directories. Basically, we have
some standard IDL that I have pre-generated and installed into site-packages
using a command like:</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>cd
/commonidl</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>omniidl -I .
-bpython -Wbpackage=coolproduct *</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>ln -s
/commonidl/coolproduct site-packages</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>This allows me to do
imports like:</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>import
coolproduct.modulex.moduley as moduley</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>However, if I want
to extend the modulex IDL in a local directory:</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><FONT face=Arial
size=2>/someproject/IDL</FONT></SPAN>/extended.IDL</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>by
doing:</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>cd <SPAN
class=566004720-17092003><FONT face=Arial
size=2>/someproject/IDL</FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN class=566004720-17092003><FONT face=Arial
size=2>omniidl -I . -I/commonidl -bpython -Wbpackage=coolproduct
*</FONT></SPAN></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN
class=566004720-17092003></SPAN></SPAN></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN class=566004720-17092003>I get another directory
named coolproduct with another__init__.py.</SPAN></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN
class=566004720-17092003></SPAN></SPAN></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN class=566004720-17092003>The problem is that
although omniidl can find the IDL files and generate the directory, python
thinks there is only one place to find the import for coolproduct.modulex. Once
it finds either my local copy or the site-packages copy it won't look for the
other one. Since they both contain parts of modulex, they both need to be
found.</SPAN></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN
class=566004720-17092003></SPAN></SPAN></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN class=566004720-17092003>I can solve this by
making my python path find the local one first and modifying the module paths by
changing the omniidl generated versions of __init__.py in the local directory to
include the incantation:</SPAN></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN
class=566004720-17092003></SPAN></SPAN></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN class=566004720-17092003>from pkgutil import
extend_path<BR>__path__ = extend_path(__path__,
__name__)<BR></SPAN></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN class=566004720-17092003>This seems evil since it
is right below a line that says "# DO NOT EDIT THIS
FILE!"</SPAN></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2><SPAN
class=566004720-17092003><SPAN
class=566004720-17092003></SPAN></SPAN></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial size=2>Is there another way
to make this work, and if not, would this be useful to have an option to
generate the extend_path incantations in the generated __init__.py
files?</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2>Thanks!</FONT></SPAN></DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=566004720-17092003><FONT face=Arial
size=2>-Brian</FONT></SPAN></DIV></BODY></HTML>