brechtm/rinohtype

TypeError: Can't instantiate abstract class DynamicRinohDistribution with...

BobDenny opened this issue · 12 comments

Is there an existing issue for this?

  • I have searched the existing issues

Sphinx or rinoh output

(.venv) D:\dev\astro\ASCOM Alpaca\Alpyca\docs>make html
Running Sphinx v5.3.0

Exception occurred:
  File "D:\dev\astro\ASCOM Alpaca\Alpyca\.venv\lib\site-packages\rinoh\resource.py", line 187, in <module>
    _DISTRIBUTION = DynamicRinohDistribution()
TypeError: Can't instantiate abstract class DynamicRinohDistribution with abstract methods locate_file, read_text
The full traceback has been saved in C:\Users\ROBERT~1.DEN\AppData\Local\Temp\sphinx-err-5zzmd_z9.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

Source files

https://github.com/ASCOMInitiative/alpyca

Clone this, open shell into the virtual environment, type make html. By the way this identical message happens on Linux, so youj can clone it to a Linux machine though in my report it is Windows. Only the path changes, the substance of the error is identical.

Also I did install 0.5.5 from your GitHub as recommended above.

Versions

(.venv) D:\dev\astro\ASCOM Alpaca\Alpyca\docs>rinoh --versions
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\dev\astro\ASCOM Alpaca\Alpyca\.venv\Scripts\rinoh.exe\__main__.py", line 4, in <module>
  File "D:\dev\astro\ASCOM Alpaca\Alpyca\.venv\lib\site-packages\rinoh\__init__.py", line 41, in <module>
    from . import resource
  File "D:\dev\astro\ASCOM Alpaca\Alpyca\.venv\lib\site-packages\rinoh\resource.py", line 187, in <module>
    _DISTRIBUTION = DynamicRinohDistribution()
TypeError: Can't instantiate abstract class DynamicRinohDistribution with abstract methods locate_file, read_text

On Linux:

(.venv) pi@rpi1:~/Documents/alpyca/docs $ rinoh --versions
Traceback (most recent call last):
  File "/home/pi/Documents/alpyca/.venv/bin/rinoh", line 5, in <module>
    from rinoh.__main__ import main
  File "/home/pi/Documents/alpyca/.venv/lib/python3.9/site-packages/rinoh/__init__.py", line 41, in <module>
    from . import resource
  File "/home/pi/Documents/alpyca/.venv/lib/python3.9/site-packages/rinoh/resource.py", line 187, in <module>
    _DISTRIBUTION = DynamicRinohDistribution()
TypeError: Can't instantiate abstract class DynamicRinohDistribution with abstract methods locate_file, read_text

I tried this outside the virtual environment .venv on Linux and and I get this:

pi@rpi1:~ $ rinoh --versions
rinohtype 0.5.5 (in development)
Sphinx 4.5.0
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]
Linux-5.15.76-v8+-aarch64-with-glibc2.31

This started happening to me when I use Poetry to update dependencies for my project (in the .venv). So this is "caused" by a newer dependency. Let me try to run this down. I can make PDF with these things, and witoout the stuff in my .venv. Annoying but I can at least make PDF now if I carefully keep my global site-packages as is.

I also ran into this issue, after updating all dependencies in the venv of my project to their latest versions. Downgrading to rinohtype 0.5.3 solved the issue for me, though I haven't investigated why yet. I'm running Python 3.8.10.

It's a small project. Here's a pip freeze:

alabaster==0.7.12 appdirs==1.4.4 Babel==2.11.0 certifi==2022.12.7 charset-normalizer==2.1.1 rinohtype==0.5.3 smmap==5.0.0 snowballstemmer==2.2.0 sphinx==6.1.1 sphinxcontrib-applehelp==1.0.2 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 urllib3==1.26.13 zipp==3.11.0

Updating to rinohtype 0.5.4 from here triggers the error

Edit: additionally tried updating to Python 3.11.1, and that runs the newest rinohtype version without any problems. I'll stick with that solution for now.

I cloned the alpyca repository and did a poetry install. That didn't install Sphinx, rinohtype or the other dependencies required for building the docs. Installing them manually using pip, make html and make rinoh work fine for me. These are the versions of the packages installed:

$ rinoh --versions
rinohtype 0.5.4 (2022-06-17)
Sphinx 5.3.0
Python 3.10.1 (main, Dec 11 2021, 18:34:42) [Clang 13.0.0 (clang-1300.0.29.3)]
macOS-12.6-x86_64-i386-64bit

I was able to reproduce the issue by installing importlib-metadata. I'm afraid that its API changed again 😢 If you're running Python 3.9+, I think you should be able to uninstall it from your virtualenv.

Related: sphinx-doc/sphinx#10157

calve commented

Hi ! running into this aswell. Shouldn't we pin importlib_metadata to a version < 6 at

importlib-metadata = {version = ">=0.21", python = "<3.8"}
and cut a release ?

For lost readers, I fixed my build by adding

importlib_metadata==5.2.0

in its requirements.txt

Shouldn't we pin importlib_metadata to a version < 6 at

I'm hesitatant to set version constraints on dependencies, since it could cause conflicts with other packages requiring a newer version in the future. I added NotImplementedError-throwing implementations for those abstract methods to avoid the crash.

@BobDenny (in response to your removed comments) Great to read that you've been able to get around the problem!

I wasn't very explicit in my last comment, but this problem was fixed in rinohtype and could have saved you some trouble. The fix is not yet available in a release, but it's easy enough to install the current development version (as described in the README):

pip install https://github.com/brechtm/rinohtype/archive/refs/heads/master.zip

P.S. There's no need to remove your comments. They could help other souls running into this issue :-)

@calve nailed it. I had to revert importlib-metadata to a older version, and make a note to myself to avoid ever updating it to 6..x. I'm not big on development/experimental stuff. I'll watch for a production version. Thank you for the help.

You shouldn't be too hesitant to run the development version. At this point, there's not much difference between the releases and the development version. They are more or less just development snapshots at arbitrary points in time.

aut0 commented

Is my understanding correct that "pip install rinohtype" is broken until the fix is released?

@aut0 Yes, that is correct. And thank you for the reminder, I really should make a new release! :-)

@aut0 Version 0.5.5 has finally landed!