wbond / oscrypto

Compiler-free Python crypto library backed by the OS, supporting CPython and PyPy
MIT License
320 stars 70 forks source link

use `importlib` instead of deprecated `imp` module #77

Closed rathann closed 10 months ago

rathann commented 10 months ago

This fixes tests with python 3.12 where the imp module was removed.

This should fix issue #74.

wbond commented 10 months ago

I've tried a few implementations, but the new importlib API is far more complex, so it will require some more work to get it right.

wbond commented 10 months ago

@rathann Can you test out this version on 3.12? I'd try python run.py tests and python run.py ci

rathann commented 10 months ago

@wbond thanks a lot for working on this. python run.py tests passes, but python run.py ci fails with:

$ python3 run.py ci
Traceback (most recent call last):
  File "/builddir/build/BUILD/oscrypto-1.3.0/run.py", line 8, in <module>
    run_task()
  File "/builddir/build/BUILD/oscrypto-1.3.0/dev/_task.py", line 134, in run_task
    task_mod = _import_from('dev.%s' % task, package_root, allow_error=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/oscrypto-1.3.0/dev/_import.py", line 80, in _import_from
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 400, in _call_with_frames_removed
  File "/builddir/build/BUILD/oscrypto-1.3.0/dev/ci.py", line 24, in <module>
    from .coverage import run as run_coverage
  File "/builddir/build/BUILD/oscrypto-1.3.0/dev/coverage.py", line 7, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'

Looks like we missed at least one instance of imp usage.

rathann commented 10 months ago

This fixes run.py ci on 3.12 for me, but it looks like it's still failing the CircleCI tests.