yaqwsx / KiKit

Automation tools for KiCAD
https://yaqwsx.github.io/KiKit
MIT License
1.49k stars 200 forks source link

Bundled versioneer.py is not compatible with python 3.12 #680

Closed shapirus closed 3 months ago

shapirus commented 3 months ago

Prerequisites

KiKit version

1.5.1

KiCAD version

8.0.1

Operating system

Debian sid

Description

The version of versioneer.py which is bundled with KiKit uses attributes which are no longer supported by python (definitely by 3.12, not sure about earlier versions). Building a debian package from the kikit pypi package using py2dsp or other tools like this fails:

$ dpkg-buildpackage -rfakeroot -b
dpkg-buildpackage: info: source package kikit
dpkg-buildpackage: info: source version 1.5.1-0~py2deb
dpkg-buildpackage: info: source distribution UNRELEASED
dpkg-buildpackage: info: source changed by absh <absh@desktop.shlocal>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build .
dpkg-source: info: using options from kikit-1.5.1/debian/source/options: --extend-diff-ignore=^[^/]+.(egg-info|dist-info)/
 debian/rules clean
dh clean --with python3 --buildsystem=pybuild
   dh_auto_clean -O--buildsystem=pybuild
I: pybuild base:311: python3.12 setup.py clean 
/tmp/kikit/result/kikit-1.5.1/versioneer.py:421: SyntaxWarning: invalid escape sequence '\s'
  LONG_VERSION_PY['git'] = '''
Traceback (most recent call last):
  File "/tmp/kikit/result/kikit-1.5.1/setup.py", line 45, in <module>
    version=versioneer.get_version(),
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/kikit/result/kikit-1.5.1/versioneer.py", line 1480, in get_version
    return get_versions()["version"]
           ^^^^^^^^^^^^^^
  File "/tmp/kikit/result/kikit-1.5.1/versioneer.py", line 1412, in get_versions
    cfg = get_config_from_root(root)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/kikit/result/kikit-1.5.1/versioneer.py", line 342, in get_config_from_root
    parser = configparser.SafeConfigParser()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?
E: pybuild pybuild:389: clean: plugin distutils failed with: exit code=1: python3.12 setup.py clean 
dh_auto_clean: error: pybuild --clean -i python{version} -p "3.12 3.11" returned exit code 13
make: *** [debian/rules:5: clean] Error 13
dpkg-buildpackage: error: debian/rules clean subprocess returned exit status 2

Versioneer 0.29 seems to fix this particular error.

Side note. Why build a proper deb package instead of pip? For one thing, that's the right way of doing things in Debian. But also because the documented way of doing it with pip fails:

$ pip3 install kikit
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Steps to Reproduce

  1. cd $(mktemp -d)
  2. py2dsp kikit
  3. cd result/kikit-1.5.1
  4. dpkg-buildpackage -b
yaqwsx commented 3 months ago

Versioneer upgraded in e0c312ae105c8d2a4626b83ac86324b1a1be75ba