Repository: conda/conda

Issue:
setuptools hard build dependency
Here: https://github.com/conda/conda/blob/master/setup.py#L8

@kalefranz I thought we had agreed that setuptools is not going to be a hard build dependency anymore.



Discussion:
If you don't want to hard code all the packages (because you're vendoring so many things now), you can use this code:

```
import os
from fnmatch import fnmatchcase
from distutils.util import convert_path

def find_packages(where='.', exclude=()):
    out = []
    stack=[(convert_path(where), '')]
    while stack:
        where, prefix = stack.pop(0)
        for name in os.listdir(where):
            fn = os.path.join(where,name)
            if ('.' not in name and os.path.isdir(fn) and
                os.path.isfile(os.path.join(fn, '__init__.py'))
            ):
                out.append(prefix+name)
                stack.append((fn, prefix+name+'.'))
    for pat in list(exclude) + ['ez_setup', 'distribute_setup']:
        out = [item for item in out if not fnmatchcase(item, pat)]
    return out
```

Actually, I thought you'd think this build dependency was ok.  I'm still using the `setup` function from distutils, not from setuptools.
https://github.com/conda/conda/blob/master/setup.py#L12

No, `from distutils.core import setup` doesn't help, because `setuptools` monkeypatches `distutils` somehow.  When I add `setuptools` as a build dependency, I also have to add `pycosat`.  I'm not sure exactly what setuptools does, not it's safest to not depend on it.

Grrrrrrrrr that sucks.  OK I'll fix it with the function you suggest.  I'll put that in auxlib.packaging.

Thanks!  Setuptools does crazy stuff, so the best is to avoid it when possible.


Resolving patch:
diff --git a/conda/_vendor/auxlib/packaging.py b/conda/_vendor/auxlib/packaging.py
--- a/conda/_vendor/auxlib/packaging.py
+++ b/conda/_vendor/auxlib/packaging.py
@@ -69,11 +69,14 @@
 import sys
 from collections import namedtuple
 from logging import getLogger
-from os import getenv, remove
+from os import getenv, remove, listdir
 from os.path import abspath, dirname, expanduser, isdir, isfile, join
 from re import compile
 from shlex import split
 from subprocess import CalledProcessError, Popen, PIPE
+from fnmatch import fnmatchcase
+from distutils.util import convert_path
+
 try:
     from setuptools.command.build_py import build_py
     from setuptools.command.sdist import sdist
@@ -81,8 +84,8 @@
 except ImportError:
     from distutils.command.build_py import build_py
     from distutils.command.sdist import sdist
-    TestCommand = object
 
+    TestCommand = object
 
 log = getLogger(__name__)
 
@@ -222,3 +225,21 @@ def run_tests(self):
             args = ''
         errno = cmdline(args=args)
         sys.exit(errno)
+
+
+# swiped from setuptools
+def find_packages(where='.', exclude=()):
+    out = []
+    stack = [(convert_path(where), '')]
+    while stack:
+        where, prefix = stack.pop(0)
+        for name in listdir(where):
+            fn = join(where, name)
+            if ('.' not in name and isdir(fn) and
+                    isfile(join(fn, '__init__.py'))
+                ):
+                out.append(prefix + name)
+                stack.append((fn, prefix + name + '.'))
+    for pat in list(exclude) + ['ez_setup', 'distribute_setup']:
+        out = [item for item in out if not fnmatchcase(item, pat)]
+    return out
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,6 @@
 # Consult LICENSE.txt or http://opensource.org/licenses/BSD-3-Clause.
 import os
 import sys
-from setuptools import find_packages
 if 'develop' in sys.argv:
     from setuptools import setup
 else:
@@ -61,7 +60,8 @@
         "Programming Language :: Python :: 3.4",
         "Programming Language :: Python :: 3.5",
     ],
-    packages=find_packages(exclude=("tests", "conda-env", "build", "utils", ".tox")),
+    packages=conda._vendor.auxlib.packaging.find_packages(exclude=("tests", "conda-env",
+                                                                   "build", "utils", ".tox")),
     cmdclass={
         'build_py': conda._vendor.auxlib.BuildPyCommand,
         'sdist': conda._vendor.auxlib.SDistCommand,


Test patch: