We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Extra files in source distribution packaging
`python setup.py sdist` builds source distribution with docs and tests and bunch of random files in it, that should not be included. Strangely `bdist_wheel` does not include those and generates proper release file.

https://github.com/conda-forge/datacube-feedstock/issues/25

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `datacube/utils/xarray_geoextensions.py`
Content:
```
1 """
2 Add geometric extensions to :class:`xarray.Dataset` and :class:`xarray.DataArray` for use
3 with Data Cube by Monkey Patching those classes.
4 
5 This extension is reliant on an `xarray` object having a `.crs` property of type
6 :class:`datacube.utils.geometry.CRS`. This is used to inspect the spatial dimensions of the
7 :class:`Dataset` or :class:`DataArray`, and provide new attributes for accessing a
8 :class:`datacube.utils.geometry.GeoBox`, affine transform and extent for the dataset as
9 `.geobox`, `.affine` and `.extent` respectively.
10 
11 """
12 
13 import xarray
14 
15 from datacube.utils import geometry, spatial_dims
16 from datacube.utils.math import affine_from_axis
17 
18 
19 def _norm_crs(crs):
20     if crs is None or isinstance(crs, geometry.CRS):
21         return crs
22     elif isinstance(crs, str):
23         return geometry.CRS(crs)
24     else:
25         raise ValueError('Can not interpret {} as CRS'.format(type(crs)))
26 
27 
28 def _get_crs_from_attrs(obj, sdims):
29     """ Looks for attribute named `crs` containing CRS string
30         1. Checks spatials coords attrs
31         2. Checks data variable attrs
32         3. Checks dataset attrs
33 
34         Returns
35         =======
36         Content for `.attrs[crs]` usually it's a string
37         None if not present in any of the places listed above
38     """
39     if isinstance(obj, xarray.Dataset):
40         if len(obj.data_vars) > 0:
41             data_array = next(iter(obj.data_vars.values()))
42         else:
43             # fall back option
44             return obj.attrs.get('crs', None)
45     else:
46         data_array = obj
47 
48     crs_set = set(data_array[d].attrs.get('crs', None) for d in sdims)
49     crs = None
50     if len(crs_set) > 1:
51         raise ValueError('Spatial dimensions have different crs.')
52     elif len(crs_set) == 1:
53         crs = crs_set.pop()
54 
55     if crs is None:
56         # fall back option
57         crs = data_array.attrs.get('crs', None) or obj.attrs.get('crs', None)
58     return crs
59 
60 
61 def _get_crs_from_coord(obj, mode='strict'):
62     """ Looks for dimensionless coordinate with `spatial_ref` attribute.
63 
64         obj: Dataset | DataArray
65         mode: strict|any|all
66            strict -- raise Error if multiple candidates
67            any    -- return first one
68            all    -- return a list of all found CRSs
69 
70        Returns
71        =======
72        None     - if none found
73        crs:str  - if found one
74        crs:str  - if found several but mode is any
75 
76        (crs: str, crs: str) - if found several and mode=all
77     """
78     grid_mapping = obj.attrs.get('grid_mapping', None)
79 
80     # First check CF convention "pointer"
81     if grid_mapping is not None and grid_mapping in obj.coords:
82         coord = obj.coords[grid_mapping]
83         spatial_ref = coord.attrs.get('spatial_ref', None)
84         if spatial_ref is not None:
85             return spatial_ref
86         else:
87             raise ValueError(f"Coordinate '{grid_mapping}' has no `spatial_ref` attribute")
88 
89     # No explicit `grid_mapping` find some "CRS" coordinate
90     candidates = tuple(coord.attrs['spatial_ref'] for coord in obj.coords.values()
91                        if coord.ndim == 0 and 'spatial_ref' in coord.attrs)
92 
93     if len(candidates) == 0:
94         return None
95     if len(candidates) == 1:
96         return candidates[0]
97 
98     if mode == 'strict':
99         raise ValueError("Too many candidates when looking for CRS")
100     elif mode == 'all':
101         return candidates
102     elif mode == 'any':
103         return candidates[0]
104     else:
105         raise ValueError(f"Mode needs to be: strict|any|all got {mode}")
106 
107 
108 def _xarray_affine_impl(obj):
109     sdims = spatial_dims(obj, relaxed=True)
110     if sdims is None:
111         return None, None
112 
113     yy, xx = (obj[dim] for dim in sdims)
114     fallback_res = (coord.attrs.get('resolution', None) for coord in (xx, yy))
115 
116     return affine_from_axis(xx.values, yy.values, fallback_res), sdims
117 
118 
119 def _xarray_affine(obj):
120     transform, _ = _xarray_affine_impl(obj)
121     return transform
122 
123 
124 def _xarray_extent(obj):
125     geobox = obj.geobox
126     return None if geobox is None else geobox.extent
127 
128 
129 def _xarray_geobox(obj):
130     transform, sdims = _xarray_affine_impl(obj)
131     if sdims is None:
132         return None
133 
134     crs = None
135     try:
136         crs = _get_crs_from_coord(obj)
137     except ValueError:
138         pass
139 
140     if crs is None:
141         try:
142             crs = _get_crs_from_attrs(obj, sdims)
143         except ValueError:
144             pass
145 
146     if crs is None:
147         return None
148 
149     try:
150         crs = _norm_crs(crs)
151     except ValueError:
152         return None
153 
154     h, w = (obj.coords[dim].size for dim in sdims)
155 
156     return geometry.GeoBox(w, h, transform, crs)
157 
158 
159 xarray.Dataset.geobox = property(_xarray_geobox)    # type: ignore
160 xarray.Dataset.affine = property(_xarray_affine)    # type: ignore
161 xarray.Dataset.extent = property(_xarray_extent)    # type: ignore
162 xarray.DataArray.geobox = property(_xarray_geobox)  # type: ignore
163 xarray.DataArray.affine = property(_xarray_affine)  # type: ignore
164 xarray.DataArray.extent = property(_xarray_extent)  # type: ignore
165
```
--- 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/datacube/utils/xarray_geoextensions.py b/datacube/utils/xarray_geoextensions.py
--- a/datacube/utils/xarray_geoextensions.py
+++ b/datacube/utils/xarray_geoextensions.py
@@ -9,9 +9,8 @@
 `.geobox`, `.affine` and `.extent` respectively.
 
 """
-
+import warnings
 import xarray
-
 from datacube.utils import geometry, spatial_dims
 from datacube.utils.math import affine_from_axis
 
@@ -27,34 +26,48 @@
 
 def _get_crs_from_attrs(obj, sdims):
     """ Looks for attribute named `crs` containing CRS string
