slaclab / pysmurf

Other
2 stars 9 forks source link

Update versioneer for Python 3.12 compatibility #791

Closed BrianJKoopman closed 4 months ago

BrianJKoopman commented 5 months ago

Description

On Python 3.12 when installing pysmurf I ran into this error:

Collecting pysmurf@ git+https://github.com/slaclab/pysmurf.git@main (from -r requirements.txt (line 40))
  Cloning https://github.com/slaclab/pysmurf.git (to revision main) to /tmp/pip-install-ejqfh829/pysmurf_6b504bcac0334db6928411aabaeebcf1
  Running command git clone --filter=blob:none --quiet https://github.com/slaclab/pysmurf.git /tmp/pip-install-ejqfh829/pysmurf_6b504bcac0334db6928411aabaeebcf1
  Resolved https://github.com/slaclab/pysmurf.git to commit 1959443676247c42ba3017cbd37ceb25f348f748
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      /tmp/pip-install-ejqfh829/pysmurf_6b504bcac0334db6928411aabaeebcf1/versioneer.py:420: SyntaxWarning: invalid escape sequence '\s'
        LONG_VERSION_PY['git'] = '''
      Traceback (most recent call last):
        File "/home/koopman/.venv/user/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/koopman/.venv/user/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/koopman/.venv/user/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-58am1pvk/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-58am1pvk/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-58am1pvk/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-58am1pvk/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 19, in <module>
        File "/tmp/pip-install-ejqfh829/pysmurf_6b504bcac0334db6928411aabaeebcf1/versioneer.py", line 1479, in get_version
          return get_versions()["version"]
                 ^^^^^^^^^^^^^^
        File "/tmp/pip-install-ejqfh829/pysmurf_6b504bcac0334db6928411aabaeebcf1/versioneer.py", line 1411, in get_versions
          cfg = get_config_from_root(root)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-install-ejqfh829/pysmurf_6b504bcac0334db6928411aabaeebcf1/versioneer.py", line 341, in get_config_from_root
          parser = configparser.SafeConfigParser()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

SafeConfigParser was deprecated in Python 3.2, and removed in Python 3.12.

Versioneer was still using SafeConfigParser. This PR just runs the update process for versioneer, using versioneer 0.29, which resolves the issue.

Jira Issue

None.

Tests done on this branch

Ran python -m pip install . on Python 3.12 before the change, resulting in the above failure. Ran it again after the change on Python 3.12 and 3.8, both of which succeed.

Function interfaces that changed

No interface changes.

swh76 commented 4 months ago

Not sure why, but couldn't merge this - I think because the branch was forked. https://github.com/slaclab/pysmurf/pull/793 is just a nonforked copy which I was able to merge. Closing this PR.