prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Unnecessary dependency on `pathlib` when running in python3
  ### Expected behaviour
  Datacube shouldn't depend on unnecessary packages when running in Python 3.
  
  ### Actual behaviour
  There's a dependency on `pathlib`, which is included in the Python 3 standard library, and so doesn't need to be installed.
  
  This causes trouble on the NCI deployment when trying to load `stats` modules which use the `setuptools` entry_points for their registration. And returns error messages to users trying to load them.
  
  ### Steps to reproduce the behaviour
  ```
  module load agdc-py3-prod agdc_statistics
  dra547@raijin4:~ $ python
  Python 3.6.3 | packaged by conda-forge | (default, Nov  4 2017, 10:10:56)
  [GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import datacube_stats.statistics
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/g/data/v10/public/modules/agdc_statistics/0.9a7/lib/python3.6/site-packages/datacube_stats/statistics.py", line 769, in <module>
      STATS[entry_point.name] = entry_point.load()
    File "/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2404, in load
      self.require(*args, **kwargs)
    File "/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2427, in require
      items = working_set.resolve(reqs, env, installer, extras=self.extras)
    File "/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/lib/python3.6/site-packages/pkg_resources/__init__.py", line 870, in resolve
      raise DistributionNotFound(req, requirers)
  pkg_resources.DistributionNotFound: The 'pathlib' distribution was not found and is required by datacube
  >>>
  ```
  
  ### The Fix
  Modify `setup.py` to use [platform specific dependencies](https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies) to only require `pathlib` when not running on python 3.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `setup.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 
  3 import versioneer
  4 from setuptools import setup, find_packages
  5 
  6 tests_require = [
  7     'pytest', 'pytest-cov', 'mock', 'pep8', 'pylint', 'hypothesis', 'compliance-checker', 'objgraph'
  8 ]
  9 
  10 extras_require = {
  11     'performance': ['ciso8601', 'bottleneck'],
  12     'interactive': ['matplotlib', 'fiona'],
  13     'distributed': ['distributed', 'dask[distributed]'],
  14     'analytics': ['scipy', 'pyparsing', 'numexpr'],
  15     'doc': ['Sphinx', 'setuptools'],
  16     'replicas': ['paramiko', 'sshtunnel', 'tqdm'],
  17     'celery': ['celery>=4', 'redis'],
  18     's3': ['boto3==1.4.3', 'SharedArray', 'pathos', 'zstandard'],
  19     'test': tests_require,
  20 }
  21 # An 'all' option, following ipython naming conventions.
  22 extras_require['all'] = sorted(set(sum(extras_require.values(), [])))
  23 
  24 setup(
  25     name='datacube',
  26     version=versioneer.get_version(),
  27     cmdclass=versioneer.get_cmdclass(),
  28 
  29     url='https://github.com/opendatacube/datacube-core',
  30     author='AGDC Collaboration',
  31     maintainer='AGDC Collaboration',
  32     maintainer_email='',
  33     description='An analysis environment for satellite and other earth observation data',
  34     long_description=open('README.rst').read(),
  35     license='Apache License 2.0',
  36     classifiers=[
  37         "Development Status :: 4 - Beta",
  38         "Intended Audience :: Developers",
  39         "Intended Audience :: Science/Research",
  40         "License :: OSI Approved :: Apache Software License",
  41         "Natural Language :: English",
  42         "Operating System :: MacOS :: MacOS X",
  43         "Operating System :: POSIX",
  44         "Operating System :: POSIX :: BSD",
  45         "Operating System :: POSIX :: Linux",
  46         "Operating System :: Microsoft :: Windows",
  47         "Programming Language :: Python",
  48         "Programming Language :: Python :: 2",
  49         "Programming Language :: Python :: 2.7",
  50         "Programming Language :: Python :: 3",
  51         "Programming Language :: Python :: 3.5",
  52         "Topic :: Scientific/Engineering :: GIS",
  53         "Topic :: Scientific/Engineering :: Information Analysis",
  54     ],
  55 
  56     packages=find_packages(
  57         exclude=('tests', 'tests.*',
  58                  'integration_tests', 'integration_tests.*')
  59     ),
  60     package_data={
  61         '': ['*.yaml', '*/*.yaml'],
  62     },
  63     scripts=[
  64         'datacube_apps/scripts/pbs_helpers.sh'
  65     ],
  66     setup_requires=[
  67         'pytest-runner'
  68     ],
  69     install_requires=[
  70         'affine',
  71         'cachetools',
  72         'click>=5.0',
  73         'cloudpickle>=0.4',
  74         'dask[array]',
  75         'gdal>=1.9',
  76         'jsonschema',
  77         'netcdf4',
  78         'numpy',
  79         'pathlib',
  80         'psycopg2',
  81         'pypeg2',
  82         'python-dateutil',
  83         'pyyaml',
  84         'rasterio>=0.9',  # required for zip reading, 0.9 gets around 1.0a ordering problems
  85         'singledispatch',
  86         'sqlalchemy',
  87         'xarray>=0.9',  # >0.9 fixes most problems with `crs` attributes being lost
  88     ],
  89     extras_require=extras_require,
  90     tests_require=tests_require,
  91 
  92     entry_points={
  93         'console_scripts': [
  94             'datacube-search = datacube.scripts.search_tool:cli',
  95             'datacube = datacube.scripts.cli_app:cli',
  96             'datacube-stacker = datacube_apps.stacker:main',
  97             'datacube-worker = datacube.execution.worker:main',
  98             'datacube-fixer = datacube_apps.stacker:fixer_main',
  99             'datacube-ncml = datacube_apps.ncml:ncml_app',
  100             'pixeldrill = datacube_apps.pixeldrill:main [interactive]',
  101             'movie_generator = datacube_apps.movie_generator:main',
  102             'datacube-simple-replica = datacube_apps.simple_replica:replicate'
  103         ]
  104     },
  105 )
  106
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/setup.py b/setup.py
  --- a/setup.py
  +++ b/setup.py
  @@ -76,7 +76,7 @@
           'jsonschema',
           'netcdf4',
           'numpy',
  -        'pathlib',
  +        'pathlib;python_version<"3"',
           'psycopg2',
           'pypeg2',
           'python-dateutil',
  
verification_info: {"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -76,7 +76,7 @@\n         'jsonschema',\n         'netcdf4',\n         'numpy',\n-        'pathlib',\n+        'pathlib;python_version<\"3\"',\n         'psycopg2',\n         'pypeg2',\n         'python-dateutil',\n", "issue": "Unnecessary dependency on `pathlib` when running in python3\n### Expected behaviour\r\nDatacube shouldn't depend on unnecessary packages when running in Python 3.\r\n\r\n### Actual behaviour\r\nThere's a dependency on `pathlib`, which is included in the Python 3 standard library, and so doesn't need to be installed.\r\n\r\nThis causes trouble on the NCI deployment when trying to load `stats` modules which use the `setuptools` entry_points for their registration. And returns error messages to users trying to load them.\r\n\r\n### Steps to reproduce the behaviour\r\n```\r\nmodule load agdc-py3-prod agdc_statistics\r\ndra547@raijin4:~ $ python\r\nPython 3.6.3 | packaged by conda-forge | (default, Nov  4 2017, 10:10:56)\r\n[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import datacube_stats.statistics\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/g/data/v10/public/modules/agdc_statistics/0.9a7/lib/python3.6/site-packages/datacube_stats/statistics.py\", line 769, in <module>\r\n    STATS[entry_point.name] = entry_point.load()\r\n  File \"/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/lib/python3.6/site-packages/pkg_resources/__init__.py\", line 2404, in load\r\n    self.require(*args, **kwargs)\r\n  File \"/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/lib/python3.6/site-packages/pkg_resources/__init__.py\", line 2427, in require\r\n    items = working_set.resolve(reqs, env, installer, extras=self.extras)\r\n  File \"/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/lib/python3.6/site-packages/pkg_resources/__init__.py\", line 870, in resolve\r\n    raise DistributionNotFound(req, requirers)\r\npkg_resources.DistributionNotFound: The 'pathlib' distribution was not found and is required by datacube\r\n>>>\r\n```\r\n\r\n### The Fix\r\nModify `setup.py` to use [platform specific dependencies](https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies) to only require `pathlib` when not running on python 3.\n", "before_files": [{"content": "#!/usr/bin/env python\n\nimport versioneer\nfrom setuptools import setup, find_packages\n\ntests_require = [\n    'pytest', 'pytest-cov', 'mock', 'pep8', 'pylint', 'hypothesis', 'compliance-checker', 'objgraph'\n]\n\nextras_require = {\n    'performance': ['ciso8601', 'bottleneck'],\n    'interactive': ['matplotlib', 'fiona'],\n    'distributed': ['distributed', 'dask[distributed]'],\n    'analytics': ['scipy', 'pyparsing', 'numexpr'],\n    'doc': ['Sphinx', 'setuptools'],\n    'replicas': ['paramiko', 'sshtunnel', 'tqdm'],\n    'celery': ['celery>=4', 'redis'],\n    's3': ['boto3==1.4.3', 'SharedArray', 'pathos', 'zstandard'],\n    'test': tests_require,\n}\n# An 'all' option, following ipython naming conventions.\nextras_require['all'] = sorted(set(sum(extras_require.values(), [])))\n\nsetup(\n    name='datacube',\n    version=versioneer.get_version(),\n    cmdclass=versioneer.get_cmdclass(),\n\n    url='https://github.com/opendatacube/datacube-core',\n    author='AGDC Collaboration',\n    maintainer='AGDC Collaboration',\n    maintainer_email='',\n    description='An analysis environment for satellite and other earth observation data',\n    long_description=open('README.rst').read(),\n    license='Apache License 2.0',\n    classifiers=[\n        \"Development Status :: 4 - Beta\",\n        \"Intended Audience :: Developers\",\n        \"Intended Audience :: Science/Research\",\n        \"License :: OSI Approved :: Apache Software License\",\n        \"Natural Language :: English\",\n        \"Operating System :: MacOS :: MacOS X\",\n        \"Operating System :: POSIX\",\n        \"Operating System :: POSIX :: BSD\",\n        \"Operating System :: POSIX :: Linux\",\n        \"Operating System :: Microsoft :: Windows\",\n        \"Programming Language :: Python\",\n        \"Programming Language :: Python :: 2\",\n        \"Programming Language :: Python :: 2.7\",\n        \"Programming Language :: Python :: 3\",\n        \"Programming Language :: Python :: 3.5\",\n        \"Topic :: Scientific/Engineering :: GIS\",\n        \"Topic :: Scientific/Engineering :: Information Analysis\",\n    ],\n\n    packages=find_packages(\n        exclude=('tests', 'tests.*',\n                 'integration_tests', 'integration_tests.*')\n    ),\n    package_data={\n        '': ['*.yaml', '*/*.yaml'],\n    },\n    scripts=[\n        'datacube_apps/scripts/pbs_helpers.sh'\n    ],\n    setup_requires=[\n        'pytest-runner'\n    ],\n    install_requires=[\n        'affine',\n        'cachetools',\n        'click>=5.0',\n        'cloudpickle>=0.4',\n        'dask[array]',\n        'gdal>=1.9',\n        'jsonschema',\n        'netcdf4',\n        'numpy',\n        'pathlib',\n        'psycopg2',\n        'pypeg2',\n        'python-dateutil',\n        'pyyaml',\n        'rasterio>=0.9',  # required for zip reading, 0.9 gets around 1.0a ordering problems\n        'singledispatch',\n        'sqlalchemy',\n        'xarray>=0.9',  # >0.9 fixes most problems with `crs` attributes being lost\n    ],\n    extras_require=extras_require,\n    tests_require=tests_require,\n\n    entry_points={\n        'console_scripts': [\n            'datacube-search = datacube.scripts.search_tool:cli',\n            'datacube = datacube.scripts.cli_app:cli',\n            'datacube-stacker = datacube_apps.stacker:main',\n            'datacube-worker = datacube.execution.worker:main',\n            'datacube-fixer = datacube_apps.stacker:fixer_main',\n            'datacube-ncml = datacube_apps.ncml:ncml_app',\n            'pixeldrill = datacube_apps.pixeldrill:main [interactive]',\n            'movie_generator = datacube_apps.movie_generator:main',\n            'datacube-simple-replica = datacube_apps.simple_replica:replicate'\n        ]\n    },\n)\n", "path": "setup.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\nimport versioneer\nfrom setuptools import setup, find_packages\n\ntests_require = [\n    'pytest', 'pytest-cov', 'mock', 'pep8', 'pylint', 'hypothesis', 'compliance-checker', 'objgraph'\n]\n\nextras_require = {\n    'performance': ['ciso8601', 'bottleneck'],\n    'interactive': ['matplotlib', 'fiona'],\n    'distributed': ['distributed', 'dask[distributed]'],\n    'analytics': ['scipy', 'pyparsing', 'numexpr'],\n    'doc': ['Sphinx', 'setuptools'],\n    'replicas': ['paramiko', 'sshtunnel', 'tqdm'],\n    'celery': ['celery>=4', 'redis'],\n    's3': ['boto3==1.4.3', 'SharedArray', 'pathos', 'zstandard'],\n    'test': tests_require,\n}\n# An 'all' option, following ipython naming conventions.\nextras_require['all'] = sorted(set(sum(extras_require.values(), [])))\n\nsetup(\n    name='datacube',\n    version=versioneer.get_version(),\n    cmdclass=versioneer.get_cmdclass(),\n\n    url='https://github.com/opendatacube/datacube-core',\n    author='AGDC Collaboration',\n    maintainer='AGDC Collaboration',\n    maintainer_email='',\n    description='An analysis environment for satellite and other earth observation data',\n    long_description=open('README.rst').read(),\n    license='Apache License 2.0',\n    classifiers=[\n        \"Development Status :: 4 - Beta\",\n        \"Intended Audience :: Developers\",\n        \"Intended Audience :: Science/Research\",\n        \"License :: OSI Approved :: Apache Software License\",\n        \"Natural Language :: English\",\n        \"Operating System :: MacOS :: MacOS X\",\n        \"Operating System :: POSIX\",\n        \"Operating System :: POSIX :: BSD\",\n        \"Operating System :: POSIX :: Linux\",\n        \"Operating System :: Microsoft :: Windows\",\n        \"Programming Language :: Python\",\n        \"Programming Language :: Python :: 2\",\n        \"Programming Language :: Python :: 2.7\",\n        \"Programming Language :: Python :: 3\",\n        \"Programming Language :: Python :: 3.5\",\n        \"Topic :: Scientific/Engineering :: GIS\",\n        \"Topic :: Scientific/Engineering :: Information Analysis\",\n    ],\n\n    packages=find_packages(\n        exclude=('tests', 'tests.*',\n                 'integration_tests', 'integration_tests.*')\n    ),\n    package_data={\n        '': ['*.yaml', '*/*.yaml'],\n    },\n    scripts=[\n        'datacube_apps/scripts/pbs_helpers.sh'\n    ],\n    setup_requires=[\n        'pytest-runner'\n    ],\n    install_requires=[\n        'affine',\n        'cachetools',\n        'click>=5.0',\n        'cloudpickle>=0.4',\n        'dask[array]',\n        'gdal>=1.9',\n        'jsonschema',\n        'netcdf4',\n        'numpy',\n        'pathlib;python_version<\"3\"',\n        'psycopg2',\n        'pypeg2',\n        'python-dateutil',\n        'pyyaml',\n        'rasterio>=0.9',  # required for zip reading, 0.9 gets around 1.0a ordering problems\n        'singledispatch',\n        'sqlalchemy',\n        'xarray>=0.9',  # >0.9 fixes most problems with `crs` attributes being lost\n    ],\n    extras_require=extras_require,\n    tests_require=tests_require,\n\n    entry_points={\n        'console_scripts': [\n            'datacube-search = datacube.scripts.search_tool:cli',\n            'datacube = datacube.scripts.cli_app:cli',\n            'datacube-stacker = datacube_apps.stacker:main',\n            'datacube-worker = datacube.execution.worker:main',\n            'datacube-fixer = datacube_apps.stacker:fixer_main',\n            'datacube-ncml = datacube_apps.ncml:ncml_app',\n            'pixeldrill = datacube_apps.pixeldrill:main [interactive]',\n            'movie_generator = datacube_apps.movie_generator:main',\n            'datacube-simple-replica = datacube_apps.simple_replica:replicate'\n        ]\n    },\n)\n", "path": "setup.py"}]}