From patchwork Fri Jan 16 18:03:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: setup.py: attempt to use setuptools From: Gregory Szorc X-Patchwork-Id: 7490 Message-Id: <711fa69653f69a705996.1421431431@gps-mbp.local> To: mercurial-devel@selenic.com Date: Fri, 16 Jan 2015 10:03:51 -0800 # HG changeset patch # User Gregory Szorc # Date 1421431223 28800 # Fri Jan 16 10:00:23 2015 -0800 # Node ID 711fa69653f69a7059966fff1dae1a352244b781 # Parent 049a9e3a078d7c988cb12ed456aad6ec2779ea69 setup.py: attempt to use setuptools The Python Packaging User Guide recommends setuptools over distutils (https://packaging.python.org/en/latest/distributing.html). setuptools.setup should be a drop-in replacement for distutils.core.setup and this patch should "just work." That being said, setuptools does differ from distutils. I wouldn't be surprised if this change broke Mercurial packaging somewhere. If it does, it should be easy enough to revert. With this patch applied, I did notice a new warning when running setup.py: UserWarning: The version specified requires normalization, consider using '3.2.4+668.41fac217e2e4' instead of '3.2.4+668-41fac217e2e4'. Furter research indicates that setuptools may break our current dev versioning format in the future. The impetus for this patch is to work around https://bugs.python.org/issue23246, which was preventing me from easily building Mercurial on Windows using the Visual C++ for Python distribution. In the future, this patch may open the door to other distribution potentials for Mercurial, including wheels, which the Python world is slowly moving to. On my machine, |python setup.py bdist_wheel| does produce a wheel. But I haven't tested whether the wheel is sane. diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -66,10 +66,16 @@ else: import os, stat, subprocess, time import re import shutil import tempfile + +try: + from setuptools import setup +except: + from distutils.core import setup + from distutils import log -from distutils.core import setup, Command, Extension +from distutils.core import Command, Extension from distutils.dist import Distribution from distutils.command.build import build from distutils.command.build_ext import build_ext from distutils.command.build_py import build_py