pdoc3 / pdoc

:snake: :arrow_right: :scroll: Auto-generate API documentation for Python projects
https://pdoc3.github.io/pdoc/
GNU Affero General Public License v3.0
1.12k stars 145 forks source link

pdoc3 uses the soon to be deprecated distutils package #392

Open 991jo opened 2 years ago

991jo commented 2 years ago

Apparently distutils is getting deprecated in Python 3.12. For more details see PEP-632

Expected Behavior

Not getting spammed with deprecation warnings.

Actual Behavior

I see some deprecation warnings.

$ pdoc3 <my module here>
<path to venv>/lib/python3.10/site-packages/pdoc/cli.py:490: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.sysconfig import get_python_lib
<path to venv>/lib/python3.10/site-packages/pdoc/cli.py:490: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
  from distutils.sysconfig import get_python_lib
<actual command output>

Steps to Reproduce

  1. Execute pdoc3 with python3.10 on a module. Simply running the --help or --version commands does not work to trigger the deprecation warnings.

Additional info

kernc commented 2 years ago

Thanks. I guess the needed work entails replacing uses of distutils.sysconfig.get_python_lib(): https://github.com/pdoc3/pdoc/blob/f358893e4fcfd7f29857a7ff5491b606ff146d39/pdoc/cli.py#L490-L491 https://github.com/pdoc3/pdoc/blob/2cce30a9b55eeeddc1ed826c8a2ada53777c3eea/pdoc/html_helpers.py#L625-L627 with appropriate calls to sysconfig.get_path()?

braniii commented 2 years ago

I guess this is the relevant replacement function sysconfig.get_path('platlib'), see https://bugs.python.org/issue41282#msg393018 for further infromations.

timkofu commented 2 years ago

PR https://github.com/pdoc3/pdoc/pull/401

LostInDarkMath commented 7 months ago

Is there any progress here? It seems like pdoc3 does not work with Python 3.12 due to this issue: pdoc3 --html --output-dir docs foo --force gives the error

Traceback (most recent call last):
  File "/home/willi/Documents/GitHub/pedantic-python-decorators/.venv/bin/pdoc3", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/willi/Documents/GitHub/pedantic-python-decorators/.venv/lib/python3.12/site-packages/pdoc/cli.py", line 490, in main
    from distutils.sysconfig import get_python_lib
ModuleNotFoundError: No module named 'distutils'
briansturgill commented 7 months ago

Temporarily, I've edited the file: lib/python3.10/site-packages/pdoc/cli.py Replacing lines 490, 491 with: from sysconfig import get_path libdir = get_path('platlib')

This is working for me just fine.

mshadbolt commented 7 months ago

Adding a voice, would be great to have pydoc3 working in python 3.12, thanks