Repository: numpy/numpy

Issue:
Travis tests are busted.
I suspect there has been a change in the configuration of some of the build machines, but maybe something else is broken. The end of the traceback is:

```
File "/tmp/pip-0jmng0-build/numpy/distutils/command/install.py", line 33, in setuptools_run

return old_install_mod._install.run(self)

AttributeError: 'module' object has no attribute '_install'
```

Where `old_install_mod` is python's `distutils.command.install`.



Discussion:
This shows on all the recent tests.

OK, I don't see the `_install` method in that module either. Evidently the Numpy install is following a different path than it was. The relevant part of `numpy/distutils/command/install.py` is

```
        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return old_install_mod._install.run(self)
```

Perhaps we should not be calling a private, non-existent method ;) There is one other call in that file. The module it comes from is determined by

```
if 'setuptools' in sys.modules:
    import setuptools.command.install as old_install_mod
    have_setuptools = True
else:
    import distutils.command.install as old_install_mod
    have_setuptools = False
```

I suspect setuptools in this case.

My version of setuptools is 1.4.1 and the `_install` method is available; the current version is 3.5. It looks like `_install` disappeared along the way.

Simply replacing `._install` by `.install` seems to work, but I have no idea what the consequences of such a change are. @cournape Any idea of the best way forward is?

And I see @rkern is responsible for the original back in 2008. Robert, what was the purpose in using the `_install` method.

This doesn't just need changing; we need to understand it because if it's a change in setuptools (or pip) then we have a problem for all released numpy versions. Preferably the offending change needs to be undone.

Looks like setuptools `_install` is just `distutils.command.install`,

```
from distutils.command.install import install as _install
```

When `setuptools` is being used, `old_install_mod` is `setuptools.command.install`. And the `_install` object is `distutils.command.install` in older versions of setuptools. The code was copied quickly from the `setuptools` sources. We can just unconditionally import `distutils.command.install` and use that explicitly.


Resolving patch:
diff --git a/numpy/distutils/command/install.py b/numpy/distutils/command/install.py
--- a/numpy/distutils/command/install.py
+++ b/numpy/distutils/command/install.py
@@ -7,9 +7,10 @@
 else:
     import distutils.command.install as old_install_mod
     have_setuptools = False
-old_install = old_install_mod.install
 from distutils.file_util import write_file
 
+old_install = old_install_mod.install
+
 class install(old_install):
 
     # Always run install_clib - the command is cheap, so no need to bypass it;
@@ -28,9 +29,11 @@ def setuptools_run(self):
         We must pull in the entire code so we can override the level used in the
         _getframe() call since we wrap this call by one more level.
         """
+        from distutils.command.install import install as distutils_install
+
         # Explicit request for old-style install?  Just do it
         if self.old_and_unmanageable or self.single_version_externally_managed:
-            return old_install_mod._install.run(self)
+            return distutils_install.run(self)
 
         # Attempt to detect whether we were called from setup() or by another
         # command.  If we were called by setup(), our caller will be the
@@ -48,7 +51,7 @@ def setuptools_run(self):
             # We weren't called from the command line or setup(), so we
             # should run in backward-compatibility mode to support bdist_*
             # commands.
-            old_install_mod._install.run(self)
+            distutils_install.run(self)
         else:
             self.do_egg_install()
 


Test patch: