mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-05 09:17:57 +03:00
Replace deprecated imp
usage with importlib
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
79da19ad07
commit
758eb74ba3
13
setup.py
13
setup.py
@ -10,6 +10,7 @@ if sys.version_info.major < 3:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
|
import importlib.util
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
@ -33,14 +34,10 @@ def _import_buildconfig():
|
|||||||
# A bit of crazyness to import the buildconfig file without importing
|
# A bit of crazyness to import the buildconfig file without importing
|
||||||
# the rest of virtinst, so the build process doesn't require all the
|
# the rest of virtinst, so the build process doesn't require all the
|
||||||
# runtime deps to be installed
|
# runtime deps to be installed
|
||||||
import warnings
|
spec = importlib.util.spec_from_file_location(
|
||||||
|
'buildconfig', 'virtinst/buildconfig.py')
|
||||||
# 'imp' is deprecated. We use it elsewhere though too. Deal with using
|
buildconfig = importlib.util.module_from_spec(spec)
|
||||||
# the modern replacement when we replace all usage
|
spec.loader.exec_module(buildconfig)
|
||||||
with warnings.catch_warnings():
|
|
||||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
||||||
import imp
|
|
||||||
buildconfig = imp.load_source('buildconfig', 'virtinst/buildconfig.py')
|
|
||||||
if "libvirt" in sys.modules:
|
if "libvirt" in sys.modules:
|
||||||
raise RuntimeError("Found libvirt in sys.modules. setup.py should "
|
raise RuntimeError("Found libvirt in sys.modules. setup.py should "
|
||||||
"not import virtinst.")
|
"not import virtinst.")
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# This work is licensed under the GNU GPLv2 or later.
|
# This work is licensed under the GNU GPLv2 or later.
|
||||||
# See the COPYING file in the top-level directory.
|
# See the COPYING file in the top-level directory.
|
||||||
|
|
||||||
import imp
|
import importlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Need to do this before any tests or virtinst import
|
# Need to do this before any tests or virtinst import
|
||||||
@ -18,8 +18,9 @@ os.environ.pop("LANGUAGE", None)
|
|||||||
# pylint: disable=wrong-import-position
|
# pylint: disable=wrong-import-position
|
||||||
from virtinst import buildconfig
|
from virtinst import buildconfig
|
||||||
from virtinst import log, reset_logging
|
from virtinst import log, reset_logging
|
||||||
|
|
||||||
# This sets all the cli bits back to their defaults
|
# This sets all the cli bits back to their defaults
|
||||||
imp.reload(buildconfig)
|
importlib.reload(buildconfig)
|
||||||
|
|
||||||
from tests import utils
|
from tests import utils
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user