setup: be compatible with newer setuptools

Newer setup tool are apparently incompatible with the old distutils way. We make add support for both.

authorOlle Lundberg <geek@nerd.sh>
changeset99478d1b5b30
branchdefault
phasepublic
hiddenno
parent revision#dd3b5c418c0a graph: work around the new smartset class used for revset (compat hg 3.0)
child revision#c1cc5c806c53 [nested] be robust against .hgguestrepo parse errors (closes #234670)
files modified by this revision
setup.py
# HG changeset patch
# User Olle Lundberg <geek@nerd.sh>
# Date 1397589870 -7200
# Tue Apr 15 21:24:30 2014 +0200
# Node ID 99478d1b5b30fa92a6b74ff30dab050c4c1c92b8
# Parent dd3b5c418c0a6562a24b789e1a31d2ec6aa2171a
setup: be compatible with newer setuptools

Newer setup tool are apparently incompatible with the old distutils way. We make
add support for both.

diff --git a/setup.py b/setup.py
@@ -25,15 +25,30 @@
1  import sys
2  import shutil
3  from os.path import isdir, exists, join, walk, splitext, basename, dirname
4  from subprocess import check_call, call as sub_call
5 
6 -from distutils.core import setup
7 +with_setuptools = False
8 +if 'USE_SETUPTOOLS' in os.environ or 'pip' in __file__:
9 +    try:
10 +        from setuptools import setup
11 +        from setuptools.command.install import install as _install
12 +        from setuptools.command.build_py import build_py as _build_py
13 +        from setuptools.command.install_lib import install_lib
14 +        with_setuptools = True
15 +    except:
16 +        with_setuptools = False
17 +
18 +if with_setuptools is False:
19 +    import warnings
20 +    from distutils.command.install import install as _install
21 +    from distutils.core import setup
22 +    from distutils.command.build_py import build_py as _build_py
23 +    from distutils.command.install_lib import install_lib
24 +
25 +
26  from distutils.command.build import build as _build
27 -from distutils.command.build_py import build_py as _build_py
28 -from distutils.command.install import install as _install
29 -from distutils.command.install_lib import install_lib
30  from distutils.command.install_data import install_data as _install_data
31 
32  py2exe, innosetup = None, None
33  try:
34      import py2exe