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

login
register
mail settings
Submitter Nathan Goldbaum
Date Oct. 9, 2015, 4:45 p.m.
Message ID <490624ac27dac6156a18.1444409113@ROUS2>
Download mbox | patch
Permalink /patch/10912/
State Not Applicable
Headers show

Comments

Nathan Goldbaum - Oct. 9, 2015, 4:45 p.m.
# HG changeset patch
# User Nathan Goldbaum <ngoldbau@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
Gregory Szorc - Oct. 9, 2015, 5:11 p.m.
On Fri, Oct 9, 2015 at 9:45 AM, Nathan Goldbaum <nathan12343@gmail.com>
wrote:

> # HG changeset patch
> # User Nathan Goldbaum <ngoldbau@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 ...

Patch

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