Skip to content

Commit 1f313cb

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 1f313cb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: setup.py

+11-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,17 @@
139
import shutil
1410
import shlex
1511

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

1724
SKIP_CYTHON_FILE = '__dont_use_cython__.txt'
1825

0 commit comments

Comments
 (0)