Repository: django-haystack/django-haystack

Issue:
DistutilsError: Could not find suitable distribution for Requirement.parse('setuptools-scm')
I'm getting the following `setuptools_scm` error when trying to install via the latest version of pip in a virtual environment. As you can see in the code below, setuptools_scm does appear to be installed. I'm trying to figure out why it's not linking up with your library. If you have any ideas, please let me know.

```bash
(himmel.latimes.com)datadesk@himmel:/apps/himmel.latimes.com$ pip freeze | grep setuptools-scm
setuptools-scm==1.15.6
(himmel.latimes.com)datadesk@himmel:/apps/himmel.latimes.com$ python
Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools_scm
>>> exit()
(himmel.latimes.com)datadesk@himmel:/apps/himmel.latimes.com$ pip install django-haystack
Collecting django-haystack
  Using cached django-haystack-2.6.1.tar.gz
    Complete output from command python setup.py egg_info:
    Couldn't find index page for 'setuptools_scm' (maybe misspelled?)
    No local packages or download links found for setuptools-scm
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-do137B/django-haystack/setup.py", line 68, in <module>
        setup_requires=['setuptools_scm'],
      File "/usr/lib/python2.7/distutils/core.py", line 112, in setup
        _setup_distribution = dist = klass(attrs)
      File "/apps/himmel.latimes.com/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/dist.py", line 221, in __init__
        self.fetch_build_eggs(attrs.pop('setup_requires'))
      File "/apps/himmel.latimes.com/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/dist.py", line 245, in fetch_build_eggs
        parse_requirements(requires), installer=self.fetch_build_egg
      File "/apps/himmel.latimes.com/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 576, in resolve
        dist = best[req.key] = env.best_match(req, self, installer)
      File "/apps/himmel.latimes.com/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 821, in best_match
        return self.obtain(req, installer) # try and download/install
      File "/apps/himmel.latimes.com/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 833, in obtain
        return installer(requirement)
      File "/apps/himmel.latimes.com/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/dist.py", line 294, in fetch_build_egg
        return cmd.easy_install(req)
      File "/apps/himmel.latimes.com/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/command/easy_install.py", line 583, in easy_install
        raise DistutilsError(msg)
    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('setuptools-scm')
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-do137B/django-haystack/
```


Discussion:
pip isnt picking up on it but you can install the package manually

`pip install setuptools-scm`
What version of pip are people seeing this with? It seems to be not uncommon but there were suggestions that it was due to what is by now a quite old version of pip (https://github.com/pypa/pypi-legacy/issues/322#issuecomment-229131838) so I'm wondering whether updating that would also fix the problem.
hey @acdha, thanks for the response! Im on pip 18.1 using python 3.7 within a pipvenv
This happens if you use a non-standard PyPI repo. pip will use it, but `setup_requires` is handled by `setuptools` which does not respect pip settings. Instead, you are redirected to pypi.org which is not accessible in our environment. I'm fighting with this now. The suggestion to create a `distutils.cfg` file does not work for me.

Is `setuptools-scm` even needed here? I can't see anything in setup.cfg requiring it. #1603 seems to think it isn't.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,16 +1,7 @@
 #!/usr/bin/env python
 # encoding: utf-8
 
-# n.b. we can't have unicode_literals here due to http://bugs.python.org/setuptools/issue152
-from __future__ import absolute_import, division, print_function
-
-try:
-    from setuptools import setup
-except ImportError:
-    from ez_setup import use_setuptools
-
-    use_setuptools()
-    from setuptools import setup
+from setuptools import setup
 
 install_requires = ["Django>=1.11"]
 
@@ -63,5 +54,4 @@
     install_requires=install_requires,
     tests_require=tests_require,
     test_suite="test_haystack.run_tests.run_all",
-    setup_requires=["setuptools_scm"],
 )


Test patch: