Skip to content

Commit 3090a48

Browse files
setup: migrate from distutils
distutils is starting to get removed from the standard library since 2020 and has been phased out since 2014 (or earlier). Distutils has been exposed only recently, so relatively old Python (like 3.8) setuptools doesn't have them yet. 1. https://peps.python.org/pep-0632 2. pypa/setuptools@974dbb0 Part of #270
1 parent 2ee10b3 commit 3090a48

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

setup.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
import codecs
77
import os
88

9-
try:
10-
from setuptools import setup, find_packages
11-
from setuptools.command.build_py import build_py
12-
except ImportError:
13-
from distutils.core import setup, find_packages
14-
from distutils.command.build_py import build_py
9+
from setuptools import setup, find_packages
10+
from setuptools.command.build_py import build_py
1511

1612
# Extra commands for documentation management
1713
cmdclass = {}

test/setup_command.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
"""
55

66
import unittest
7-
from distutils.errors import DistutilsError
87

98
import setuptools
109

10+
try:
11+
from setuptools.errors import BaseError
12+
except ModuleNotFoundError:
13+
# pylint: disable=deprecated-module
14+
from distutils.errors import DistutilsError as BaseError
15+
1116
class Test(setuptools.Command):
1217
"""
1318
Class implementing `python setup.py test`.
@@ -37,4 +42,4 @@ def run(self):
3742
test_runner = unittest.TextTestRunner(verbosity=2)
3843
result = test_runner.run(tests)
3944
if not result.wasSuccessful():
40-
raise DistutilsError('There are failed tests')
45+
raise BaseError('There are failed tests')

0 commit comments

Comments
 (0)