From 13f3987f7933895dd6fa3f501280555f5e3e6ddd Mon Sep 17 00:00:00 2001 From: Roberto Polli Date: Tue, 26 Apr 2016 17:55:50 +0200 Subject: [PATCH] use setuptools when possible. I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it. --- lib/cpy_distutils.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/cpy_distutils.py b/lib/cpy_distutils.py index e1dc75b..d4b6885 100644 --- a/lib/cpy_distutils.py +++ b/lib/cpy_distutils.py @@ -24,9 +24,18 @@ """Implements the DistUtils command 'build_ext' """ -from distutils.command.build_ext import build_ext -from distutils.command.install import install -from distutils.command.install_lib import install_lib +# Setuptools is the default choice for package management +# and pip uses it to build it. Moreover bare +# distutils doesn't implement uninstalling. +try: + from setuptools.command.build_ext import build_ext + from setuptools.command.install import install + from setuptools.command.install_lib import install_lib +except ImportError: + from distutils.command.build_ext import build_ext + from distutils.command.install import install + from distutils.command.install_lib import install_lib + from distutils.errors import DistutilsExecError from distutils.util import get_platform from distutils.dir_util import copy_tree