Discussion:
[omniORB] Python packages/directories and generated code.
Nigel Rantor
2007-01-08 19:40:01 UTC
Permalink
Hi all,

I originally sent this to python-list some time ago and didn't really
get any satisfactory answer. I was wondering if anyone here who is using
python had come up against the same problem and how they solved it.

I'm a new to python so it may be that there is a good solution to this
that I just don't know.

Below is the message I sent to python list, that's why it's cuched in
more general terms but of course I'm talking about generating IDL
stubs/skels with omniORBpy/omniidl.

So, if I have a tool that generates python code for me (in my case,
CORBA stubs/skels) in a particular package is there a way of placing my
own code under the same package hierarchy without all the code living in
the same directory structure.

Ideally I would like something like the following:

package_dir/
top_level_package/
generated_code_package/
implementation_code_package/

but have two distinct directories that hold them so that I can simply
delete the generated code and regenerate it without worrying that
anything got left behind.

So, I want something like:

generated_package_dir/
top_level_package/
generated_code_package/

implementation_package_dir/
top_level_package/
implementation_code_package/

Whilst I can create this structure, and add 'generated_package_dir' and
'implementation_package_dir' to PYTHONPATH the fact that both
directories contain 'top_level_package' seems to be causing clashes,
perhaps because there are multiple __init__.py files for
'top_level_package'?

I know that this is possible in Java, Perl and C++ so I am finding it
hard to believe I can't do the same in Python, I just think I'm too new
to know how.

I have spent most of this morning searching through all the docs I can
find, searching on USENET and the web to no avail.

Any help or pointers greatly appreciated.

Regards,

n
Harri Pasanen
2007-01-08 20:32:49 UTC
Permalink
You could probably do it using __path__

from Python Tutorial, 6.4.3 Packages in Multiple Directories:

http://docs.python.org/tut/node8.html#SECTION008430000000000000000

-Harri
Post by Nigel Rantor
Hi all,
I originally sent this to python-list some time ago and didn't
really get any satisfactory answer. I was wondering if anyone here
who is using python had come up against the same problem and how
they solved it.
I'm a new to python so it may be that there is a good solution to
this that I just don't know.
Below is the message I sent to python list, that's why it's cuched
in more general terms but of course I'm talking about generating
IDL stubs/skels with omniORBpy/omniidl.
So, if I have a tool that generates python code for me (in my case,
CORBA stubs/skels) in a particular package is there a way of
placing my own code under the same package hierarchy without all
the code living in the same directory structure.
package_dir/
top_level_package/
generated_code_package/
implementation_code_package/
but have two distinct directories that hold them so that I can
simply delete the generated code and regenerate it without worrying
that anything got left behind.
generated_package_dir/
top_level_package/
generated_code_package/
implementation_package_dir/
top_level_package/
implementation_code_package/
Whilst I can create this structure, and add 'generated_package_dir'
and 'implementation_package_dir' to PYTHONPATH the fact that both
directories contain 'top_level_package' seems to be causing
clashes, perhaps because there are multiple __init__.py files for
'top_level_package'?
I know that this is possible in Java, Perl and C++ so I am finding
it hard to believe I can't do the same in Python, I just think I'm
too new to know how.
I have spent most of this morning searching through all the docs I
can find, searching on USENET and the web to no avail.
Any help or pointers greatly appreciated.
Regards,
n
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Privileged or confidential information may be contained in this message. If you are not the addressee of this message please notify the sender by return and thereafter delete the message, and you may not use, copy, disclose or rely on the information contained in it. Internet e-mail may be susceptible to data corruption, interception and unauthorised amendment for which Wall Street Systems does not accept liability. Whilst we have taken reasonable precautions to ensure that this e-mail and any attachments have been swept for viruses, Wall Street Systems does not accept liability for any damage sustained as a result of viruses. Statements in this message or attachments that do not relate to the business of Wall Street Systems are neither given nor endorsed by the company or its Directors.
Nigel Rantor
2007-01-08 23:13:16 UTC
Permalink
Post by Harri Pasanen
You could probably do it using __path__
http://docs.python.org/tut/node8.html#SECTION008430000000000000000
Thanks Harri,

Well, currently using that to add the other directory, but I need to
have a __init__.py that calls execfile for the __init__.py in the
generated code.

I don't really want to hard code the path to this in my library. I
suppose I may have to go do some real work in __init__.py to
programatically figure out where the generated packages live and find
the __init__.py that needs exec'ing.

It all seems a bit wrong though. Maybe I'm just unlucky to have hit this
one in Python but the package system does seem to suck, at least,
compared to all the others I've used.

I'm not trying to beat on python here, I'm new to it and I love quite a
lot of it already, maybe that means when I find a dark corner that
doesn't match up to my experience with the rest of the language, which
has been good so far.

n
Post by Harri Pasanen
-Harri
Post by Nigel Rantor
Hi all,
I originally sent this to python-list some time ago and didn't
really get any satisfactory answer. I was wondering if anyone here
who is using python had come up against the same problem and how
they solved it.
I'm a new to python so it may be that there is a good solution to
this that I just don't know.
Below is the message I sent to python list, that's why it's cuched
in more general terms but of course I'm talking about generating
IDL stubs/skels with omniORBpy/omniidl.
So, if I have a tool that generates python code for me (in my case,
CORBA stubs/skels) in a particular package is there a way of
placing my own code under the same package hierarchy without all
the code living in the same directory structure.
package_dir/
top_level_package/
generated_code_package/
implementation_code_package/
but have two distinct directories that hold them so that I can
simply delete the generated code and regenerate it without worrying
that anything got left behind.
generated_package_dir/
top_level_package/
generated_code_package/
implementation_package_dir/
top_level_package/
implementation_code_package/
Whilst I can create this structure, and add 'generated_package_dir'
and 'implementation_package_dir' to PYTHONPATH the fact that both
directories contain 'top_level_package' seems to be causing
clashes, perhaps because there are multiple __init__.py files for
'top_level_package'?
I know that this is possible in Java, Perl and C++ so I am finding
it hard to believe I can't do the same in Python, I just think I'm
too new to know how.
I have spent most of this morning searching through all the docs I
can find, searching on USENET and the web to no avail.
Any help or pointers greatly appreciated.
Regards,
n
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Privileged or confidential information may be contained in this message. If you are not the addressee of this message please notify the sender by return and thereafter delete the message, and you may not use, copy, disclose or rely on the information contained in it. Internet e-mail may be susceptible to data corruption, interception and unauthorised amendment for which Wall Street Systems does not accept liability. Whilst we have taken reasonable precautions to ensure that this e-mail and any attachments have been swept for viruses, Wall Street Systems does not accept liability for any damage sustained as a result of viruses. Statements in this message or attachments that do not relate to the business of Wall Street Systems are neither given nor endorsed by the company or its Directors.
------------------------------------------------------------------------
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Loading...