Skip to content

Commit 677801a

Browse files
committed
RF: use importlib for importing + style change
Use importlib to test module import. Put 'and' at end of line instead of beginning.
1 parent 310f033 commit 677801a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ def run(self):
193193
required_failed.append(package)
194194
else:
195195
good_packages.append(package)
196-
if (isinstance(package, setupext.OptionalBackendPackage)
197-
and package.runtime_check()
198-
and default_backend is None):
196+
if (isinstance(package, setupext.OptionalBackendPackage) and
197+
package.runtime_check() and
198+
default_backend is None):
199199
default_backend = package.name
200200
print_raw('')
201201

setupext.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import print_function, absolute_import
22

3+
from importlib import import_module
4+
35
from distutils import sysconfig
46
from distutils import version
57
from distutils.core import Extension
@@ -1655,7 +1657,7 @@ def runtime_check(self):
16551657
"""
16561658
pkg_name = 'tkinter' if PY3min else 'Tkinter'
16571659
try:
1658-
__import__(pkg_name)
1660+
import_module(pkg_name)
16591661
except ImportError:
16601662
return False
16611663
return True

0 commit comments

Comments
 (0)