miyakogi / m2r

Markdown to reStructuredText converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: module 'mistune' has no attribute 'BlockGrammar' in line 58 of m2r.py

mcepl opened this issue · comments

When packaging new version of mistune (2.0.0-rc1) is included into openSUSE/Factory, this package’s test suite starts failing:

[   32s] + /usr/bin/python3.6 setup.py build '--executable=/usr/bin/python3.6 -s'
[   32s] Traceback (most recent call last):
[   32s]   File "setup.py", line 14, in <module>
[   32s]     from m2r import parse_from_file
[   32s]   File "/home/abuild/rpmbuild/BUILD/m2r-0.2.1/m2r.py", line 58, in <module>
[   32s]     class RestBlockGrammar(mistune.BlockGrammar):
[   32s] AttributeError: module 'mistune' has no attribute 'BlockGrammar'
[   32s] error: Bad exit status from /var/tmp/rpm-tmp.G27V7P (%build)

Complete build log with all versions of packages used and steps taken.

I am getting this as well. Setting mistune<2.0.0 to fix the problem for now.

This issue seems to be specific to Python 3.6.

With Python 3.8 m2r==0.2.1 and mistune==2.0.0 seem to work well together 🤔

This issue seems to be specific to Python 3.6.

My CI uses the latest 3.9 (via latest Sphinx).

I am facing the same issue right now and it looks like mistune v2.* versions had huge revamp and there is no BlockGrammar class anymore by the looks of it -> https://github.com/lepture/mistune/blob/v2.0.0a1/mistune/__init__.py#L54-L59 . I think m2r2 needs to constraint the mistune version to <2.0.0 as suggested in one of the above comments?

The PR is waiting to be merged to fix this issue. Seems like this repository is not being maintained anymore.

The PR is waiting to be merged to fix this issue. Seems like this repository is not being maintained anymore.

Fixing the issue should actually mean fixing the issue.

Just to confirm that even with m2r-0.2.1 and mistune-2.0.0 I get exactly the same result.

Complete build log showing all packages used and steps taken to achieve the failed test.

@mcepl I agree that fixing the issue means revamping m2r2 with upstream changes in the API of mistune. But seems like no one is maintaining this repo anymore. As long as mistune>=2.0.0 is used to build m2r2, this will always break (due to changes in API in mistune>=2.0.0). So the quick fix would be to lock mistune<2.0.0.

Sounds like an m2r3 is needed 😆

Wait, I have just realised that this is indeed "old" repository and the new "m2r2" is a fork of this repo and being actively maintained here -> https://github.com/CrossNox/m2r2 . They have already have a PR on this issue and hopefully it will be released soon.

They have already have a PR on this issue and hopefully it will be released soon.

And again, that PR is not fix just freezing old version of mistune.

I also have this issue with Python 3.7:

- m2r=0.2.1=py_0
- markupsafe=2.0.1=py37h5e8e339_0
- mistune=2.0.0=pyhd8ed1ab_1

I am guessing the issue is from mistune 2.0.0.
If they follow semantic versioning, the jump from 1.X to 2.X means backwards incompatible changes to the API.
A revert to an older version might be the actual "fix".

I am guessing the issue is from mistune 2.0.0. If they follow semantic versioning, the jump from 1.X to 2.X means backwards incompatible changes to the API. A revert to an older version might be the actual "fix".

It is not the fix, it is a workaround. When you make your program dependent on another library, you get yourself into a debt and a dependency on somebody else’s plans, which you have no control over, but to which you have to accommodate. Unless you follow that somebody else’s plans, your package is broken and your users will be unhappy with you. In the end, the easiest thing for me is to get rid of m2r in OpenSUSE, because it is apparently unmaintained.

Can you update pypi with this? If I pip install m2r I get this error. Works with 0.8.4 mistune.

Sounds like an m2r3 is needed 😆

I forked a new project, sphinx-mdinclude from m2r2, and did extensive work to upgrade to mistune 2.0. Details available at https://sphinx-mdinclude.readthedocs.io/en/latest/

I just hit the same issue trying generate jupyter-server documentation.
Any chance to make new release updated against latest mistune?

Any plans to update m2r for mistune 2.x? 🤔