Better setuptools detection

Bug #504968 reported by Sridhar Ratnakumar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IPython
Fix Committed
Undecided
Fernando Perez

Bug Description

The current setup.py does not use setuptools if it is already installed. Repro steps:

1. Install setuptools or Distribute normally.
2. Download and extract IPython 0.10
3. Run "python setup.py install"

You will note that the .exe wrappers are not installed (they may be only installed via "easy_install ipython" I think).

Why is this important? Because binary package managers like PyPM [pypm.activestate.com] run "python setup.py install" - and does not use the easy_install sandbox.

Attached is the patch that fixes it.

Revision history for this message
Sridhar Ratnakumar (srid) wrote :
Revision history for this message
Fernando Perez (fdo.perez) wrote :

Sorry, but this is actually by explicit design and will NEVER be changed. Setuptools causes enough other problems, that we never, ever use it by default.

If you want to run a setuptools-enabled installation, simply call

python setupegg.py install

instead, which we also provide to make this as easy as possible.

But we will NEVER use setuptools in the default setup.py, it simply has too many detrimental and unavoidable side-effects to be used by default (since simply importing it monkeypatches distutils, there's no way to avoid its problems once you've imported it).

Changed in ipython:
assignee: nobody → Fernando Perez (fdo.perez)
status: New → Invalid
Revision history for this message
Brian Granger (ellisonbg) wrote : Re: [Bug 504968] [NEW] Better setuptools detection

> The current setup.py does not use setuptools if it is already installed.

At this point, we consider this to be a feature rather than a bug. In
our experience,
setuptools should only be used if a user asks for it, not merely
because setuptools
happens to be installed - doing otherwise creates problems for users
who don't want
to use setuptools.

But, to install IPython using setuptools, you can do:

python setupegg.py install

Cheers,

Brian

> Repro steps:
>
> 1. Install setuptools or Distribute normally.
> 2. Download and extract IPython 0.10
> 3. Run "python setup.py install"
>
> You will note that the .exe wrappers are not installed (they may be only
> installed via "easy_install ipython" I think).
>
> Why is this important? Because binary package managers like PyPM
> [pypm.activestate.com] run "python setup.py install" - and does not use
> the easy_install sandbox.
>
> Attached is the patch that fixes it.
>
> ** Affects: ipython
>     Importance: Undecided
>         Status: New
>
> --
> Better setuptools detection
> https://bugs.launchpad.net/bugs/504968
> You received this bug notification because you are a member of IPython
> Developers, which is subscribed to IPython.
>
> Status in IPython - Enhanced Interactive Python: New
>
> Bug description:
> The current setup.py does not use setuptools if it is already installed. Repro steps:
>
> 1. Install setuptools or Distribute normally.
> 2. Download and extract IPython 0.10
> 3. Run "python setup.py install"
>
> You will note that the .exe wrappers are not installed (they may be only installed via "easy_install ipython" I think).
>
> Why is this important? Because binary package managers like PyPM [pypm.activestate.com] run "python setup.py install" - and does not use the easy_install sandbox.
>
> Attached is the patch that fixes it.
>
>
>

--
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
<email address hidden>
<email address hidden>

Revision history for this message
Gael Varoquaux (gael-varoquaux) wrote : Re: [Bug 504968] Re: Better setuptools detection

On Fri, Jan 08, 2010 at 10:24:16PM -0000, Fernando Perez wrote:
> But we will NEVER use setuptools in the default setup.py, it simply has
> too many detrimental and unavoidable side-effects to be used by default
> (since simply importing it monkeypatches distutils, there's no way to
> avoid its problems once you've imported it).

There are ways to use setuptools for the good features it has and avoid
these problems. Have a look at the setup.py and setupegg.py in the
following project, for instance:
http://bazaar.launchpad.net/~gael-varoquaux/joblib/trunk/files

Gaël

Revision history for this message
Fernando Perez (fdo.perez) wrote :

On Fri, Jan 8, 2010 at 2:32 PM, Gael Varoquaux
<email address hidden> wrote:
> On Fri, Jan 08, 2010 at 10:24:16PM -0000, Fernando Perez wrote:
>> But we will NEVER use setuptools in the default setup.py, it simply has
>> too many detrimental and unavoidable side-effects to be used by default
>> (since simply importing it monkeypatches distutils, there's no way to
>> avoid its problems once you've imported it).
>
> There are ways to use setuptools for the good features it has and avoid
> these problems. Have a look at the setup.py and setupegg.py in the
> following project, for instance:
> http://bazaar.launchpad.net/~gael-varoquaux/joblib/trunk/files

You mean this, I assume:

# For some commands, use setuptools
if len(set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm',
           'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info',
           'build_sphinx', 'egg_info', 'easy_install', 'upload',
            )).intersection(sys.argv)) > 0:
    from setupegg import extra_setuptools_args

# extra_setuptools_args is injected by the setupegg.py script, for
# running the setup with setuptools.
if not 'extra_setuptools_args' in globals():
    extra_setuptools_args = dict()

Yes, that's very nice in that for many commands provided by
setuptools, it wil transparently work for the user, thanks. We should
adopt that code ourselves too, it's a good solution for all those
commands. Thanks!

However, it doesn't change the resolution for this bug, which was for
'setup.py install', because for the install command, we are not going
to pull setuptools in, as that's where the easy-install.pth mess
happens.

In summary: bug resolution stays unchanged, but using your solution to
be more setuptools-friendly is a great idea.

Cheers,

f

Revision history for this message
Sridhar Ratnakumar (srid) wrote :

On Fri, Jan 8, 2010 at 3:28 PM, Fernando Perez <email address hidden> wrote:
> However, it doesn't change the resolution for this bug, which was for
> 'setup.py install', because for the install command, we are not going
> to pull setuptools in, as that's where the easy-install.pth mess
> happens.

Yes. The only reason for us to use setuptools is that it creates nice
.exe wrappers on Windows.

Does using "--single-version-externally-managed" avoid the undesired
side-effects (at least, it does not install .pth files)?
http://packages.python.org/distribute/setuptools.html#install-run-easy-install-or-old-style-installation

-srid

PS: the bug resolution is fine with me; I can configure ipython to use
setupegg.py script instead.

Revision history for this message
Fernando Perez (fdo.perez) wrote :

On Fri, Jan 8, 2010 at 4:12 PM, Sridhar Ratnakumar
<email address hidden> wrote:
>
> Does using "--single-version-externally-managed" avoid the undesired
> side-effects (at least, it does not install .pth files)?
> http://packages.python.org/distribute/setuptools.html#install-run-easy-install-or-old-style-installation
>

Maybe, but the fact that on every install I'd have to remember that
monstrosity, and in addition specify --root options or --record (as
dicated by setuptools) means I'm never going to use it :)

Revision history for this message
Gael Varoquaux (gael-varoquaux) wrote :

On Fri, Jan 08, 2010 at 11:28:39PM -0000, Fernando Perez wrote:
> You mean this, I assume:

> # For some commands, use setuptools
> if len(set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm',
> 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info',
> 'build_sphinx', 'egg_info', 'easy_install', 'upload',
> )).intersection(sys.argv)) > 0:
> from setupegg import extra_setuptools_args

> # extra_setuptools_args is injected by the setupegg.py script, for
> # running the setup with setuptools.
> if not 'extra_setuptools_args' in globals():
> extra_setuptools_args = dict()

Yes.

> However, it doesn't change the resolution for this bug, which was for
> 'setup.py install', because for the install command, we are not going
> to pull setuptools in, as that's where the easy-install.pth mess
> happens.

I do not disagree with you here :). This is why I adopted the above
option: give the user develop, easy_install (which will pretty much do
an install using setuptools, and other niceties), but default to standard
behavior elsewhere.

Gaël

Revision history for this message
Fernando Perez (fdo.perez) wrote :

Marked as committed because I just applied a little snippet taken from Gael's example.

Thanks for that tip!

Changed in ipython:
status: Invalid → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.