File tree Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change 10
10
sys .exit (1 )
11
11
12
12
import glob
13
+ import importlib .util
13
14
import os
14
15
from pathlib import Path
15
16
import shutil
@@ -33,18 +34,14 @@ def _import_buildconfig():
33
34
# A bit of crazyness to import the buildconfig file without importing
34
35
# the rest of virtinst, so the build process doesn't require all the
35
36
# runtime deps to be installed
36
- import warnings
37
-
38
- # 'imp' is deprecated. We use it elsewhere though too. Deal with using
39
- # the modern replacement when we replace all usage
40
- with warnings .catch_warnings ():
41
- warnings .filterwarnings ("ignore" , category = DeprecationWarning )
42
- import imp
43
- buildconfig = imp .load_source ('buildconfig' , 'virtinst/buildconfig.py' )
44
- if "libvirt" in sys .modules :
45
- raise RuntimeError ("Found libvirt in sys.modules. setup.py should "
46
- "not import virtinst." )
47
- return buildconfig .BuildConfig
37
+ spec = importlib .util .spec_from_file_location (
38
+ 'buildconfig' , 'virtinst/buildconfig.py' )
39
+ buildconfig = importlib .util .module_from_spec (spec )
40
+ spec .loader .exec_module (buildconfig )
41
+ if "libvirt" in sys .modules :
42
+ raise RuntimeError ("Found libvirt in sys.modules. setup.py should "
43
+ "not import virtinst." )
44
+ return buildconfig .BuildConfig
48
45
49
46
50
47
BuildConfig = _import_buildconfig ()
Original file line number Diff line number Diff line change 3
3
# This work is licensed under the GNU GPLv2 or later.
4
4
# See the COPYING file in the top-level directory.
5
5
6
- import imp
6
+ import importlib
7
7
import os
8
8
9
9
# Need to do this before any tests or virtinst import
18
18
# pylint: disable=wrong-import-position
19
19
from virtinst import buildconfig
20
20
from virtinst import log , reset_logging
21
+
21
22
# This sets all the cli bits back to their defaults
22
- imp .reload (buildconfig )
23
+ importlib .reload (buildconfig )
23
24
24
25
from tests import utils
25
26
You can’t perform that action at this time.
0 commit comments