From 2a4877a0a05c1613363829f4acbd8925bb228026 Mon Sep 17 00:00:00 2001 From: francisco souza <108725+fsouza@users.noreply.github.com> Date: Mon, 29 Aug 2022 22:14:00 -0400 Subject: [PATCH] Use the new sysconfig module instead of distutils Closes #98. Maybe helps with #100? --- autoflake.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/autoflake.py b/autoflake.py index 9994818..b3941c9 100755 --- a/autoflake.py +++ b/autoflake.py @@ -31,9 +31,9 @@ import signal import string import sys +import sysconfig import tokenize -import distutils.sysconfig import pyflakes.api import pyflakes.messages import pyflakes.reporter @@ -55,19 +55,18 @@ def standard_paths(): """Yield paths to standard modules.""" - for is_plat_spec in [True, False]: - + paths = sysconfig.get_paths() + path_names = ['stdlib', 'platstdlib'] + for path_name in path_names: # Yield lib paths. - path = distutils.sysconfig.get_python_lib( - standard_lib=True, - plat_specific=is_plat_spec, - ) - yield from os.listdir(path) - - # Yield lib-dynload paths. - dynload_path = os.path.join(path, 'lib-dynload') - if os.path.isdir(dynload_path): - yield from os.listdir(dynload_path) + if path_name in paths: + path = paths[path_name] + yield from os.listdir(path) + + # Yield lib-dynload paths. + dynload_path = os.path.join(path, 'lib-dynload') + if os.path.isdir(dynload_path): + yield from os.listdir(dynload_path) def standard_package_names():