-        1. Checks spatials coords attrs
-        2. Checks data variable attrs
-        3. Checks dataset attrs
+        - Checks spatials coords attrs
+        - Checks data variable attrs
+        - Checks dataset attrs
 
         Returns
         =======
         Content for `.attrs[crs]` usually it's a string
         None if not present in any of the places listed above
     """
-    if isinstance(obj, xarray.Dataset):
-        if len(obj.data_vars) > 0:
-            data_array = next(iter(obj.data_vars.values()))
+    crs_set = set()
+
+    def _add_candidate(crs):
+        if crs is None:
+            return
+        if isinstance(crs, str):
+            crs_set.add(crs)
         else:
-            # fall back option
-            return obj.attrs.get('crs', None)
+            warnings.warn(f"Ignoring crs attribute of type: {type(crs)}")
+
+    def process_attrs(attrs):
+        _add_candidate(attrs.get('crs', None))
+        _add_candidate(attrs.get('crs_wkt', None))
+
+    def process_datavar(x):
+        process_attrs(x.attrs)
+        for dim in sdims:
+            if dim in x.coords:
+                process_attrs(x.coords[dim].attrs)
+
+    if isinstance(obj, xarray.Dataset):
+        process_attrs(obj.attrs)
+        for dv in obj.data_vars.values():
+            process_datavar(dv)
     else:
-        data_array = obj
+        process_datavar(obj)
 
-    crs_set = set(data_array[d].attrs.get('crs', None) for d in sdims)
     crs = None
     if len(crs_set) > 1:
         raise ValueError('Spatial dimensions have different crs.')
     elif len(crs_set) == 1:
         crs = crs_set.pop()
 
-    if crs is None:
-        # fall back option
-        crs = data_array.attrs.get('crs', None) or obj.attrs.get('crs', None)
     return crs
 
 
@@ -148,7 +161,8 @@
 
     try:
         crs = _norm_crs(crs)
-    except ValueError:
+    except (ValueError, geometry.CRSError):
+        warnings.warn(f"Encountered malformed CRS: {crs}")
         return None
 
     h, w = (obj.coords[dim].size for dim in sdims)

{"golden_diff": "diff --git a/datacube/utils/xarray_geoextensions.py b/datacube/utils/xarray_geoextensions.py\n--- a/datacube/utils/xarray_geoextensions.py\n+++ b/datacube/utils/xarray_geoextensions.py\n@@ -9,9 +9,8 @@\n `.geobox`, `.affine` and `.extent` respectively.\n \n \"\"\"\n-\n+import warnings\n import xarray\n-\n from datacube.utils import geometry, spatial_dims\n from datacube.utils.math import affine_from_axis\n \n@@ -27,34 +26,48 @@\n \n def _get_crs_from_attrs(obj, sdims):\n     \"\"\" Looks for attribute named `crs` containing CRS string\n-        1. Checks spatials coords attrs\n-        2. Checks data variable attrs\n-        3. Checks dataset attrs\n+        - Checks spatials coords attrs\n+        - Checks data variable attrs\n+        - Checks dataset attrs\n \n         Returns\n         =======\n         Content for `.attrs[crs]` usually it's a string\n         None if not present in any of the places listed above\n     \"\"\"\n-    if isinstance(obj, xarray.Dataset):\n-        if len(obj.data_vars) > 0:\n-            data_array = next(iter(obj.data_vars.values()))\n+    crs_set = set()\n+\n+    def _add_candidate(crs):\n+        if crs is None:\n+            return\n+        if isinstance(crs, str):\n+            crs_set.add(crs)\n         else:\n-            # fall back option\n-            return obj.attrs.get('crs', None)\n+            warnings.warn(f\"Ignoring crs attribute of type: {type(crs)}\")\n+\n+    def process_attrs(attrs):\n+        _add_candidate(attrs.get('crs', None))\n+        _add_candidate(attrs.get('crs_wkt', None))\n+\n+    def process_datavar(x):\n+        process_attrs(x.attrs)\n+        for dim in sdims:\n+            if dim in x.coords:\n+                process_attrs(x.coords[dim].attrs)\n+\n+    if isinstance(obj, xarray.Dataset):\n+        process_attrs(obj.attrs)\n+        for dv in obj.data_vars.values():\n+            process_datavar(dv)\n     else:\n-        data_array = obj\n+        process_datavar(obj)\n \n-    crs_set = set(data_array[d].attrs.get('crs', None) for d in sdims)\n     crs = None\n     if len(crs_set) > 1:\n         raise ValueError('Spatial dimensions have different crs.')\n     elif len(crs_set) == 1:\n         crs = crs_set.pop()\n \n-    if crs is None:\n-        # fall back option\n-        crs = data_array.attrs.get('crs', None) or obj.attrs.get('crs', None)\n     return crs\n \n \n@@ -148,7 +161,8 @@\n \n     try:\n         crs = _norm_crs(crs)\n-    except ValueError:\n+    except (ValueError, geometry.CRSError):\n+        warnings.warn(f\"Encountered malformed CRS: {crs}\")\n         return None\n \n     h, w = (obj.coords[dim].size for dim in sdims)\n", "issue": "Extra files in source distribution packaging\n`python setup.py sdist` builds source distribution with docs and tests and bunch of random files in it, that should not be included. Strangely `bdist_wheel` does not include those and generates proper release file.\r\n\r\nhttps://github.com/conda-forge/datacube-feedstock/issues/25\n", "before_files": [{"content": "\"\"\"\nAdd geometric extensions to :class:`xarray.Dataset` and :class:`xarray.DataArray` for use\nwith Data Cube by Monkey Patching those classes.\n\nThis extension is reliant on an `xarray` object having a `.crs` property of type\n:class:`datacube.utils.geometry.CRS`. This is used to inspect the spatial dimensions of the\n:class:`Dataset` or :class:`DataArray`, and provide new attributes for accessing a\n:class:`datacube.utils.geometry.GeoBox`, affine transform and extent for the dataset as\n`.geobox`, `.affine` and `.extent` respectively.\n\n\"\"\"\n\nimport xarray\n\nfrom datacube.utils import geometry, spatial_dims\nfrom datacube.utils.math import affine_from_axis\n\n\ndef _norm_crs(crs):\n    if crs is None or isinstance(crs, geometry.CRS):\n        return crs\n    elif isinstance(crs, str):\n        return geometry.CRS(crs)\n    else:\n        raise ValueError('Can not interpret {} as CRS'.format(type(crs)))\n\n\ndef _get_crs_from_attrs(obj, sdims):\n    \"\"\" Looks for attribute named `crs` containing CRS string\n        1. Checks spatials coords attrs\n        2. Checks data variable attrs\n        3. Checks dataset attrs\n\n        Returns\n        =======\n        Content for `.attrs[crs]` usually it's a string\n        None if not present in any of the places listed above\n    \"\"\"\n    if isinstance(obj, xarray.Dataset):\n        if len(obj.data_vars) > 0:\n            data_array = next(iter(obj.data_vars.values()))\n        else:\n            # fall back option\n            return obj.attrs.get('crs', None)\n    else:\n        data_array = obj\n\n    crs_set = set(data_array[d].attrs.get('crs', None) for d in sdims)\n    crs = None\n    if len(crs_set) > 1:\n        raise ValueError('Spatial dimensions have different crs.')\n    elif len(crs_set) == 1:\n        crs = crs_set.pop()\n\n    if crs is None:\n        # fall back option\n        crs = data_array.attrs.get('crs', None) or obj.attrs.get('crs', None)\n    return crs\n\n\ndef _get_crs_from_coord(obj, mode='strict'):\n    \"\"\" Looks for dimensionless coordinate with `spatial_ref` attribute.\n\n        obj: Dataset | DataArray\n        mode: strict|any|all\n           strict -- raise Error if multiple candidates\n           any    -- return first one\n           all    -- return a list of all found CRSs\n\n       Returns\n       =======\n       None     - if none found\n       crs:str  - if found one\n       crs:str  - if found several but mode is any\n\n       (crs: str, crs: str) - if found several and mode=all\n    \"\"\"\n    grid_mapping = obj.attrs.get('grid_mapping', None)\n\n    # First check CF convention \"pointer\"\n    if grid_mapping is not None and grid_mapping in obj.coords:\n        coord = obj.coords[grid_mapping]\n        spatial_ref = coord.attrs.get('spatial_ref', None)\n        if spatial_ref is not None:\n            return spatial_ref\n        else:\n            raise ValueError(f\"Coordinate '{grid_mapping}' has no `spatial_ref` attribute\")\n\n    # No explicit `grid_mapping` find some \"CRS\" coordinate\n    candidates = tuple(coord.attrs['spatial_ref'] for coord in obj.coords.values()\n                       if coord.ndim == 0 and 'spatial_ref' in coord.attrs)\n\n    if len(candidates) == 0:\n        return None\n    if len(candidates) == 1:\n        return candidates[0]\n\n    if mode == 'strict':\n        raise ValueError(\"Too many candidates when looking for CRS\")\n    elif mode == 'all':\n        return candidates\n    elif mode == 'any':\n        return candidates[0]\n    else:\n        raise ValueError(f\"Mode needs to be: strict|any|all got {mode}\")\n\n\ndef _xarray_affine_impl(obj):\n    sdims = spatial_dims(obj, relaxed=True)\n    if sdims is None:\n        return None, None\n\n    yy, xx = (obj[dim] for dim in sdims)\n    fallback_res = (coord.attrs.get('resolution', None) for coord in (xx, yy))\n\n    return affine_from_axis(xx.values, yy.values, fallback_res), sdims\n\n\ndef _xarray_affine(obj):\n    transform, _ = _xarray_affine_impl(obj)\n    return transform\n\n\ndef _xarray_extent(obj):\n    geobox = obj.geobox\n    return None if geobox is None else geobox.extent\n\n\ndef _xarray_geobox(obj):\n    transform, sdims = _xarray_affine_impl(obj)\n    if sdims is None:\n        return None\n\n    crs = None\n    try:\n        crs = _get_crs_from_coord(obj)\n    except ValueError:\n        pass\n\n    if crs is None:\n        try:\n            crs = _get_crs_from_attrs(obj, sdims)\n        except ValueError:\n            pass\n\n    if crs is None:\n        return None\n\n    try:\n        crs = _norm_crs(crs)\n    except ValueError:\n        return None\n\n    h, w = (obj.coords[dim].size for dim in sdims)\n\n    return geometry.GeoBox(w, h, transform, crs)\n\n\nxarray.Dataset.geobox = property(_xarray_geobox)    # type: ignore\nxarray.Dataset.affine = property(_xarray_affine)    # type: ignore\nxarray.Dataset.extent = property(_xarray_extent)    # type: ignore\nxarray.DataArray.geobox = property(_xarray_geobox)  # type: ignore\nxarray.DataArray.affine = property(_xarray_affine)  # type: ignore\nxarray.DataArray.extent = property(_xarray_extent)  # type: ignore\n", "path": "datacube/utils/xarray_geoextensions.py"}], "after_files": [{"content": "\"\"\"\nAdd geometric extensions to :class:`xarray.Dataset` and :class:`xarray.DataArray` for use\nwith Data Cube by Monkey Patching those classes.\n\nThis extension is reliant on an `xarray` object having a `.crs` property of type\n:class:`datacube.utils.geometry.CRS`. This is used to inspect the spatial dimensions of the\n:class:`Dataset` or :class:`DataArray`, and provide new attributes for accessing a\n:class:`datacube.utils.geometry.GeoBox`, affine transform and extent for the dataset as\n`.geobox`, `.affine` and `.extent` respectively.\n\n\"\"\"\nimport warnings\nimport xarray\nfrom datacube.utils import geometry, spatial_dims\nfrom datacube.utils.math import affine_from_axis\n\n\ndef _norm_crs(crs):\n    if crs is None or isinstance(crs, geometry.CRS):\n        return crs\n    elif isinstance(crs, str):\n        return geometry.CRS(crs)\n    else:\n        raise ValueError('Can not interpret {} as CRS'.format(type(crs)))\n\n\ndef _get_crs_from_attrs(obj, sdims):\n    \"\"\" Looks for attribute named `crs` containing CRS string\n        - Checks spatials coords attrs\n        - Checks data variable attrs\n        - Checks dataset attrs\n\n        Returns\n        =======\n        Content for `.attrs[crs]` usually it's a string\n        None if not present in any of the places listed above\n    \"\"\"\n    crs_set = set()\n\n    def _add_candidate(crs):\n        if crs is None:\n            return\n        if isinstance(crs, str):\n            crs_set.add(crs)\n        else:\n            warnings.warn(f\"Ignoring crs attribute of type: {type(crs)}\")\n\n    def process_attrs(attrs):\n        _add_candidate(attrs.get('crs', None))\n        _add_candidate(attrs.get('crs_wkt', None))\n\n    def process_datavar(x):\n        process_attrs(x.attrs)\n        for dim in sdims:\n            if dim in x.coords:\n                process_attrs(x.coords[dim].attrs)\n\n    if isinstance(obj, xarray.Dataset):\n        process_attrs(obj.attrs)\n        for dv in obj.data_vars.values():\n            process_datavar(dv)\n    else:\n        process_datavar(obj)\n\n    crs = None\n    if len(crs_set) > 1:\n        raise ValueError('Spatial dimensions have different crs.')\n    elif len(crs_set) == 1:\n        crs = crs_set.pop()\n\n    return crs\n\n\ndef _get_crs_from_coord(obj, mode='strict'):\n    \"\"\" Looks for dimensionless coordinate with `spatial_ref` attribute.\n\n        obj: Dataset | DataArray\n        mode: strict|any|all\n           strict -- raise Error if multiple candidates\n           any    -- return first one\n           all    -- return a list of all found CRSs\n\n       Returns\n       =======\n       None     - if none found\n       crs:str  - if found one\n       crs:str  - if found several but mode is any\n\n       (crs: str, crs: str) - if found several and mode=all\n    \"\"\"\n    grid_mapping = obj.attrs.get('grid_mapping', None)\n\n    # First check CF convention \"pointer\"\n    if grid_mapping is not None and grid_mapping in obj.coords:\n        coord = obj.coords[grid_mapping]\n        spatial_ref = coord.attrs.get('spatial_ref', None)\n        if spatial_ref is not None:\n            return spatial_ref\n        else:\n            raise ValueError(f\"Coordinate '{grid_mapping}' has no `spatial_ref` attribute\")\n\n    # No explicit `grid_mapping` find some \"CRS\" coordinate\n    candidates = tuple(coord.attrs['spatial_ref'] for coord in obj.coords.values()\n                       if coord.ndim == 0 and 'spatial_ref' in coord.attrs)\n\n    if len(candidates) == 0:\n        return None\n    if len(candidates) == 1:\n        return candidates[0]\n\n    if mode == 'strict':\n        raise ValueError(\"Too many candidates when looking for CRS\")\n    elif mode == 'all':\n        return candidates\n    elif mode == 'any':\n        return candidates[0]\n    else:\n        raise ValueError(f\"Mode needs to be: strict|any|all got {mode}\")\n\n\ndef _xarray_affine_impl(obj):\n    sdims = spatial_dims(obj, relaxed=True)\n    if sdims is None:\n        return None, None\n\n    yy, xx = (obj[dim] for dim in sdims)\n    fallback_res = (coord.attrs.get('resolution', None) for coord in (xx, yy))\n\n    return affine_from_axis(xx.values, yy.values, fallback_res), sdims\n\n\ndef _xarray_affine(obj):\n    transform, _ = _xarray_affine_impl(obj)\n    return transform\n\n\ndef _xarray_extent(obj):\n    geobox = obj.geobox\n    return None if geobox is None else geobox.extent\n\n\ndef _xarray_geobox(obj):\n    transform, sdims = _xarray_affine_impl(obj)\n    if sdims is None:\n        return None\n\n    crs = None\n    try:\n        crs = _get_crs_from_coord(obj)\n    except ValueError:\n        pass\n\n    if crs is None:\n        try:\n            crs = _get_crs_from_attrs(obj, sdims)\n        except ValueError:\n            pass\n\n    if crs is None:\n        return None\n\n    try:\n        crs = _norm_crs(crs)\n    except (ValueError, geometry.CRSError):\n        warnings.warn(f\"Encountered malformed CRS: {crs}\")\n        return None\n\n    h, w = (obj.coords[dim].size for dim in sdims)\n\n    return geometry.GeoBox(w, h, transform, crs)\n\n\nxarray.Dataset.geobox = property(_xarray_geobox)    # type: ignore\nxarray.Dataset.affine = property(_xarray_affine)    # type: ignore\nxarray.Dataset.extent = property(_xarray_extent)    # type: ignore\nxarray.DataArray.geobox = property(_xarray_geobox)  # type: ignore\nxarray.DataArray.affine = property(_xarray_affine)  # type: ignore\nxarray.DataArray.extent = property(_xarray_extent)  # type: ignore\n", "path": "datacube/utils/xarray_geoextensions.py"}]}