Closed 72ba7a0a-cd40-4637-9752-0f81b6e4c176 closed 15 years ago
I think that modifying the regex like this (adding two '^'
characters) will fix the problem. (It fixes the above test case, but I don't have time to do a real test, or submit a real patch, right now.)
r'^ *(?:cimport +(\S+))|^(?:from +(\S+) *cimport)|^(?:include *[\'"]([^\'"]+)[\'"])'
some more thoughts
the include keyword is deprecated cython doc,
the current regexp misses other cython patterns that involve dependancies:
cimport mod1, mod2
and
cdef extern from "toto.h":
....
Here is a first attempt to fix this,
import re
dep_regex = re.compile(r'^ *(?:(?:(?:(?:include)|(?:cdef +extern + from)) +[\'"]([^\'"]+)[\'"])|(?:from +(\w+) *cimport)|(?:cimport +([^ \t\n\r\f\v,]+)(?: *, *([^ \t\n\r\f\v,]+))*))', re.MULTILINE)
teststr = """include "yes1.h"
include "yes2.h"
include "yes3.h"
include 'yes4.h'
#include "no5.h"
# include "no6.h"
cimport yes7
cimport yes8
#cimport no9
# cimport no10
from yes11 cimport toto
from yes12 cimport toto as tata
#from no13 cimport toto as tata
cdef extern from "yes14.h"
cimport yes15 , yes15b
cimport yes16, yes16b
cimport yes17, yes17b , yes17c
"""
print 'toto'
for m in dep_regex.finditer(teststr):
print m.groups()
However, for some reason, it doesn't catch yes14.h nor yes17b. So this is not yet functional (nor elegant). Any suggestion is welcome.
Attachment: 5060-deps.patch.gz
The original bug was due to the fact that "^ *" was only required for the first grouping.
Given that more than one module could be cimported in a single statement, it took an extra loop in the parsing code as well.
This looks good. Man, that is one serious regular expression.
Merged in Sage 3.3.alpha2
Cheers,
Michael
Hello,
reading the code, I see another problem if ones has the following line in its .pyx:
cimport mod#mycomment
I such a case, we'll look for a dependency mod#mycomment.pxd instead of mod.pxd.
Otherwise, the patch solves the aforementioned problems.
Cheers
Please do not reopen closed tickets -- it makes things much more difficult for Michael. Instead, just open a new one.
I've opened #5103 for this.
Actually, I'm going to reclose this ticket, since the original issues reported are fixed, and I've opened #5104 for this new issue.
Oops. Mike, I'm closing your ticket as a dupe, since I spent more time reformatting the text in mine. :P
using sage 3.2.3, I'm trying to build a new module with a .pxd file containing this line
note that the line is commented. The build fails with the following traceback
There is probably a problem with the regexp on line 228 of setup.py. One can reprouce the bug with this snipet
which results in
Component: build
Issue created by migration from https://trac.sagemath.org/ticket/5060