|
Re: cimport across directories: msg#00022python.pyrex
On 16 Jun 2006 at 0:06, Martin Albrecht wrote: > 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): > The idea might be sound but the implementation is not portable. It would be better to do a: "%s.pxd" % os.path.join(*module_name.split('.')) Lenard Lindstrom <len-l@xxxxxxxxx> |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | cimport across directories: 00022, Martin Albrecht |
|---|---|
| Next by Date: | Re: cimport across directories: 00022, Greg Ewing |
| Previous by Thread: | cimport across directoriesi: 00022, Martin Albrecht |
| Next by Thread: | Re: cimport across directories: 00022, Greg Ewing |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |