[PATCH 1 of 2 v2] setup: import setup from setuptools when building wheels

Gregory Szorc gregory.szorc at gmail.com
Fri Oct 9 12:11:37 CDT 2015


On Fri, Oct 9, 2015 at 9:45 AM, Nathan Goldbaum <nathan12343 at gmail.com>
wrote:

> # HG changeset patch
> # User Nathan Goldbaum <ngoldbau at ucsc.edu>
> # Date 1444408995 18000
> #      Fri Oct 09 11:43:15 2015 -0500
> # Node ID 490624ac27dac6156a18446fe8d6091761e5ac74
> # Parent  a024e2db4553492e173032f52464e2c4efe0d4fa
> setup: import setup from setuptools when building wheels
>
> This should hopefully prevent side-effects from using setuptools except
> when
> a user has *explicitly* asked to produce a wheel
>
> diff --git a/setup.py b/setup.py
> --- a/setup.py
> +++ b/setup.py
> @@ -70,7 +70,11 @@ import re
>  import shutil
>  import tempfile
>  from distutils import log
> -from distutils.core import setup, Command, Extension
> +if 'bdist_wheel' in sys.argv:
> +    from setuptools import setup
> +else:
> +    from distutils.core import setup
> +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
>

I would have preferred something like:

  if 'FORCE_SETUPTOOLS' in os.environ:
      from setuptools import setup
  else:
      from distutils.core import setup

That way we can experiment more broadly with setuptools for general
packaging without having to modify setup.py. You can have the "wheel" make
target pass this environment variable on the command line:

wheel:
    FORCE_SETUPTOOLS=1 python setup.py ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151009/1afe1cc9/attachment.html>


More information about the Mercurial-devel mailing list