Skip to content

use importlib instead of imp module on Python3.12 #208

@yuzibo

Description

@yuzibo

Hi,

I just google some links about imp was deprecated on python3.12. On Debian, we have one ftbfs below:

    cmd_obj.ensure_finalized()
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 111, in ensure_finalized
    self.finalize_options()
  File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 225, in finalize_options
    parsed_version = packaging.version.Version(self.egg_version)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/setuptools/_vendor/packaging/version.py", line 198, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: 'unknown'
E: pybuild pybuild:389: build: plugin distutils failed with: exit code=1: /usr/bin/python3 setup.py build 

But the back track was unclear, the question is raised from imp imported, so I purpose one patch:

--- a/pycorrfit/_version.py
+++ b/pycorrfit/_version.py
@@ -12,7 +12,7 @@
 # Put the entire script into a `True` statement and add the hint
 # `pragma: no cover` to ignore code coverage here.
 if True:  # pragma: no cover
-    import imp
+    import importlib
     import os
     from os.path import abspath, basename, dirname, join
     import subprocess

It seems it works on my local build. Could you have a look at this?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions