Patchwork setup.py: attempt to use setuptools

login
register
mail settings
Submitter Gregory Szorc
Date Jan. 16, 2015, 6:03 p.m.
Message ID <711fa69653f69a705996.1421431431@gps-mbp.local>
Download mbox | patch
Permalink /patch/7490/
State Accepted
Headers show

Comments

Gregory Szorc - Jan. 16, 2015, 6:03 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# 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.
Augie Fackler - Jan. 16, 2015, 6:14 p.m.
On Jan 16, 2015, at 1:03 PM, Gregory Szorc <gregory.szorc@gmail.com> wrote:

> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1421431223 28800
> #      Fri Jan 16 10:00:23 2015 -0800
> # Node ID 711fa69653f69a7059966fff1dae1a352244b781
> # Parent  049a9e3a078d7c988cb12ed456aad6ec2779ea69
> setup.py: attempt to use setup tools

I endorse this patch - it should improve things.

> 
> 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'.

Sigh, but yes, we'll probably want to move to that at some point.

> 
> 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Adrian Buehlmann - Jan. 16, 2015, 7:26 p.m.
On 2015-01-16 19:03, 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 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.

I'm pretty much out of this business, but in the past, I spent quite
some time documenting what was needed to install a Windows computer that
was able to build TortoiseHg MSI installers for Windows (32 and 64 bit).
Building Mercurial for Windows using the Visual C++ compiler was part of it.

Perhaps you may find the Readme.txt at

  https://bitbucket.org/tortoisehg/thg-winbuild/src

useful in some way. It contains some hints about vcvars and the like,
which may or may not apply to your issue.

Perhaps Steve Borho can provide specific feedback for your patch. I
guess he's the one who would notice first if this patch here breaks
anything that is done when building for Windows.
Matt Mackall - Jan. 17, 2015, midnight
On Fri, 2015-01-16 at 10:03 -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 711fa69653f69a7059966fff1dae1a352244b781
> # Parent  049a9e3a078d7c988cb12ed456aad6ec2779ea69
> setup.py: attempt to use setuptools

I like this, but I think I'd rather have it at the start of the next
cycle.
Augie Fackler - Feb. 8, 2015, 7:41 p.m.
On Fri, Jan 16, 2015 at 10:03:51AM -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 711fa69653f69a7059966fff1dae1a352244b781
> # Parent  049a9e3a078d7c988cb12ed456aad6ec2779ea69
> setup.py: attempt to use setuptools

Should this patch be reexamined now that I've queued those other
patches for run-tests?

>
> 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Gregory Szorc - Feb. 8, 2015, 8:13 p.m.
> On Feb 8, 2015, at 11:41, Augie Fackler <raf@durin42.com> wrote:
> 
>> On Fri, Jan 16, 2015 at 10:03:51AM -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 711fa69653f69a7059966fff1dae1a352244b781
>> # Parent  049a9e3a078d7c988cb12ed456aad6ec2779ea69
>> setup.py: attempt to use setuptools
> 
> Should this patch be reexamined now that I've queued those other
> patches for run-tests?

This patch was queued, then unqueued because of run-tests issues that now have fixes queued. I think this patch qualifies for auto queue.

> 
>> 
>> 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
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel

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