proycon / codemetapy

A Python package for generating and working with codemeta
https://codemeta.github.io/
GNU General Public License v3.0
24 stars 5 forks source link

Remove use of distuitls as deprecated and breaking use in Python 3.12 #50

Closed matthewfeickert closed 2 months ago

matthewfeickert commented 2 months ago

As noted in https://github.com/proycon/codemetapy/commit/71938e0f203bcc03e84a999a34b77d3e94caac0a

https://github.com/proycon/codemetapy/blob/b904d74a3d1739b15168e12fdd3114e4359f639c/codemeta/codemeta.py#L18

distuitls has been deprecated and removed from Python 3.12, so codemetapy now breaks in Python 3.12 (c.f. https://github.com/xrootd/xrootd/issues/1698 for some other info from another project).

Example:

Using pipx only as this is how many people will do so to get a command line utility

root@62201609b254:/# python --version
Python 3.12.3
$ docker run --rm -ti python:3.12 /bin/bash
root@62201609b254:/# python -m pip --quiet install --upgrade pipx
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@62201609b254:/# pipx ensurepath
Success! Added /root/.local/bin to the PATH environment variable.

Consider adding shell completions for pipx. Run 'pipx completions' for instructions.

You will need to open a new terminal or re-login for the PATH changes to take effect.

Otherwise pipx is ready to go! ✨ 🌟 ✨
root@62201609b254:/# . ~/.bashrc 
root@62201609b254:/# pipx install codemetapy
  installed package codemetapy 2.5.2, installed using Python 3.12.3
  These apps are now globally available
    - codemetapy
done! ✨ 🌟 ✨
root@62201609b254:/# codemetapy --inputtype python --no-extras numpy
Traceback (most recent call last):
  File "/root/.local/bin/codemetapy", line 5, in <module>
    from codemeta.codemeta import main
  File "/root/.local/share/pipx/venvs/codemetapy/lib/python3.12/site-packages/codemeta/codemeta.py", line 18, in <module>
    import distutils.cmd  # note: will be removed in python 3.12! TODO constraint <= 3.11 in apk/apt-get in Dockerfile
    ^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'distutils'
root@62201609b254:/# 
proycon commented 2 months ago

Thanks for the report! I have fixed this now and another regression problem regarding setup.py codemeta and released v2.5.3