diff options
author | Cole Robinson <crobinso@redhat.com> | 2021-10-04 15:44:28 -0400 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2021-10-04 16:04:44 -0400 |
commit | 758eb74ba3b687b6ed7e0af76865d6add8d96d06 (patch) | |
tree | 7c90788cf1a6a6d6a0bf71e6f7d1c427d6c0e07d /setup.py | |
parent | 79da19ad075392cab115e528799f32bb6e1f6a2a (diff) | |
download | virt-manager-758eb74ba3b687b6ed7e0af76865d6add8d96d06.tar.gz |
Replace deprecated `imp` usage with `importlib`
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -10,6 +10,7 @@ if sys.version_info.major < 3: sys.exit(1) import glob +import importlib.util import os from pathlib import Path import shutil @@ -33,18 +34,14 @@ def _import_buildconfig(): # A bit of crazyness to import the buildconfig file without importing # the rest of virtinst, so the build process doesn't require all the # runtime deps to be installed - import warnings - - # 'imp' is deprecated. We use it elsewhere though too. Deal with using - # the modern replacement when we replace all usage - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) - import imp - buildconfig = imp.load_source('buildconfig', 'virtinst/buildconfig.py') - if "libvirt" in sys.modules: - raise RuntimeError("Found libvirt in sys.modules. setup.py should " - "not import virtinst.") - return buildconfig.BuildConfig + spec = importlib.util.spec_from_file_location( + 'buildconfig', 'virtinst/buildconfig.py') + buildconfig = importlib.util.module_from_spec(spec) + spec.loader.exec_module(buildconfig) + if "libvirt" in sys.modules: + raise RuntimeError("Found libvirt in sys.modules. setup.py should " + "not import virtinst.") + return buildconfig.BuildConfig BuildConfig = _import_buildconfig() |