Patchwork [resubmission-after-33-cycle] setup.py: attempt to use setuptools

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 6, 2015, 2:52 a.m.
Message ID <975f6586908de6526bf5.1423191146@gps-mbp.local>
Download mbox | patch
Permalink /patch/7700/
State Changes Requested
Headers show

Comments

Gregory Szorc - Feb. 6, 2015, 2:52 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1421431223 28800
#      Fri Jan 16 10:00:23 2015 -0800
# Node ID 975f6586908de6526bf5165d09f8622437a682e5
# Parent  a9b61dbdb827165a9fd9d44dd42b892dbd9fa07c
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.
Matt Mackall - Feb. 6, 2015, 11:09 p.m.
On Thu, 2015-02-05 at 18:52 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1421431223 28800
> #      Fri Jan 16 10:00:23 2015 -0800
> # Node ID 975f6586908de6526bf5165d09f8622437a682e5
> # Parent  a9b61dbdb827165a9fd9d44dd42b892dbd9fa07c
> setup.py: attempt to use setuptools

Ok, queued, thanks. check-code says hi.
Matt Mackall - Feb. 6, 2015, 11:14 p.m.
On Fri, 2015-02-06 at 17:09 -0600, Matt Mackall wrote:
> On Thu, 2015-02-05 at 18:52 -0800, Gregory Szorc wrote:
> > # HG changeset patch
> > # User Gregory Szorc <gregory.szorc@gmail.com>
> > # Date 1421431223 28800
> > #      Fri Jan 16 10:00:23 2015 -0800
> > # Node ID 975f6586908de6526bf5165d09f8622437a682e5
> > # Parent  a9b61dbdb827165a9fd9d44dd42b892dbd9fa07c
> > setup.py: attempt to use setuptools
> 
> Ok, queued, thanks. check-code says hi.

Also, run-tests explodes with pages of build spew on both Centos and
Debian. Please investigate.

Patch

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