From fb1f1ac95d3269ced243097574b898cd3401a5d1 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Wed, 6 Oct 2021 07:30:49 +1000 Subject: [PATCH] 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 --- setup.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index a0109666..ee0b2e51 100755 --- a/setup.py +++ b/setup.py @@ -1,10 +1,6 @@ #!/usr/bin/env python from __future__ import print_function -from setuptools import setup -from setuptools import Distribution -from setuptools.command.sdist import sdist -from setuptools.extension import Extension import subprocess import platform import re @@ -13,6 +9,17 @@ import shutil import shlex +# Enables the vendored distutils in setuptools over the stdlib one to avoid +# the deprecation warning. Must be done before importing setuptools, +# setuptools also must be imported before distutils. +# https://github.com/pypa/setuptools/blob/main/docs/deprecated/distutils-legacy.rst +os.environ['SETUPTOOLS_USE_DISTUTILS'] = 'local' + +from setuptools import setup # noqa: E402 +from setuptools import Distribution # noqa: E402 +from setuptools.command.sdist import sdist # noqa: E402 +from setuptools.extension import Extension # noqa: E402 + SKIP_CYTHON_FILE = '__dont_use_cython__.txt'