From ccee1750542bd16427bb80eb850615b5fa8bf716 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Wed, 8 Jul 2020 19:14:05 +0200 Subject: [PATCH] Fix building Ansible dist w/ setuptools>=48,<49.1 This change addresses the deprecation of the use of stdlib `distutils`. It's a short-term hotfix for the problem and we'll need to consider dropping the use of `distutils` from our `setup.py`. Refs: * https://github.com/ansible/ansible/issues/70456 * https://github.com/pypa/setuptools/issues/2230 * https://github.com/pypa/setuptools/commit/bd110264 --- setup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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__