Skip to content

Commit 9499f7c

Browse files
committed
Use distutils provided by setuptools
The distutils module provided by the stdlib has been deprecated in Python 3.10. This PR sets an env var that is read by setuptools which will shim its vendored copy of distutils if present avoiding a failure once distutils is removed from the stdlib. Signed-off-by: Jordan Borean <[email protected]>
1 parent 2bde020 commit 9499f7c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

setup.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/usr/bin/env python
22
from __future__ import print_function
33

4-
from setuptools import setup
5-
from setuptools import Distribution
6-
from setuptools.command.sdist import sdist
7-
from setuptools.extension import Extension
84
import subprocess
95
import platform
106
import re
@@ -13,6 +9,16 @@
139
import shutil
1410
import shlex
1511

12+
# Enables the vendored distutils in setuptools over the stdlib one to avoid the derpecation warning.
13+
# Must be done before importing setuptools (setuptools also must be imported before distutils).
14+
# https://github.com/pypa/setuptools/blob/main/docs/deprecated/distutils-legacy.rst
15+
os.environ['SETUPTOOLS_USE_DISTUTILS'] = 'local'
16+
17+
from setuptools import setup # noqa: E402
18+
from setuptools import Distribution # noqa: E402
19+
from setuptools.command.sdist import sdist # noqa: E402
20+
from setuptools.extension import Extension # noqa: E402
21+
1622

1723
SKIP_CYTHON_FILE = '__dont_use_cython__.txt'
1824

0 commit comments

Comments
 (0)