We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Skip local rasterfill.cpp for GDAL >= 2.0
Our local rasterfill.cpp (see #253) is in GDAL 2.+: https://github.com/OSGeo/gdal/pull/47.


--- 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 # Two environmental variables influence this script.
4 #
5 # GDAL_CONFIG: the path to a gdal-config program that points to GDAL headers,
6 # libraries, and data files.
7 #
8 # PACKAGE_DATA: if defined, GDAL and PROJ4 data files will be copied into the
9 # source or binary distribution. This is essential when creating self-contained
10 # binary wheels.
11 
12 import logging
13 import os
14 import pprint
15 import shutil
16 import subprocess
17 import sys
18 
19 from setuptools import setup
20 from setuptools.extension import Extension
21 
22 
23 logging.basicConfig()
24 log = logging.getLogger()
25 
26 
27 def check_output(cmd):
28     # since subprocess.check_output doesn't exist in 2.6
29     # we wrap it here.
30     try:
31         out = subprocess.check_output(cmd)
32         return out.decode('utf')
33     except AttributeError:
34         # For some reasone check_output doesn't exist
35         # So fall back on Popen
36         p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
37         out, err = p.communicate()
38         return out
39 
40 
41 def copy_data_tree(datadir, destdir):
42     try:
43         shutil.rmtree(destdir)
44     except OSError:
45         pass
46     shutil.copytree(datadir, destdir)
47 
48 
49 # python -W all setup.py ...
50 if 'all' in sys.warnoptions:
51     log.level = logging.DEBUG
52 
53 # Parse the version from the rasterio module.
54 with open('rasterio/__init__.py') as f:
55     for line in f:
56         if line.find("__version__") >= 0:
57             version = line.split("=")[1].strip()
58             version = version.strip('"')
59             version = version.strip("'")
60             continue
61 
62 with open('VERSION.txt', 'w') as f:
63     f.write(version)
64 
65 # Use Cython if available.
66 try:
67     from Cython.Build import cythonize
68 except ImportError:
69     cythonize = None
70 
71 # By default we'll try to get options via gdal-config. On systems without,
72 # options will need to be set in setup.cfg or on the setup command line.
73 include_dirs = []
74 library_dirs = []
75 libraries = []
76 extra_link_args = []
77 gdal_output = [None]*3
78 
79 try:
80     import numpy
81     include_dirs.append(numpy.get_include())
82 except ImportError:
83     log.critical("Numpy and its headers are required to run setup(). Exiting.")
84     sys.exit(1)
85 
86 try:
87     gdal_config = os.environ.get('GDAL_CONFIG', 'gdal-config')
88     for i, flag in enumerate(("--cflags", "--libs", "--datadir")):
89         gdal_output[i] = check_output([gdal_config, flag]).strip()
90 
91     for item in gdal_output[0].split():
92         if item.startswith("-I"):
93             include_dirs.extend(item[2:].split(":"))
94     for item in gdal_output[1].split():
95         if item.startswith("-L"):
96             library_dirs.extend(item[2:].split(":"))
97         elif item.startswith("-l"):
98             libraries.append(item[2:])
99         else:
100             # e.g. -framework GDAL
101             extra_link_args.append(item)
102 
103 except Exception as e:
104     if os.name == "nt":
105         log.info(("Building on Windows requires extra options to setup.py to locate needed GDAL files.\n"
106                  "More information is available in the README."))
107     else:
108         log.warning("Failed to get options via gdal-config: %s", str(e))
109 
110 
111 # Conditionally copy the GDAL data. To be used in conjunction with
112 # the bdist_wheel command to make self-contained binary wheels.
113 if os.environ.get('PACKAGE_DATA'):
114     destdir = 'rasterio/gdal_data'
115     if gdal_output[2]:
116         log.info("Copying gdal data from %s" % gdal_output[2])
117         copy_data_tree(gdal_output[2], destdir)
118     else:
119         # check to see if GDAL_DATA is defined
120         gdal_data = os.environ.get('GDAL_DATA', None)
121         if gdal_data:
122             log.info("Copying gdal_data from %s" % gdal_data)
123             copy_data_tree(gdal_data, destdir)
124 
125     # Conditionally copy PROJ.4 data.
126     projdatadir = os.environ.get('PROJ_LIB', '/usr/local/share/proj')
127     if os.path.exists(projdatadir):
128         log.info("Copying proj_data from %s" % projdatadir)
129         copy_data_tree(projdatadir, 'rasterio/proj_data')
130 
131 ext_options = dict(
132     include_dirs=include_dirs,
133     library_dirs=library_dirs,
134     libraries=libraries,
135     extra_link_args=extra_link_args)
136 
137 if not os.name == "nt":
138     # These options fail on Windows if using Visual Studio
139     ext_options['extra_compile_args'] = ['-Wno-unused-parameter',
140                                          '-Wno-unused-function']
141 
142 cythonize_options = {}
143 if os.environ.get('CYTHON_COVERAGE'):
144     cythonize_options['compiler_directives'] = {'linetrace': True}
145     cythonize_options['annotate'] = True
146     ext_options['define_macros'] = [('CYTHON_TRACE', '1'),
147                                     ('CYTHON_TRACE_NOGIL', '1')]
148 
149 log.debug('ext_options:\n%s', pprint.pformat(ext_options))
150 
151 # When building from a repo, Cython is required.
152 if os.path.exists("MANIFEST.in") and "clean" not in sys.argv:
153     log.info("MANIFEST.in found, presume a repo, cythonizing...")
154     if not cythonize:
155         log.critical(
156             "Cython.Build.cythonize not found. "
157             "Cython is required to build from a repo.")
158         sys.exit(1)
159     ext_modules = cythonize([
160         Extension(
161             'rasterio._base', ['rasterio/_base.pyx'], **ext_options),
162         Extension(
163             'rasterio._io', ['rasterio/_io.pyx'], **ext_options),
164         Extension(
165             'rasterio._copy', ['rasterio/_copy.pyx'], **ext_options),
166         Extension(
167             'rasterio._features', ['rasterio/_features.pyx'], **ext_options),
168         Extension(
169             'rasterio._drivers', ['rasterio/_drivers.pyx'], **ext_options),
170         Extension(
171             'rasterio._warp', ['rasterio/_warp.pyx'], **ext_options),
172         Extension(
173             'rasterio._fill', ['rasterio/_fill.pyx', 'rasterio/rasterfill.cpp'], **ext_options),
174         Extension(
175             'rasterio._err', ['rasterio/_err.pyx'], **ext_options),
176         Extension(
177             'rasterio._example', ['rasterio/_example.pyx'], **ext_options),
178         ], quiet=True, **cythonize_options)
179 
180 # If there's no manifest template, as in an sdist, we just specify .c files.
181 else:
182     ext_modules = [
183         Extension(
184             'rasterio._base', ['rasterio/_base.c'], **ext_options),
185         Extension(
186             'rasterio._io', ['rasterio/_io.c'], **ext_options),
187         Extension(
188             'rasterio._copy', ['rasterio/_copy.c'], **ext_options),
189         Extension(
190             'rasterio._features', ['rasterio/_features.c'], **ext_options),
191         Extension(
192             'rasterio._drivers', ['rasterio/_drivers.c'], **ext_options),
193         Extension(
194             'rasterio._warp', ['rasterio/_warp.cpp'], **ext_options),
195         Extension(
196             'rasterio._fill', ['rasterio/_fill.cpp', 'rasterio/rasterfill.cpp'], **ext_options),
197         Extension(
198             'rasterio._err', ['rasterio/_err.c'], **ext_options),
199         Extension(
200             'rasterio._example', ['rasterio/_example.c'], **ext_options),
201             ]
202 
203 with open('README.rst') as f:
204     readme = f.read()
205 
206 # Runtime requirements.
207 inst_reqs = ['affine', 'cligj', 'numpy', 'snuggs', 'click-plugins']
208 
209 if sys.version_info < (3, 4):
210     inst_reqs.append('enum34')
211 
212 setup_args = dict(
213     name='rasterio',
214     version=version,
215     description="Fast and direct raster I/O for use with Numpy and SciPy",
216     long_description=readme,
217     classifiers=[
218         'Development Status :: 4 - Beta',
219         'Intended Audience :: Developers',
220         'Intended Audience :: Information Technology',
221         'Intended Audience :: Science/Research',
222         'License :: OSI Approved :: BSD License',
223         'Programming Language :: C',
224         'Programming Language :: Python :: 2.6',
225         'Programming Language :: Python :: 2.7',
226         'Programming Language :: Python :: 3.3',
227         'Programming Language :: Python :: 3.4',
228         'Topic :: Multimedia :: Graphics :: Graphics Conversion',
229         'Topic :: Scientific/Engineering :: GIS'],
230     keywords='raster gdal',
231     author='Sean Gillies',
232     author_email='sean@mapbox.com',
233     url='https://github.com/mapbox/rasterio',
234     license='BSD',
235     package_dir={'': '.'},
236     packages=['rasterio', 'rasterio.rio', 'rasterio.tools'],
237     entry_points='''
238         [console_scripts]
239         rio=rasterio.rio.main:main_group
240 
241         [rasterio.rio_commands]
242         bounds=rasterio.rio.bounds:bounds
243         calc=rasterio.rio.calc:calc
244         clip=rasterio.rio.clip:clip
245         convert=rasterio.rio.convert:convert
246         edit-info=rasterio.rio.edit_info:edit
247         env=rasterio.rio.env:env
248         info=rasterio.rio.info:info
249         insp=rasterio.rio.insp:insp
250         mask=rasterio.rio.mask:mask
251         merge=rasterio.rio.merge:merge
252         overview=rasterio.rio.overview:overview
253         rasterize=rasterio.rio.rasterize:rasterize
254         sample=rasterio.rio.sample:sample
255         shapes=rasterio.rio.shapes:shapes
256         stack=rasterio.rio.stack:stack
257         warp=rasterio.rio.warp:warp
258         transform=rasterio.rio.transform:transform
259     ''',
260     include_package_data=True,
261     ext_modules=ext_modules,
262     zip_safe=False,
263     install_requires=inst_reqs,
264     extras_require={
265         'ipython': ['ipython>=2.0'],
266         's3': ['boto3'],
267         'test': ['boto3', 'packaging']})
268 
269 if os.environ.get('PACKAGE_DATA'):
270     setup_args['package_data'] = {'rasterio': ['gdal_data/*', 'proj_data/*']}
271 
272 setup(**setup_args)
273
```
--- 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/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -74,7 +74,8 @@
 library_dirs = []
 libraries = []
 extra_link_args = []
-gdal_output = [None]*3
+gdal2plus = False
+gdal_output = [None]*4
 
 try:
     import numpy
@@ -85,7 +86,7 @@
 
 try:
     gdal_config = os.environ.get('GDAL_CONFIG', 'gdal-config')
-    for i, flag in enumerate(("--cflags", "--libs", "--datadir")):
+    for i, flag in enumerate(("--cflags", "--libs", "--datadir", "--version")):
         gdal_output[i] = check_output([gdal_config, flag]).strip()
 
     for item in gdal_output[0].split():
@@ -99,6 +100,9 @@
         else:
             # e.g. -framework GDAL
             extra_link_args.append(item)
+    # datadir, gdal_output[2] handled below
+    for item in gdal_output[3].split():
+        gdal2plus = not item.startswith("1.")
 
 except Exception as e:
     if os.name == "nt":
@@ -148,6 +152,14 @@
 
 log.debug('ext_options:\n%s', pprint.pformat(ext_options))
 
+if gdal2plus:
+    # GDAL>=2.0 does not require vendorized rasterfill.cpp
+    cython_fill = ['rasterio/_fill.pyx']
+    sdist_fill = ['rasterio/_fill.cpp']
+else:
+    cython_fill = ['rasterio/_fill.pyx', 'rasterio/rasterfill.cpp']
+    sdist_fill = ['rasterio/_fill.cpp', 'rasterio/rasterfill.cpp']
+
 # When building from a repo, Cython is required.
 if os.path.exists("MANIFEST.in") and "clean" not in sys.argv:
     log.info("MANIFEST.in found, presume a repo, cythonizing...")
@@ -170,7 +182,7 @@
         Extension(
             'rasterio._warp', ['rasterio/_warp.pyx'], **ext_options),
         Extension(
-            'rasterio._fill', ['rasterio/_fill.pyx', 'rasterio/rasterfill.cpp'], **ext_options),
+            'rasterio._fill', cython_fill, **ext_options),
         Extension(
             'rasterio._err', ['rasterio/_err.pyx'], **ext_options),
         Extension(
@@ -193,12 +205,11 @@
         Extension(
             'rasterio._warp', ['rasterio/_warp.cpp'], **ext_options),
         Extension(
-            'rasterio._fill', ['rasterio/_fill.cpp', 'rasterio/rasterfill.cpp'], **ext_options),
+            'rasterio._fill', sdist_fill, **ext_options),
         Extension(
             'rasterio._err', ['rasterio/_err.c'], **ext_options),
         Extension(
-            'rasterio._example', ['rasterio/_example.c'], **ext_options),
-            ]
+            'rasterio._example', ['rasterio/_example.c'], **ext_options)]
 
 with open('README.rst') as f:
     readme = f.read()

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -74,7 +74,8 @@\n library_dirs = []\n libraries = []\n extra_link_args = []\n-gdal_output = [None]*3\n+gdal2plus = False\n+gdal_output = [None]*4\n \n try:\n     import numpy\n@@ -85,7 +86,7 @@\n \n try:\n     gdal_config = os.environ.get('GDAL_CONFIG', 'gdal-config')\n-    for i, flag in enumerate((\"--cflags\", \"--libs\", \"--datadir\")):\n+    for i, flag in enumerate((\"--cflags\", \"--libs\", \"--datadir\", \"--version\")):\n         gdal_output[i] = check_output([gdal_config, flag]).strip()\n \n     for item in gdal_output[0].split():\n@@ -99,6 +100,9 @@\n         else:\n             # e.g. -framework GDAL\n             extra_link_args.append(item)\n+    # datadir, gdal_output[2] handled below\n+    for item in gdal_output[3].split():\n+        gdal2plus = not item.startswith(\"1.\")\n \n except Exception as e:\n     if os.name == \"nt\":\n@@ -148,6 +152,14 @@\n \n log.debug('ext_options:\\n%s', pprint.pformat(ext_options))\n \n+if gdal2plus:\n+    # GDAL>=2.0 does not require vendorized rasterfill.cpp\n+    cython_fill = ['rasterio/_fill.pyx']\n+    sdist_fill = ['rasterio/_fill.cpp']\n+else:\n+    cython_fill = ['rasterio/_fill.pyx', 'rasterio/rasterfill.cpp']\n+    sdist_fill = ['rasterio/_fill.cpp', 'rasterio/rasterfill.cpp']\n+\n # When building from a repo, Cython is required.\n if os.path.exists(\"MANIFEST.in\") and \"clean\" not in sys.argv:\n     log.info(\"MANIFEST.in found, presume a repo, cythonizing...\")\n@@ -170,7 +182,7 @@\n         Extension(\n             'rasterio._warp', ['rasterio/_warp.pyx'], **ext_options),\n         Extension(\n-            'rasterio._fill', ['rasterio/_fill.pyx', 'rasterio/rasterfill.cpp'], **ext_options),\n+            'rasterio._fill', cython_fill, **ext_options),\n         Extension(\n             'rasterio._err', ['rasterio/_err.pyx'], **ext_options),\n         Extension(\n@@ -193,12 +205,11 @@\n         Extension(\n             'rasterio._warp', ['rasterio/_warp.cpp'], **ext_options),\n         Extension(\n-            'rasterio._fill', ['rasterio/_fill.cpp', 'rasterio/rasterfill.cpp'], **ext_options),\n+            'rasterio._fill', sdist_fill, **ext_options),\n         Extension(\n             'rasterio._err', ['rasterio/_err.c'], **ext_options),\n         Extension(\n-            'rasterio._example', ['rasterio/_example.c'], **ext_options),\n-            ]\n+            'rasterio._example', ['rasterio/_example.c'], **ext_options)]\n \n with open('README.rst') as f:\n     readme = f.read()\n", "issue": "Skip local rasterfill.cpp for GDAL >= 2.0\nOur local rasterfill.cpp (see #253) is in GDAL 2.+: https://github.com/OSGeo/gdal/pull/47.\n\n", "before_files": [{"content": "#!/usr/bin/env python\n\n# Two environmental variables influence this script.\n#\n# GDAL_CONFIG: the path to a gdal-config program that points to GDAL headers,\n# libraries, and data files.\n#\n# PACKAGE_DATA: if defined, GDAL and PROJ4 data files will be copied into the\n# source or binary distribution. This is essential when creating self-contained\n# binary wheels.\n\nimport logging\nimport os\nimport pprint\nimport shutil\nimport subprocess\nimport sys\n\nfrom setuptools import setup\nfrom setuptools.extension import Extension\n\n\nlogging.basicConfig()\nlog = logging.getLogger()\n\n\ndef check_output(cmd):\n    # since subprocess.check_output doesn't exist in 2.6\n    # we wrap it here.\n    try:\n        out = subprocess.check_output(cmd)\n        return out.decode('utf')\n    except AttributeError:\n        # For some reasone check_output doesn't exist\n        # So fall back on Popen\n        p = subprocess.Popen(cmd, stdout=subprocess.PIPE)\n        out, err = p.communicate()\n        return out\n\n\ndef copy_data_tree(datadir, destdir):\n    try:\n        shutil.rmtree(destdir)\n    except OSError:\n        pass\n    shutil.copytree(datadir, destdir)\n\n\n# python -W all setup.py ...\nif 'all' in sys.warnoptions:\n    log.level = logging.DEBUG\n\n# Parse the version from the rasterio module.\nwith open('rasterio/__init__.py') as f:\n    for line in f:\n        if line.find(\"__version__\") >= 0:\n            version = line.split(\"=\")[1].strip()\n            version = version.strip('\"')\n            version = version.strip(\"'\")\n            continue\n\nwith open('VERSION.txt', 'w') as f:\n    f.write(version)\n\n# Use Cython if available.\ntry:\n    from Cython.Build import cythonize\nexcept ImportError:\n    cythonize = None\n\n# By default we'll try to get options via gdal-config. On systems without,\n# options will need to be set in setup.cfg or on the setup command line.\ninclude_dirs = []\nlibrary_dirs = []\nlibraries = []\nextra_link_args = []\ngdal_output = [None]*3\n\ntry:\n    import numpy\n    include_dirs.append(numpy.get_include())\nexcept ImportError:\n    log.critical(\"Numpy and its headers are required to run setup(). Exiting.\")\n    sys.exit(1)\n\ntry:\n    gdal_config = os.environ.get('GDAL_CONFIG', 'gdal-config')\n    for i, flag in enumerate((\"--cflags\", \"--libs\", \"--datadir\")):\n        gdal_output[i] = check_output([gdal_config, flag]).strip()\n\n    for item in gdal_output[0].split():\n        if item.startswith(\"-I\"):\n            include_dirs.extend(item[2:].split(\":\"))\n    for item in gdal_output[1].split():\n        if item.startswith(\"-L\"):\n            library_dirs.extend(item[2:].split(\":\"))\n        elif item.startswith(\"-l\"):\n            libraries.append(item[2:])\n        else:\n            # e.g. -framework GDAL\n            extra_link_args.append(item)\n\nexcept Exception as e:\n    if os.name == \"nt\":\n        log.info((\"Building on Windows requires extra options to setup.py to locate needed GDAL files.\\n\"\n                 \"More information is available in the README.\"))\n    else:\n        log.warning(\"Failed to get options via gdal-config: %s\", str(e))\n\n\n# Conditionally copy the GDAL data. To be used in conjunction with\n# the bdist_wheel command to make self-contained binary wheels.\nif os.environ.get('PACKAGE_DATA'):\n    destdir = 'rasterio/gdal_data'\n    if gdal_output[2]:\n        log.info(\"Copying gdal data from %s\" % gdal_output[2])\n        copy_data_tree(gdal_output[2], destdir)\n    else:\n        # check to see if GDAL_DATA is defined\n        gdal_data = os.environ.get('GDAL_DATA', None)\n        if gdal_data:\n            log.info(\"Copying gdal_data from %s\" % gdal_data)\n            copy_data_tree(gdal_data, destdir)\n\n    # Conditionally copy PROJ.4 data.\n    projdatadir = os.environ.get('PROJ_LIB', '/usr/local/share/proj')\n    if os.path.exists(projdatadir):\n        log.info(\"Copying proj_data from %s\" % projdatadir)\n        copy_data_tree(projdatadir, 'rasterio/proj_data')\n\next_options = dict(\n    include_dirs=include_dirs,\n    library_dirs=library_dirs,\n    libraries=libraries,\n    extra_link_args=extra_link_args)\n\nif not os.name == \"nt\":\n    # These options fail on Windows if using Visual Studio\n    ext_options['extra_compile_args'] = ['-Wno-unused-parameter',\n                                         '-Wno-unused-function']\n\ncythonize_options = {}\nif os.environ.get('CYTHON_COVERAGE'):\n    cythonize_options['compiler_directives'] = {'linetrace': True}\n    cythonize_options['annotate'] = True\n    ext_options['define_macros'] = [('CYTHON_TRACE', '1'),\n                                    ('CYTHON_TRACE_NOGIL', '1')]\n\nlog.debug('ext_options:\\n%s', pprint.pformat(ext_options))\n\n# When building from a repo, Cython is required.\nif os.path.exists(\"MANIFEST.in\") and \"clean\" not in sys.argv:\n    log.info(\"MANIFEST.in found, presume a repo, cythonizing...\")\n    if not cythonize:\n        log.critical(\n            \"Cython.Build.cythonize not found. \"\n            \"Cython is required to build from a repo.\")\n        sys.exit(1)\n    ext_modules = cythonize([\n        Extension(\n            'rasterio._base', ['rasterio/_base.pyx'], **ext_options),\n        Extension(\n            'rasterio._io', ['rasterio/_io.pyx'], **ext_options),\n        Extension(\n            'rasterio._copy', ['rasterio/_copy.pyx'], **ext_options),\n        Extension(\n            'rasterio._features', ['rasterio/_features.pyx'], **ext_options),\n        Extension(\n            'rasterio._drivers', ['rasterio/_drivers.pyx'], **ext_options),\n        Extension(\n            'rasterio._warp', ['rasterio/_warp.pyx'], **ext_options),\n        Extension(\n            'rasterio._fill', ['rasterio/_fill.pyx', 'rasterio/rasterfill.cpp'], **ext_options),\n        Extension(\n            'rasterio._err', ['rasterio/_err.pyx'], **ext_options),\n        Extension(\n            'rasterio._example', ['rasterio/_example.pyx'], **ext_options),\n        ], quiet=True, **cythonize_options)\n\n# If there's no manifest template, as in an sdist, we just specify .c files.\nelse:\n    ext_modules = [\n        Extension(\n            'rasterio._base', ['rasterio/_base.c'], **ext_options),\n        Extension(\n            'rasterio._io', ['rasterio/_io.c'], **ext_options),\n        Extension(\n            'rasterio._copy', ['rasterio/_copy.c'], **ext_options),\n        Extension(\n            'rasterio._features', ['rasterio/_features.c'], **ext_options),\n        Extension(\n            'rasterio._drivers', ['rasterio/_drivers.c'], **ext_options),\n        Extension(\n            'rasterio._warp', ['rasterio/_warp.cpp'], **ext_options),\n        Extension(\n            'rasterio._fill', ['rasterio/_fill.cpp', 'rasterio/rasterfill.cpp'], **ext_options),\n        Extension(\n            'rasterio._err', ['rasterio/_err.c'], **ext_options),\n        Extension(\n            'rasterio._example', ['rasterio/_example.c'], **ext_options),\n            ]\n\nwith open('README.rst') as f:\n    readme = f.read()\n\n# Runtime requirements.\ninst_reqs = ['affine', 'cligj', 'numpy', 'snuggs', 'click-plugins']\n\nif sys.version_info < (3, 4):\n    inst_reqs.append('enum34')\n\nsetup_args = dict(\n    name='rasterio',\n    version=version,\n    description=\"Fast and direct raster I/O for use with Numpy and SciPy\",\n    long_description=readme,\n    classifiers=[\n        'Development Status :: 4 - Beta',\n        'Intended Audience :: Developers',\n        'Intended Audience :: Information Technology',\n        'Intended Audience :: Science/Research',\n        'License :: OSI Approved :: BSD License',\n        'Programming Language :: C',\n        'Programming Language :: Python :: 2.6',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3.3',\n        'Programming Language :: Python :: 3.4',\n        'Topic :: Multimedia :: Graphics :: Graphics Conversion',\n        'Topic :: Scientific/Engineering :: GIS'],\n    keywords='raster gdal',\n    author='Sean Gillies',\n    author_email='sean@mapbox.com',\n    url='https://github.com/mapbox/rasterio',\n    license='BSD',\n    package_dir={'': '.'},\n    packages=['rasterio', 'rasterio.rio', 'rasterio.tools'],\n    entry_points='''\n        [console_scripts]\n        rio=rasterio.rio.main:main_group\n\n        [rasterio.rio_commands]\n        bounds=rasterio.rio.bounds:bounds\n        calc=rasterio.rio.calc:calc\n        clip=rasterio.rio.clip:clip\n        convert=rasterio.rio.convert:convert\n        edit-info=rasterio.rio.edit_info:edit\n        env=rasterio.rio.env:env\n        info=rasterio.rio.info:info\n        insp=rasterio.rio.insp:insp\n        mask=rasterio.rio.mask:mask\n        merge=rasterio.rio.merge:merge\n        overview=rasterio.rio.overview:overview\n        rasterize=rasterio.rio.rasterize:rasterize\n        sample=rasterio.rio.sample:sample\n        shapes=rasterio.rio.shapes:shapes\n        stack=rasterio.rio.stack:stack\n        warp=rasterio.rio.warp:warp\n        transform=rasterio.rio.transform:transform\n    ''',\n    include_package_data=True,\n    ext_modules=ext_modules,\n    zip_safe=False,\n    install_requires=inst_reqs,\n    extras_require={\n        'ipython': ['ipython>=2.0'],\n        's3': ['boto3'],\n        'test': ['boto3', 'packaging']})\n\nif os.environ.get('PACKAGE_DATA'):\n    setup_args['package_data'] = {'rasterio': ['gdal_data/*', 'proj_data/*']}\n\nsetup(**setup_args)\n", "path": "setup.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\n# Two environmental variables influence this script.\n#\n# GDAL_CONFIG: the path to a gdal-config program that points to GDAL headers,\n# libraries, and data files.\n#\n# PACKAGE_DATA: if defined, GDAL and PROJ4 data files will be copied into the\n# source or binary distribution. This is essential when creating self-contained\n# binary wheels.\n\nimport logging\nimport os\nimport pprint\nimport shutil\nimport subprocess\nimport sys\n\nfrom setuptools import setup\nfrom setuptools.extension import Extension\n\n\nlogging.basicConfig()\nlog = logging.getLogger()\n\n\ndef check_output(cmd):\n    # since subprocess.check_output doesn't exist in 2.6\n    # we wrap it here.\n    try:\n        out = subprocess.check_output(cmd)\n        return out.decode('utf')\n    except AttributeError:\n        # For some reasone check_output doesn't exist\n        # So fall back on Popen\n        p = subprocess.Popen(cmd, stdout=subprocess.PIPE)\n        out, err = p.communicate()\n        return out\n\n\ndef copy_data_tree(datadir, destdir):\n    try:\n        shutil.rmtree(destdir)\n    except OSError:\n        pass\n    shutil.copytree(datadir, destdir)\n\n\n# python -W all setup.py ...\nif 'all' in sys.warnoptions:\n    log.level = logging.DEBUG\n\n# Parse the version from the rasterio module.\nwith open('rasterio/__init__.py') as f:\n    for line in f:\n        if line.find(\"__version__\") >= 0:\n            version = line.split(\"=\")[1].strip()\n            version = version.strip('\"')\n            version = version.strip(\"'\")\n            continue\n\nwith open('VERSION.txt', 'w') as f:\n    f.write(version)\n\n# Use Cython if available.\ntry:\n    from Cython.Build import cythonize\nexcept ImportError:\n    cythonize = None\n\n# By default we'll try to get options via gdal-config. On systems without,\n# options will need to be set in setup.cfg or on the setup command line.\ninclude_dirs = []\nlibrary_dirs = []\nlibraries = []\nextra_link_args = []\ngdal2plus = False\ngdal_output = [None]*4\n\ntry:\n    import numpy\n    include_dirs.append(numpy.get_include())\nexcept ImportError:\n    log.critical(\"Numpy and its headers are required to run setup(). Exiting.\")\n    sys.exit(1)\n\ntry:\n    gdal_config = os.environ.get('GDAL_CONFIG', 'gdal-config')\n    for i, flag in enumerate((\"--cflags\", \"--libs\", \"--datadir\", \"--version\")):\n        gdal_output[i] = check_output([gdal_config, flag]).strip()\n\n    for item in gdal_output[0].split():\n        if item.startswith(\"-I\"):\n            include_dirs.extend(item[2:].split(\":\"))\n    for item in gdal_output[1].split():\n        if item.startswith(\"-L\"):\n            library_dirs.extend(item[2:].split(\":\"))\n        elif item.startswith(\"-l\"):\n            libraries.append(item[2:])\n        else:\n            # e.g. -framework GDAL\n            extra_link_args.append(item)\n    # datadir, gdal_output[2] handled below\n    for item in gdal_output[3].split():\n        gdal2plus = not item.startswith(\"1.\")\n\nexcept Exception as e:\n    if os.name == \"nt\":\n        log.info((\"Building on Windows requires extra options to setup.py to locate needed GDAL files.\\n\"\n                 \"More information is available in the README.\"))\n    else:\n        log.warning(\"Failed to get options via gdal-config: %s\", str(e))\n\n\n# Conditionally copy the GDAL data. To be used in conjunction with\n# the bdist_wheel command to make self-contained binary wheels.\nif os.environ.get('PACKAGE_DATA'):\n    destdir = 'rasterio/gdal_data'\n    if gdal_output[2]:\n        log.info(\"Copying gdal data from %s\" % gdal_output[2])\n        copy_data_tree(gdal_output[2], destdir)\n    else:\n        # check to see if GDAL_DATA is defined\n        gdal_data = os.environ.get('GDAL_DATA', None)\n        if gdal_data:\n            log.info(\"Copying gdal_data from %s\" % gdal_data)\n            copy_data_tree(gdal_data, destdir)\n\n    # Conditionally copy PROJ.4 data.\n    projdatadir = os.environ.get('PROJ_LIB', '/usr/local/share/proj')\n    if os.path.exists(projdatadir):\n        log.info(\"Copying proj_data from %s\" % projdatadir)\n        copy_data_tree(projdatadir, 'rasterio/proj_data')\n\next_options = dict(\n    include_dirs=include_dirs,\n    library_dirs=library_dirs,\n    libraries=libraries,\n    extra_link_args=extra_link_args)\n\nif not os.name == \"nt\":\n    # These options fail on Windows if using Visual Studio\n    ext_options['extra_compile_args'] = ['-Wno-unused-parameter',\n                                         '-Wno-unused-function']\n\ncythonize_options = {}\nif os.environ.get('CYTHON_COVERAGE'):\n    cythonize_options['compiler_directives'] = {'linetrace': True}\n    cythonize_options['annotate'] = True\n    ext_options['define_macros'] = [('CYTHON_TRACE', '1'),\n                                    ('CYTHON_TRACE_NOGIL', '1')]\n\nlog.debug('ext_options:\\n%s', pprint.pformat(ext_options))\n\nif gdal2plus:\n    # GDAL>=2.0 does not require vendorized rasterfill.cpp\n    cython_fill = ['rasterio/_fill.pyx']\n    sdist_fill = ['rasterio/_fill.cpp']\nelse:\n    cython_fill = ['rasterio/_fill.pyx', 'rasterio/rasterfill.cpp']\n    sdist_fill = ['rasterio/_fill.cpp', 'rasterio/rasterfill.cpp']\n\n# When building from a repo, Cython is required.\nif os.path.exists(\"MANIFEST.in\") and \"clean\" not in sys.argv:\n    log.info(\"MANIFEST.in found, presume a repo, cythonizing...\")\n    if not cythonize:\n        log.critical(\n            \"Cython.Build.cythonize not found. \"\n            \"Cython is required to build from a repo.\")\n        sys.exit(1)\n    ext_modules = cythonize([\n        Extension(\n            'rasterio._base', ['rasterio/_base.pyx'], **ext_options),\n        Extension(\n            'rasterio._io', ['rasterio/_io.pyx'], **ext_options),\n        Extension(\n            'rasterio._copy', ['rasterio/_copy.pyx'], **ext_options),\n        Extension(\n            'rasterio._features', ['rasterio/_features.pyx'], **ext_options),\n        Extension(\n            'rasterio._drivers', ['rasterio/_drivers.pyx'], **ext_options),\n        Extension(\n            'rasterio._warp', ['rasterio/_warp.pyx'], **ext_options),\n        Extension(\n            'rasterio._fill', cython_fill, **ext_options),\n        Extension(\n            'rasterio._err', ['rasterio/_err.pyx'], **ext_options),\n        Extension(\n            'rasterio._example', ['rasterio/_example.pyx'], **ext_options),\n        ], quiet=True, **cythonize_options)\n\n# If there's no manifest template, as in an sdist, we just specify .c files.\nelse:\n    ext_modules = [\n        Extension(\n            'rasterio._base', ['rasterio/_base.c'], **ext_options),\n        Extension(\n            'rasterio._io', ['rasterio/_io.c'], **ext_options),\n        Extension(\n            'rasterio._copy', ['rasterio/_copy.c'], **ext_options),\n        Extension(\n            'rasterio._features', ['rasterio/_features.c'], **ext_options),\n        Extension(\n            'rasterio._drivers', ['rasterio/_drivers.c'], **ext_options),\n        Extension(\n            'rasterio._warp', ['rasterio/_warp.cpp'], **ext_options),\n        Extension(\n            'rasterio._fill', sdist_fill, **ext_options),\n        Extension(\n            'rasterio._err', ['rasterio/_err.c'], **ext_options),\n        Extension(\n            'rasterio._example', ['rasterio/_example.c'], **ext_options)]\n\nwith open('README.rst') as f:\n    readme = f.read()\n\n# Runtime requirements.\ninst_reqs = ['affine', 'cligj', 'numpy', 'snuggs', 'click-plugins']\n\nif sys.version_info < (3, 4):\n    inst_reqs.append('enum34')\n\nsetup_args = dict(\n    name='rasterio',\n    version=version,\n    description=\"Fast and direct raster I/O for use with Numpy and SciPy\",\n    long_description=readme,\n    classifiers=[\n        'Development Status :: 4 - Beta',\n        'Intended Audience :: Developers',\n        'Intended Audience :: Information Technology',\n        'Intended Audience :: Science/Research',\n        'License :: OSI Approved :: BSD License',\n        'Programming Language :: C',\n        'Programming Language :: Python :: 2.6',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3.3',\n        'Programming Language :: Python :: 3.4',\n        'Topic :: Multimedia :: Graphics :: Graphics Conversion',\n        'Topic :: Scientific/Engineering :: GIS'],\n    keywords='raster gdal',\n    author='Sean Gillies',\n    author_email='sean@mapbox.com',\n    url='https://github.com/mapbox/rasterio',\n    license='BSD',\n    package_dir={'': '.'},\n    packages=['rasterio', 'rasterio.rio', 'rasterio.tools'],\n    entry_points='''\n        [console_scripts]\n        rio=rasterio.rio.main:main_group\n\n        [rasterio.rio_commands]\n        bounds=rasterio.rio.bounds:bounds\n        calc=rasterio.rio.calc:calc\n        clip=rasterio.rio.clip:clip\n        convert=rasterio.rio.convert:convert\n        edit-info=rasterio.rio.edit_info:edit\n        env=rasterio.rio.env:env\n        info=rasterio.rio.info:info\n        insp=rasterio.rio.insp:insp\n        mask=rasterio.rio.mask:mask\n        merge=rasterio.rio.merge:merge\n        overview=rasterio.rio.overview:overview\n        rasterize=rasterio.rio.rasterize:rasterize\n        sample=rasterio.rio.sample:sample\n        shapes=rasterio.rio.shapes:shapes\n        stack=rasterio.rio.stack:stack\n        warp=rasterio.rio.warp:warp\n        transform=rasterio.rio.transform:transform\n    ''',\n    include_package_data=True,\n    ext_modules=ext_modules,\n    zip_safe=False,\n    install_requires=inst_reqs,\n    extras_require={\n        'ipython': ['ipython>=2.0'],\n        's3': ['boto3'],\n        'test': ['boto3', 'packaging']})\n\nif os.environ.get('PACKAGE_DATA'):\n    setup_args['package_data'] = {'rasterio': ['gdal_data/*', 'proj_data/*']}\n\nsetup(**setup_args)\n", "path": "setup.py"}]}