diff --git a/changelogs/fragments/70525-setuptools-disutils-reorder.yml b/changelogs/fragments/70525-setuptools-disutils-reorder.yml new file mode 100644 index 00000000000000..756cf13bc77f88 --- /dev/null +++ b/changelogs/fragments/70525-setuptools-disutils-reorder.yml @@ -0,0 +1,7 @@ +bugfixes: +- > + Address the deprecation of the use of stdlib + distutils in packaging. It's a short-term hotfix for the problem + (https://github.com/ansible/ansible/issues/70456, + https://github.com/pypa/setuptools/issues/2230, + https://github.com/pypa/setuptools/commit/bd110264) diff --git a/setup.py b/setup.py index 0398473d5e053a..9e0338f49638ce 100644 --- a/setup.py +++ b/setup.py @@ -9,8 +9,6 @@ import warnings from collections import defaultdict -from distutils.command.build_scripts import build_scripts as BuildScripts -from distutils.command.sdist import sdist as SDist try: from setuptools import setup, find_packages @@ -23,6 +21,15 @@ " install setuptools).", file=sys.stderr) sys.exit(1) +# `distutils` must be imported after `setuptools` or it will cause explosions +# with `setuptools >=48.0.0, <49.1`. +# Refs: +# * https://github.com/ansible/ansible/issues/70456 +# * https://github.com/pypa/setuptools/issues/2230 +# * https://github.com/pypa/setuptools/commit/bd110264 +from distutils.command.build_scripts import build_scripts as BuildScripts +from distutils.command.sdist import sdist as SDist + sys.path.insert(0, os.path.abspath('lib')) from ansible.release import __version__, __author__