Skip to content

Commit

Permalink
Use the new sysconfig module instead of distutils
Browse files Browse the repository at this point in the history
Closes #98.

Maybe helps with #100?
  • Loading branch information
fsouza committed Aug 30, 2022
1 parent 3aed3dd commit 2a4877a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions autoflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down

0 comments on commit 2a4877a

Please sign in to comment.