pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

pdoc3 uses the soon to be deprecated distutils package

Open 991jo opened this issue 3 years ago • 6 comments

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

  • pdoc version: pdoc3 0.10.0
  • python version: 3.10.2

991jo avatar Apr 04 '22 18:04 991jo

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()?

kernc avatar Apr 04 '22 23:04 kernc

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

braniii avatar Apr 24 '22 10:04 braniii

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

timkofu avatar May 16 '22 12:05 timkofu

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'

LostInDarkMath avatar Dec 30 '23 07:12 LostInDarkMath

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.

briansturgill avatar Jan 09 '24 17:01 briansturgill

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

mshadbolt avatar Jan 26 '24 22:01 mshadbolt