We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
find_packages() doesn't find PEP 420 packages
Originally reported by: **gwideman (Bitbucket: [gwideman](http://bitbucket.org/gwideman), GitHub: [gwideman](http://github.com/gwideman))**

---

```
#!python

setup(...
    packages=find_packages(..)
    )
```

on the developer machine will fail to find packages that lack a `__init__.py` file, as is allowed in Python 3.3. However, such packages listed explicitly: packages=['mypkg'] do appear to get included and later installed.

Note: When testing this, before each test be sure to delete all generated metadata, including that which setup may previously have placed in the original source directory, as it seems that setup may use metadata created on a previous run in order to include files.

This is part of a general problem reported in issue #83, but I've logged it separately as it's specifically about setuptools.

---
- Bitbucket: https://bitbucket.org/pypa/setuptools/issue/97


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setuptools/__init__.py`
Content:
```
1 """Extensions to the 'distutils' for large or complex distributions"""
2 
3 import os
4 import functools
5 import distutils.core
6 import distutils.filelist
7 from distutils.util import convert_path
8 from fnmatch import fnmatchcase
9 
10 from setuptools.extern.six.moves import filter, map
11 
12 import setuptools.version
13 from setuptools.extension import Extension
14 from setuptools.dist import Distribution, Feature
15 from setuptools.depends import Require
16 from . import monkey
17 
18 __metaclass__ = type
19 
20 __all__ = [
21     'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
22     'find_packages',
23 ]
24 
25 __version__ = setuptools.version.__version__
26 
27 bootstrap_install_from = None
28 
29 # If we run 2to3 on .py files, should we also convert docstrings?
30 # Default: yes; assume that we can detect doctests reliably
31 run_2to3_on_doctests = True
32 # Standard package names for fixer packages
33 lib2to3_fixer_packages = ['lib2to3.fixes']
34 
35 
36 class PackageFinder:
37     """
38     Generate a list of all Python packages found within a directory
39     """
40 
41     @classmethod
42     def find(cls, where='.', exclude=(), include=('*',)):
43         """Return a list all Python packages found within directory 'where'
44 
45         'where' is the root directory which will be searched for packages.  It
46         should be supplied as a "cross-platform" (i.e. URL-style) path; it will
47         be converted to the appropriate local path syntax.
48 
49         'exclude' is a sequence of package names to exclude; '*' can be used
50         as a wildcard in the names, such that 'foo.*' will exclude all
51         subpackages of 'foo' (but not 'foo' itself).
52 
53         'include' is a sequence of package names to include.  If it's
54         specified, only the named packages will be included.  If it's not
55         specified, all found packages will be included.  'include' can contain
56         shell style wildcard patterns just like 'exclude'.
57         """
58 
59         return list(cls._find_packages_iter(
60             convert_path(where),
61             cls._build_filter('ez_setup', '*__pycache__', *exclude),
62             cls._build_filter(*include)))
63 
64     @classmethod
65     def _find_packages_iter(cls, where, exclude, include):
66         """
67         All the packages found in 'where' that pass the 'include' filter, but
68         not the 'exclude' filter.
69         """
70         for root, dirs, files in os.walk(where, followlinks=True):
71             # Copy dirs to iterate over it, then empty dirs.
72             all_dirs = dirs[:]
73             dirs[:] = []
74 
75             for dir in all_dirs:
76                 full_path = os.path.join(root, dir)
77                 rel_path = os.path.relpath(full_path, where)
78                 package = rel_path.replace(os.path.sep, '.')
79 
80                 # Skip directory trees that are not valid packages
81                 if ('.' in dir or not cls._looks_like_package(full_path)):
82                     continue
83 
84                 # Should this package be included?
85                 if include(package) and not exclude(package):
86                     yield package
87 
88                 # Keep searching subdirectories, as there may be more packages
89                 # down there, even if the parent was excluded.
90                 dirs.append(dir)
91 
92     @staticmethod
93     def _looks_like_package(path):
94         """Does a directory look like a package?"""
95         return os.path.isfile(os.path.join(path, '__init__.py'))
96 
97     @staticmethod
98     def _build_filter(*patterns):
99         """
100         Given a list of patterns, return a callable that will be true only if
101         the input matches at least one of the patterns.
102         """
103         return lambda name: any(fnmatchcase(name, pat=pat) for pat in patterns)
104 
105 
106 class PEP420PackageFinder(PackageFinder):
107     @staticmethod
108     def _looks_like_package(path):
109         return True
110 
111 
112 find_packages = PackageFinder.find
113 
114 
115 def _install_setup_requires(attrs):
116     # Note: do not use `setuptools.Distribution` directly, as
117     # our PEP 517 backend patch `distutils.core.Distribution`.
118     dist = distutils.core.Distribution(dict(
119         (k, v) for k, v in attrs.items()
120         if k in ('dependency_links', 'setup_requires')
121     ))
122     # Honor setup.cfg's options.
123     dist.parse_config_files(ignore_option_errors=True)
124     if dist.setup_requires:
125         dist.fetch_build_eggs(dist.setup_requires)
126 
127 
128 def setup(**attrs):
129     # Make sure we have any requirements needed to interpret 'attrs'.
130     _install_setup_requires(attrs)
131     return distutils.core.setup(**attrs)
132 
133 setup.__doc__ = distutils.core.setup.__doc__
134 
135 
136 _Command = monkey.get_unpatched(distutils.core.Command)
137 
138 
139 class Command(_Command):
140     __doc__ = _Command.__doc__
141 
142     command_consumes_arguments = False
143 
144     def __init__(self, dist, **kw):
145         """
146         Construct the command for dist, updating
147         vars(self) with any keyword parameters.
148         """
149         _Command.__init__(self, dist)
150         vars(self).update(kw)
151 
152     def reinitialize_command(self, command, reinit_subcommands=0, **kw):
153         cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
154         vars(cmd).update(kw)
155         return cmd
156 
157 
158 def _find_all_simple(path):
159     """
160     Find all files under 'path'
161     """
162     results = (
163         os.path.join(base, file)
164         for base, dirs, files in os.walk(path, followlinks=True)
165         for file in files
166     )
167     return filter(os.path.isfile, results)
168 
169 
170 def findall(dir=os.curdir):
171     """
172     Find all files under 'dir' and return the list of full filenames.
173     Unless dir is '.', return full filenames with dir prepended.
174     """
175     files = _find_all_simple(dir)
176     if dir == os.curdir:
177         make_rel = functools.partial(os.path.relpath, start=dir)
178         files = map(make_rel, files)
179     return list(files)
180 
181 
182 monkey.patch_all()
183
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/setuptools/__init__.py b/setuptools/__init__.py
--- a/setuptools/__init__.py
+++ b/setuptools/__init__.py
@@ -1,12 +1,14 @@
 """Extensions to the 'distutils' for large or complex distributions"""
 
 import os
+import sys
 import functools
 import distutils.core
 import distutils.filelist
 from distutils.util import convert_path
 from fnmatch import fnmatchcase
 
+from setuptools.extern.six import PY3
 from setuptools.extern.six.moves import filter, map
 
 import setuptools.version
@@ -17,11 +19,15 @@
 
 __metaclass__ = type
 
+
 __all__ = [
     'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
-    'find_packages',
+    'find_packages'
 ]
 
+if PY3:
+  __all__.append('find_packages_ns')
+
 __version__ = setuptools.version.__version__
 
 bootstrap_install_from = None
@@ -111,6 +117,9 @@
 
 find_packages = PackageFinder.find
 
+if PY3:
+  find_packages_ns = PEP420PackageFinder.find
+
 
 def _install_setup_requires(attrs):
     # Note: do not use `setuptools.Distribution` directly, as

{"golden_diff": "diff --git a/setuptools/__init__.py b/setuptools/__init__.py\n--- a/setuptools/__init__.py\n+++ b/setuptools/__init__.py\n@@ -1,12 +1,14 @@\n \"\"\"Extensions to the 'distutils' for large or complex distributions\"\"\"\n \n import os\n+import sys\n import functools\n import distutils.core\n import distutils.filelist\n from distutils.util import convert_path\n from fnmatch import fnmatchcase\n \n+from setuptools.extern.six import PY3\n from setuptools.extern.six.moves import filter, map\n \n import setuptools.version\n@@ -17,11 +19,15 @@\n \n __metaclass__ = type\n \n+\n __all__ = [\n     'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',\n-    'find_packages',\n+    'find_packages'\n ]\n \n+if PY3:\n+  __all__.append('find_packages_ns')\n+\n __version__ = setuptools.version.__version__\n \n bootstrap_install_from = None\n@@ -111,6 +117,9 @@\n \n find_packages = PackageFinder.find\n \n+if PY3:\n+  find_packages_ns = PEP420PackageFinder.find\n+\n \n def _install_setup_requires(attrs):\n     # Note: do not use `setuptools.Distribution` directly, as\n", "issue": "find_packages() doesn't find PEP 420 packages\nOriginally reported by: **gwideman (Bitbucket: [gwideman](http://bitbucket.org/gwideman), GitHub: [gwideman](http://github.com/gwideman))**\n\n---\n\n```\n#!python\n\nsetup(...\n    packages=find_packages(..)\n    )\n```\n\non the developer machine will fail to find packages that lack a `__init__.py` file, as is allowed in Python 3.3. However, such packages listed explicitly: packages=['mypkg'] do appear to get included and later installed.\n\nNote: When testing this, before each test be sure to delete all generated metadata, including that which setup may previously have placed in the original source directory, as it seems that setup may use metadata created on a previous run in order to include files.\n\nThis is part of a general problem reported in issue #83, but I've logged it separately as it's specifically about setuptools.\n\n---\n- Bitbucket: https://bitbucket.org/pypa/setuptools/issue/97\n\n", "before_files": [{"content": "\"\"\"Extensions to the 'distutils' for large or complex distributions\"\"\"\n\nimport os\nimport functools\nimport distutils.core\nimport distutils.filelist\nfrom distutils.util import convert_path\nfrom fnmatch import fnmatchcase\n\nfrom setuptools.extern.six.moves import filter, map\n\nimport setuptools.version\nfrom setuptools.extension import Extension\nfrom setuptools.dist import Distribution, Feature\nfrom setuptools.depends import Require\nfrom . import monkey\n\n__metaclass__ = type\n\n__all__ = [\n    'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',\n    'find_packages',\n]\n\n__version__ = setuptools.version.__version__\n\nbootstrap_install_from = None\n\n# If we run 2to3 on .py files, should we also convert docstrings?\n# Default: yes; assume that we can detect doctests reliably\nrun_2to3_on_doctests = True\n# Standard package names for fixer packages\nlib2to3_fixer_packages = ['lib2to3.fixes']\n\n\nclass PackageFinder:\n    \"\"\"\n    Generate a list of all Python packages found within a directory\n    \"\"\"\n\n    @classmethod\n    def find(cls, where='.', exclude=(), include=('*',)):\n        \"\"\"Return a list all Python packages found within directory 'where'\n\n        'where' is the root directory which will be searched for packages.  It\n        should be supplied as a \"cross-platform\" (i.e. URL-style) path; it will\n        be converted to the appropriate local path syntax.\n\n        'exclude' is a sequence of package names to exclude; '*' can be used\n        as a wildcard in the names, such that 'foo.*' will exclude all\n        subpackages of 'foo' (but not 'foo' itself).\n\n        'include' is a sequence of package names to include.  If it's\n        specified, only the named packages will be included.  If it's not\n        specified, all found packages will be included.  'include' can contain\n        shell style wildcard patterns just like 'exclude'.\n        \"\"\"\n\n        return list(cls._find_packages_iter(\n            convert_path(where),\n            cls._build_filter('ez_setup', '*__pycache__', *exclude),\n            cls._build_filter(*include)))\n\n    @classmethod\n    def _find_packages_iter(cls, where, exclude, include):\n        \"\"\"\n        All the packages found in 'where' that pass the 'include' filter, but\n        not the 'exclude' filter.\n        \"\"\"\n        for root, dirs, files in os.walk(where, followlinks=True):\n            # Copy dirs to iterate over it, then empty dirs.\n            all_dirs = dirs[:]\n            dirs[:] = []\n\n            for dir in all_dirs:\n                full_path = os.path.join(root, dir)\n                rel_path = os.path.relpath(full_path, where)\n                package = rel_path.replace(os.path.sep, '.')\n\n                # Skip directory trees that are not valid packages\n                if ('.' in dir or not cls._looks_like_package(full_path)):\n                    continue\n\n                # Should this package be included?\n                if include(package) and not exclude(package):\n                    yield package\n\n                # Keep searching subdirectories, as there may be more packages\n                # down there, even if the parent was excluded.\n                dirs.append(dir)\n\n    @staticmethod\n    def _looks_like_package(path):\n        \"\"\"Does a directory look like a package?\"\"\"\n        return os.path.isfile(os.path.join(path, '__init__.py'))\n\n    @staticmethod\n    def _build_filter(*patterns):\n        \"\"\"\n        Given a list of patterns, return a callable that will be true only if\n        the input matches at least one of the patterns.\n        \"\"\"\n        return lambda name: any(fnmatchcase(name, pat=pat) for pat in patterns)\n\n\nclass PEP420PackageFinder(PackageFinder):\n    @staticmethod\n    def _looks_like_package(path):\n        return True\n\n\nfind_packages = PackageFinder.find\n\n\ndef _install_setup_requires(attrs):\n    # Note: do not use `setuptools.Distribution` directly, as\n    # our PEP 517 backend patch `distutils.core.Distribution`.\n    dist = distutils.core.Distribution(dict(\n        (k, v) for k, v in attrs.items()\n        if k in ('dependency_links', 'setup_requires')\n    ))\n    # Honor setup.cfg's options.\n    dist.parse_config_files(ignore_option_errors=True)\n    if dist.setup_requires:\n        dist.fetch_build_eggs(dist.setup_requires)\n\n\ndef setup(**attrs):\n    # Make sure we have any requirements needed to interpret 'attrs'.\n    _install_setup_requires(attrs)\n    return distutils.core.setup(**attrs)\n\nsetup.__doc__ = distutils.core.setup.__doc__\n\n\n_Command = monkey.get_unpatched(distutils.core.Command)\n\n\nclass Command(_Command):\n    __doc__ = _Command.__doc__\n\n    command_consumes_arguments = False\n\n    def __init__(self, dist, **kw):\n        \"\"\"\n        Construct the command for dist, updating\n        vars(self) with any keyword parameters.\n        \"\"\"\n        _Command.__init__(self, dist)\n        vars(self).update(kw)\n\n    def reinitialize_command(self, command, reinit_subcommands=0, **kw):\n        cmd = _Command.reinitialize_command(self, command, reinit_subcommands)\n        vars(cmd).update(kw)\n        return cmd\n\n\ndef _find_all_simple(path):\n    \"\"\"\n    Find all files under 'path'\n    \"\"\"\n    results = (\n        os.path.join(base, file)\n        for base, dirs, files in os.walk(path, followlinks=True)\n        for file in files\n    )\n    return filter(os.path.isfile, results)\n\n\ndef findall(dir=os.curdir):\n    \"\"\"\n    Find all files under 'dir' and return the list of full filenames.\n    Unless dir is '.', return full filenames with dir prepended.\n    \"\"\"\n    files = _find_all_simple(dir)\n    if dir == os.curdir:\n        make_rel = functools.partial(os.path.relpath, start=dir)\n        files = map(make_rel, files)\n    return list(files)\n\n\nmonkey.patch_all()\n", "path": "setuptools/__init__.py"}], "after_files": [{"content": "\"\"\"Extensions to the 'distutils' for large or complex distributions\"\"\"\n\nimport os\nimport sys\nimport functools\nimport distutils.core\nimport distutils.filelist\nfrom distutils.util import convert_path\nfrom fnmatch import fnmatchcase\n\nfrom setuptools.extern.six import PY3\nfrom setuptools.extern.six.moves import filter, map\n\nimport setuptools.version\nfrom setuptools.extension import Extension\nfrom setuptools.dist import Distribution, Feature\nfrom setuptools.depends import Require\nfrom . import monkey\n\n__metaclass__ = type\n\n\n__all__ = [\n    'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',\n    'find_packages'\n]\n\nif PY3:\n  __all__.append('find_packages_ns')\n\n__version__ = setuptools.version.__version__\n\nbootstrap_install_from = None\n\n# If we run 2to3 on .py files, should we also convert docstrings?\n# Default: yes; assume that we can detect doctests reliably\nrun_2to3_on_doctests = True\n# Standard package names for fixer packages\nlib2to3_fixer_packages = ['lib2to3.fixes']\n\n\nclass PackageFinder:\n    \"\"\"\n    Generate a list of all Python packages found within a directory\n    \"\"\"\n\n    @classmethod\n    def find(cls, where='.', exclude=(), include=('*',)):\n        \"\"\"Return a list all Python packages found within directory 'where'\n\n        'where' is the root directory which will be searched for packages.  It\n        should be supplied as a \"cross-platform\" (i.e. URL-style) path; it will\n        be converted to the appropriate local path syntax.\n\n        'exclude' is a sequence of package names to exclude; '*' can be used\n        as a wildcard in the names, such that 'foo.*' will exclude all\n        subpackages of 'foo' (but not 'foo' itself).\n\n        'include' is a sequence of package names to include.  If it's\n        specified, only the named packages will be included.  If it's not\n        specified, all found packages will be included.  'include' can contain\n        shell style wildcard patterns just like 'exclude'.\n        \"\"\"\n\n        return list(cls._find_packages_iter(\n            convert_path(where),\n            cls._build_filter('ez_setup', '*__pycache__', *exclude),\n            cls._build_filter(*include)))\n\n    @classmethod\n    def _find_packages_iter(cls, where, exclude, include):\n        \"\"\"\n        All the packages found in 'where' that pass the 'include' filter, but\n        not the 'exclude' filter.\n        \"\"\"\n        for root, dirs, files in os.walk(where, followlinks=True):\n            # Copy dirs to iterate over it, then empty dirs.\n            all_dirs = dirs[:]\n            dirs[:] = []\n\n            for dir in all_dirs:\n                full_path = os.path.join(root, dir)\n                rel_path = os.path.relpath(full_path, where)\n                package = rel_path.replace(os.path.sep, '.')\n\n                # Skip directory trees that are not valid packages\n                if ('.' in dir or not cls._looks_like_package(full_path)):\n                    continue\n\n                # Should this package be included?\n                if include(package) and not exclude(package):\n                    yield package\n\n                # Keep searching subdirectories, as there may be more packages\n                # down there, even if the parent was excluded.\n                dirs.append(dir)\n\n    @staticmethod\n    def _looks_like_package(path):\n        \"\"\"Does a directory look like a package?\"\"\"\n        return os.path.isfile(os.path.join(path, '__init__.py'))\n\n    @staticmethod\n    def _build_filter(*patterns):\n        \"\"\"\n        Given a list of patterns, return a callable that will be true only if\n        the input matches at least one of the patterns.\n        \"\"\"\n        return lambda name: any(fnmatchcase(name, pat=pat) for pat in patterns)\n\n\nclass PEP420PackageFinder(PackageFinder):\n    @staticmethod\n    def _looks_like_package(path):\n        return True\n\n\nfind_packages = PackageFinder.find\n\nif PY3:\n  find_packages_ns = PEP420PackageFinder.find\n\n\ndef _install_setup_requires(attrs):\n    # Note: do not use `setuptools.Distribution` directly, as\n    # our PEP 517 backend patch `distutils.core.Distribution`.\n    dist = distutils.core.Distribution(dict(\n        (k, v) for k, v in attrs.items()\n        if k in ('dependency_links', 'setup_requires')\n    ))\n    # Honor setup.cfg's options.\n    dist.parse_config_files(ignore_option_errors=True)\n    if dist.setup_requires:\n        dist.fetch_build_eggs(dist.setup_requires)\n\n\ndef setup(**attrs):\n    # Make sure we have any requirements needed to interpret 'attrs'.\n    _install_setup_requires(attrs)\n    return distutils.core.setup(**attrs)\n\nsetup.__doc__ = distutils.core.setup.__doc__\n\n\n_Command = monkey.get_unpatched(distutils.core.Command)\n\n\nclass Command(_Command):\n    __doc__ = _Command.__doc__\n\n    command_consumes_arguments = False\n\n    def __init__(self, dist, **kw):\n        \"\"\"\n        Construct the command for dist, updating\n        vars(self) with any keyword parameters.\n        \"\"\"\n        _Command.__init__(self, dist)\n        vars(self).update(kw)\n\n    def reinitialize_command(self, command, reinit_subcommands=0, **kw):\n        cmd = _Command.reinitialize_command(self, command, reinit_subcommands)\n        vars(cmd).update(kw)\n        return cmd\n\n\ndef _find_all_simple(path):\n    \"\"\"\n    Find all files under 'path'\n    \"\"\"\n    results = (\n        os.path.join(base, file)\n        for base, dirs, files in os.walk(path, followlinks=True)\n        for file in files\n    )\n    return filter(os.path.isfile, results)\n\n\ndef findall(dir=os.curdir):\n    \"\"\"\n    Find all files under 'dir' and return the list of full filenames.\n    Unless dir is '.', return full filenames with dir prepended.\n    \"\"\"\n    files = _find_all_simple(dir)\n    if dir == os.curdir:\n        make_rel = functools.partial(os.path.relpath, start=dir)\n        files = map(make_rel, files)\n    return list(files)\n\n\nmonkey.patch_all()\n", "path": "setuptools/__init__.py"}]}