I've been working on porting the changes from version 0.25 of
commonmark.js
to Python. 0.25 introduces an abstract renderer
class inherited by the HtmlRenderer. These new classes are in
render/html.js
and render/renderer.js
.
I'm trying to keep the Python code as similar to the JavaScript
code as possible for maintainability, and I ran into some
exasperating problems with my new render/html.py
and render/renderer.py
files.
CommonMark-py has a custom test runner called
run_spec_tests.py
that hooks up to
commonmark's implementation-independent spec.txt
file. Here's what the beginning of my debugging process was
like:
$ ./venv/bin/python setup.py test running test Traceback (most recent call last): File "CommonMark/tests/run_spec_tests.py", line 10, infrom CommonMark.render.html import HtmlRenderer ImportError: No module named 'CommonMark.render'
So, I've seen this error in the past, and it's meant that
render/__init__.py
doesn't exist.
That's the first thing I checked, but it was already there
so that didn't fix it.
There's a bunch of strangeness around debugging this problem.
For example, I can import CommonMark.render
in
the Python shell, and also the actual class I need to
get at from the tests:
$ ./venv/bin/python setup.py install running install ... $ ./venv/bin/python Python 3.5.1+ (default, Mar 30 2016, 22:46:26) [GCC 5.3.1 20160330] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import CommonMark.render >>> >>> from CommonMark.render.html import HtmlRenderer >>>
If I put an ipdb breakpoint before the import statement,
I can also import CommonMark.render
. But if I try
this in a plain pdb breakpoint, I do get the error.
I've been debugging this with Python 3.5 but the library's also compatible with Python 2.7, and I get the same error with Python 2.7. Here's the branch I'm working on: https://github.com/rtfd/CommonMark-py/commits/spec-0.25 I guess I should really open a StackOverflow question, since I haven't solved the problem yet.