|
cimport across directories: msg#00021python.pyrex
Hi everyone, my name is Martin Albrecht and I use Pyrex in the SAGE [1] project by William Stein. I believe to have found and fixed a bug in Pyrex which prevented cimporting modules across directory borders. This issue has been discussed on this list a while back [2]: The problem seems to boil down to: either Pyrex cannot find the pxd file or python cannot find the module at run time. Consider e.g. you have some module in the directory bar called foo. You can (a) either cimport foo and add bar to the pyrexc include path or (b) you can cimport bar.foo and add the top level directory to the include path. In case (a) pyrexc finds the file but python gets confused with a module foo. In case (b) pyrexc complaints not to find the file foo.bar.pxd. I fixed the later one which was due to the fact that the dots where not replaced by directory delimiters so search_include_directories() can handle the filename. --- home/martin/pyrex-0.9.4.1/Pyrex/Compiler/Main.py 2006-04-15 09:24:02.000000000 +0200 +++ opt/sage/local/lib/python2.4/site-packages/Pyrex/Compiler/Main.py 2006-06-15 21:25:20.000000000 +0200 @@ -91,7 +91,10 @@ def find_pxd_file(self, module_name, pos): # Search include directories for the .pxd file # corresponding to the given (full) module name. - pxd_filename = "%s.pxd" % module_name + if "." in module_name: + pxd_filename = "%s.pxd" % module_name.replace(".","/") + else: + pxd_filename = "%s.pxd" % module_name return self.search_include_directories(pxd_filename, pos) def find_include_file(self, filename, pos): Regards, Martin Albrecht [1] http://modular.math.washington.edu/sage/ [2] http://lists.copyleft.no/pipermail/pyrex/2005-March/001141.html -- name: Martin Albrecht _pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99 _www: http://www.informatik.uni-bremen.de/~malb _icq: 177334829 _jab: martinralbrecht@xxxxxxxxxxxxx |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Circular cimports: 00021, Greg Ewing |
|---|---|
| Next by Date: | Re: cimport across directories: 00021, Lenard Lindstrom |
| Previous by Thread: | Circular cimportsi: 00021, Mike Wyatt |
| Next by Thread: | Re: cimport across directories: 00021, Lenard Lindstrom |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |