quantorconsulting / mkdocs_build_plantuml

MkDocs plugin to help generate your plantuml images locally or remotely as files (NOT inline)
MIT License
57 stars 15 forks source link

v1.10 breaks on python versions < 3.12 #37

Closed koffie closed 2 months ago

koffie commented 3 months ago

In the latest version of this plugin the new https://docs.python.org/3/library/pathlib.html#pathlib.Path.walk command is now beeing used. This was only added in python 3.12 according to the documentation there.

Bulding the documentation using the v1.10 with python 3.11 leads to tracebacks like:

  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mkdocs/__main__.py", line 286, in build_command
    build.build(cfg, dirty=not clean)
  File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/build.py", line 280, in build
    config.plugins.on_pre_build(config=config)
  File "/usr/local/lib/python3.11/site-packages/mkdocs/plugins.py", line 530, in on_pre_build
    return self.run_event('pre_build', config=config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mkdocs/plugins.py", line 509, in run_event
    result = method(**kwargs)
             ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mkdocs_build_plantuml_plugin/plantuml.py", line 75, in on_pre_build
    for subdir, _, files in Path(root.src_dir).walk():
                            ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PosixPath' object has no attribute 'walk'
error: Command '['mkdocs', 'build', '--clean', '--config-file', '/builds/mike-mkdocsu8xn66i7.yml']' returned non-zero exit status 1.

Could either the Path.walk be replaced again by os.walk like it used to be before this commit: https://github.com/quantorconsulting/mkdocs_build_plantuml/commit/f62504bf3640602968ca3dad98d0a44e34eec870 ? Or could setup.py by updated to specify that this plugin needs python versions >= 3.12?

christo-ph commented 3 months ago

Thanks for reporting and sorry for the inconvenience. I changed the requirement in setup.py, released under 1.11.0

Can you confirm this works?

koffie commented 3 months ago

Thanks for the quick fix. It indeed works. Trying to install with python3.11 gives:

maartenderickx$ pip install mkdocs-build-plantuml-plugin==1.11.0
ERROR: Ignored the following versions that require a different python version: 1.11.0 Requires-Python >=3.12
ERROR: Could not find a version that satisfies the requirement mkdocs-build-plantuml-plugin==1.11.0 (from versions: 1.0.0, 1.1.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0, 1.6.0, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.8.0, 1.9.0, 1.10.0)
ERROR: No matching distribution found for mkdocs-build-plantuml-plugin==1.11.0

as expected.

TheDutchDev commented 2 months ago

We experienced the same issue. Any chance you could push 1.11.0 as default when installing with pip? For now I'll add the specific version to the build pipeline.

EDIT: version 1.11.0 doesn't seem to be available on ubuntu 22.04 at all yet, so gonna revert back to v1.9.0 for now.

KyleKing commented 2 months ago

@christo-ph, could you yank the v1.10.0 release on PyPi? That way if you aren't on Python 3.12, updating would install v1.9.0

christo-ph commented 2 months ago

@KyleKing done

KyleKing commented 2 months ago

Thanks!!