From 918388b85f516116e2cd7dcf0c12eeb19ab561e9 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 13 Jul 2020 23:16:26 +0200 Subject: [PATCH] Fix building Ansible dist w/ setuptools>=48,<49.1 (#70525) * 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 Co-Authored-By: Jason R. Coombs * Add a change note for PR #70525 Co-authored-by: Jason R. Coombs --- .../fragments/70525-setuptools-disutils-reorder.yml | 7 +++++++ setup.py | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/70525-setuptools-disutils-reorder.yml diff --git a/changelogs/fragments/70525-setuptools-disutils-reorder.yml b/changelogs/fragments/70525-setuptools-disutils-reorder.yml new file mode 100644 index 00000000000..756cf13bc77 --- /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 0398473d5e0..9e0338f4963 100644 --- a/setup.py +++ b/setup.py @@ -9,8 +9,6 @@ import sys 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 @@ except ImportError: " 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__