We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
DEP: python, numpy, GDAL versions for rasterio 1.4
Related #2064

- Python 3.9+ (https://numpy.org/neps/nep-0029-deprecation_policy.html)
- Numpy 1.21+
- GDAL 3.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 # 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 copy
13 import itertools
14 import logging
15 import os
16 import platform
17 import pprint
18 import shutil
19 from subprocess import check_output
20 import sys
21 
22 from pkg_resources import parse_version
23 from setuptools import setup
24 from setuptools.extension import Extension
25 
26 logging.basicConfig(stream=sys.stderr, level=logging.INFO)
27 log = logging.getLogger()
28 
29 
30 def copy_data_tree(datadir, destdir):
31     try:
32         shutil.rmtree(destdir)
33     except OSError:
34         pass
35     shutil.copytree(datadir, destdir)
36 
37 
38 # python -W all setup.py ...
39 if "all" in sys.warnoptions:
40     log.level = logging.DEBUG
41 
42 # Parse the version from the rasterio module.
43 with open("rasterio/__init__.py") as f:
44     for line in f:
45         if line.find("__version__") >= 0:
46             version = line.split("=")[1].strip()
47             version = version.strip('"')
48             version = version.strip("'")
49             continue
50 
51 with open("VERSION.txt", "w") as f:
52     f.write(version)
53 
54 # Use Cython if available.
55 try:
56     from Cython.Build import cythonize
57 except ImportError:
58     raise SystemExit(
59         "ERROR: Cython.Build.cythonize not found. "
60         "Cython is required to build rasterio.")
61 
62 # By default we'll try to get options via gdal-config. On systems without,
63 # options will need to be set in setup.cfg or on the setup command line.
64 include_dirs = []
65 library_dirs = []
66 libraries = []
67 extra_link_args = []
68 gdal2plus = False
69 gdal_output = [None] * 4
70 gdalversion = None
71 gdal_major_version = 0
72 gdal_minor_version = 0
73 gdal_patch_version = 0
74 
75 try:
76     import numpy as np
77 
78     include_dirs.append(np.get_include())
79 except ImportError:
80     raise SystemExit("ERROR: Numpy and its headers are required to run setup().")
81 
82 if "clean" not in sys.argv:
83     try:
84         gdal_config = os.environ.get('GDAL_CONFIG', 'gdal-config')
85         for i, flag in enumerate(("--cflags", "--libs", "--datadir", "--version")):
86             gdal_output[i] = check_output([gdal_config, flag]).decode("utf-8").strip()
87 
88         for item in gdal_output[0].split():
89             if item.startswith("-I"):
90                 include_dirs.extend(item[2:].split(":"))
91         for item in gdal_output[1].split():
92             if item.startswith("-L"):
93                 library_dirs.extend(item[2:].split(":"))
94             elif item.startswith("-l"):
95                 libraries.append(item[2:])
96             else:
97                 # e.g. -framework GDAL
98                 extra_link_args.append(item)
99         # datadir, gdal_output[2] handled below
100 
101         gdalversion = gdal_output[3]
102         if gdalversion:
103             log.info("GDAL API version obtained from gdal-config: %s",
104                      gdalversion)
105 
106     except Exception as e:
107         if os.name == "nt":
108             log.info("Building on Windows requires extra options to setup.py "
109                      "to locate needed GDAL files. More information is available "
110                      "in the README.")
111         else:
112             log.warning("Failed to get options via gdal-config: %s", str(e))
113 
114     # Get GDAL API version from environment variable.
115     if 'GDAL_VERSION' in os.environ:
116         gdalversion = os.environ['GDAL_VERSION']
117         log.info("GDAL API version obtained from environment: %s", gdalversion)
118 
119     # Get GDAL API version from the command line if specified there.
120     if '--gdalversion' in sys.argv:
121         index = sys.argv.index('--gdalversion')
122         sys.argv.pop(index)
123         gdalversion = sys.argv.pop(index)
124         log.info("GDAL API version obtained from command line option: %s",
125                  gdalversion)
126 
127     if not gdalversion:
128         raise SystemExit("ERROR: A GDAL API version must be specified. Provide a path "
129                  "to gdal-config using a GDAL_CONFIG environment variable "
130                  "or use a GDAL_VERSION environment variable.")
131 
132     gdal_major_version, gdal_minor_version, gdal_patch_version = parse_version(
133         gdalversion
134     ).base_version.split(".", maxsplit=3)
135     gdal_major_version = int(gdal_major_version)
136     gdal_minor_version = int(gdal_minor_version)
137     gdal_patch_version = int(gdal_patch_version)
138 
139     if (gdal_major_version, gdal_minor_version) < (3, 1):
140         raise SystemExit("ERROR: GDAL >= 3.1 is required for rasterio. "
141                  "Please upgrade GDAL.")
142 
143 # Conditionally copy the GDAL data. To be used in conjunction with
144 # the bdist_wheel command to make self-contained binary wheels.
145 if os.environ.get('PACKAGE_DATA'):
146     destdir = 'rasterio/gdal_data'
147     if gdal_output[2]:
148         log.info("Copying gdal data from %s" % gdal_output[2])
149         copy_data_tree(gdal_output[2], destdir)
150     else:
151         # check to see if GDAL_DATA is defined
152         gdal_data = os.environ.get('GDAL_DATA', None)
153         if gdal_data:
154             log.info("Copying gdal_data from %s" % gdal_data)
155             copy_data_tree(gdal_data, destdir)
156 
157     # Conditionally copy PROJ DATA.
158     projdatadir = os.environ.get('PROJ_DATA', os.environ.get('PROJ_LIB', '/usr/local/share/proj'))
159     if os.path.exists(projdatadir):
160         log.info("Copying proj_data from %s" % projdatadir)
161         copy_data_tree(projdatadir, 'rasterio/proj_data')
162 
163 compile_time_env = {
164     "CTE_GDAL_MAJOR_VERSION": gdal_major_version,
165     "CTE_GDAL_MINOR_VERSION": gdal_minor_version,
166     "CTE_GDAL_PATCH_VERSION": gdal_patch_version,
167 }
168 
169 ext_options = {
170     'include_dirs': include_dirs,
171     'library_dirs': library_dirs,
172     'libraries': libraries,
173     'extra_link_args': extra_link_args,
174     'define_macros': [],
175     'cython_compile_time_env': compile_time_env
176 }
177 
178 if not os.name == "nt":
179     # These options fail on Windows if using Visual Studio
180     ext_options['extra_compile_args'] = ['-Wno-unused-parameter',
181                                          '-Wno-unused-function']
182 
183 # Copy extension options for cpp extension modules.
184 cpp_ext_options = copy.deepcopy(ext_options)
185 
186 # Remove -std=c++11 from C extension options.
187 try:
188     ext_options['extra_link_args'].remove('-std=c++11')
189     ext_options['extra_compile_args'].remove('-std=c++11')
190 except Exception:
191     pass
192 
193 # GDAL 2.3 and newer requires C++11
194 if (gdal_major_version, gdal_minor_version) >= (2, 3):
195     cpp11_flag = '-std=c++11'
196 
197     # 'extra_compile_args' may not be defined
198     eca = cpp_ext_options.get('extra_compile_args', [])
199 
200     if platform.system() == 'Darwin':
201 
202         if cpp11_flag not in eca:
203             eca.append(cpp11_flag)
204 
205         eca += [cpp11_flag, '-mmacosx-version-min=10.9', '-stdlib=libc++']
206 
207     # TODO: Windows
208 
209     elif cpp11_flag not in eca:
210         eca.append(cpp11_flag)
211 
212     cpp_ext_options['extra_compile_args'] = eca
213 
214 # Configure optional Cython coverage.
215 cythonize_options = {"language_level": sys.version_info[0]}
216 if os.environ.get('CYTHON_COVERAGE'):
217     cythonize_options['compiler_directives'] = {'linetrace': True}
218     cythonize_options['annotate'] = True
219     ext_options['define_macros'].extend(
220         [('CYTHON_TRACE', '1'), ('CYTHON_TRACE_NOGIL', '1')])
221 
222 log.debug('ext_options:\n%s', pprint.pformat(ext_options))
223 
224 ext_modules = None
225 if "clean" not in sys.argv:
226     extensions = [
227         Extension(
228             'rasterio._base', ['rasterio/_base.pyx'], **ext_options),
229         Extension(
230             'rasterio._io', ['rasterio/_io.pyx'], **ext_options),
231         Extension(
232             'rasterio._features', ['rasterio/_features.pyx'], **ext_options),
233         Extension(
234             'rasterio._env', ['rasterio/_env.pyx'], **ext_options),
235         Extension(
236             'rasterio._warp', ['rasterio/_warp.pyx'], **cpp_ext_options),
237         Extension(
238             'rasterio._fill', ['rasterio/_fill.pyx'], **cpp_ext_options),
239         Extension(
240             'rasterio._err', ['rasterio/_err.pyx'], **ext_options),
241         Extension(
242             'rasterio._example', ['rasterio/_example.pyx'], **ext_options),
243         Extension(
244             'rasterio._version', ['rasterio/_version.pyx'], **ext_options),
245         Extension(
246             'rasterio.crs', ['rasterio/crs.pyx'], **ext_options),
247         Extension(
248             'rasterio.shutil', ['rasterio/shutil.pyx'], **ext_options),
249         Extension(
250             'rasterio._transform', ['rasterio/_transform.pyx'], **ext_options)]
251     if gdal_major_version >= 3:
252         # VSI Plugins are only 3.0+
253         extensions.append(
254             Extension(
255                 'rasterio._filepath', ['rasterio/_filepath.pyx'], **cpp_ext_options))
256     ext_modules = cythonize(
257         extensions, quiet=True, compile_time_env=compile_time_env, **cythonize_options)
258 
259 
260 with open("README.rst", encoding="utf-8") as f:
261     readme = f.read()
262 
263 # Runtime requirements.
264 inst_reqs = [
265     "affine",
266     "attrs",
267     "certifi",
268     "click>=4.0",
269     "cligj>=0.5",
270     "numpy>=1.18",
271     "snuggs>=1.4.1",
272     "click-plugins",
273     "setuptools",
274 ]
275 
276 extra_reqs = {
277     "docs": [
278         "ghp-import",
279         "numpydoc",
280         "sphinx",
281         "sphinx-click",
282         "sphinx-rtd-theme",
283     ],
284     "ipython": ["ipython>=2.0"],
285     "plot": ["matplotlib"],
286     "s3": ["boto3>=1.2.4"],
287     "test": [
288         "boto3>=1.2.4",
289         "hypothesis",
290         "packaging",
291         "pytest-cov>=2.2.0",
292         "pytest>=2.8.2",
293         "shapely",
294     ],
295 }
296 
297 # Add all extra requirements
298 extra_reqs["all"] = list(set(itertools.chain(*extra_reqs.values())))
299 
300 setup_args = dict(
301     name="rasterio",
302     version=version,
303     description="Fast and direct raster I/O for use with Numpy and SciPy",
304     long_description=readme,
305     classifiers=[
306         "Development Status :: 5 - Production/Stable",
307         "Intended Audience :: Developers",
308         "Intended Audience :: Information Technology",
309         "Intended Audience :: Science/Research",
310         "License :: OSI Approved :: BSD License",
311         "Programming Language :: C",
312         "Programming Language :: Cython",
313         "Programming Language :: Python :: 3.8",
314         "Programming Language :: Python :: 3.9",
315         "Programming Language :: Python :: 3.10",
316         "Programming Language :: Python :: 3",
317         "Topic :: Multimedia :: Graphics :: Graphics Conversion",
318         "Topic :: Scientific/Engineering :: GIS",
319     ],
320     keywords="raster gdal",
321     author="Sean Gillies",
322     author_email="sean@mapbox.com",
323     url="https://github.com/rasterio/rasterio",
324     license="BSD",
325     package_dir={"": "."},
326     packages=["rasterio", "rasterio.rio"],
327     include_package_data=True,
328     ext_modules=ext_modules,
329     zip_safe=False,
330     install_requires=inst_reqs,
331     extras_require=extra_reqs,
332     python_requires=">=3.8",
333 )
334 
335 if os.environ.get('PACKAGE_DATA'):
336     setup_args['package_data'] = {'rasterio': ['gdal_data/*', 'proj_data/*']}
337 
338 setup(**setup_args)
339
```
--- 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
@@ -136,8 +136,8 @@
     gdal_minor_version = int(gdal_minor_version)
     gdal_patch_version = int(gdal_patch_version)
 
-    if (gdal_major_version, gdal_minor_version) < (3, 1):
-        raise SystemExit("ERROR: GDAL >= 3.1 is required for rasterio. "
+    if (gdal_major_version, gdal_minor_version) < (3, 3):
+        raise SystemExit("ERROR: GDAL >= 3.3 is required for rasterio. "
                  "Please upgrade GDAL.")
 
 # Conditionally copy the GDAL data. To be used in conjunction with
@@ -267,7 +267,7 @@
     "certifi",
     "click>=4.0",
     "cligj>=0.5",
-    "numpy>=1.18",
+    "numpy>=1.21",
     "snuggs>=1.4.1",
     "click-plugins",
     "setuptools",
@@ -310,7 +310,6 @@
         "License :: OSI Approved :: BSD License",
         "Programming Language :: C",
         "Programming Language :: Cython",
-        "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
         "Programming Language :: Python :: 3",
@@ -329,7 +328,7 @@
     zip_safe=False,
     install_requires=inst_reqs,
     extras_require=extra_reqs,
-    python_requires=">=3.8",
+    python_requires=">=3.9",
 )
 
 if os.environ.get('PACKAGE_DATA'):

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -136,8 +136,8 @@\n     gdal_minor_version = int(gdal_minor_version)\n     gdal_patch_version = int(gdal_patch_version)\n \n-    if (gdal_major_version, gdal_minor_version) < (3, 1):\n-        raise SystemExit(\"ERROR: GDAL >= 3.1 is required for rasterio. \"\n+    if (gdal_major_version, gdal_minor_version) < (3, 3):\n+        raise SystemExit(\"ERROR: GDAL >= 3.3 is required for rasterio. \"\n                  \"Please upgrade GDAL.\")\n \n # Conditionally copy the GDAL data. To be used in conjunction with\n@@ -267,7 +267,7 @@\n     \"certifi\",\n     \"click>=4.0\",\n     \"cligj>=0.5\",\n-    \"numpy>=1.18\",\n+    \"numpy>=1.21\",\n     \"snuggs>=1.4.1\",\n     \"click-plugins\",\n     \"setuptools\",\n@@ -310,7 +310,6 @@\n         \"License :: OSI Approved :: BSD License\",\n         \"Programming Language :: C\",\n         \"Programming Language :: Cython\",\n-        \"Programming Language :: Python :: 3.8\",\n         \"Programming Language :: Python :: 3.9\",\n         \"Programming Language :: Python :: 3.10\",\n         \"Programming Language :: Python :: 3\",\n@@ -329,7 +328,7 @@\n     zip_safe=False,\n     install_requires=inst_reqs,\n     extras_require=extra_reqs,\n-    python_requires=\">=3.8\",\n+    python_requires=\">=3.9\",\n )\n \n if os.environ.get('PACKAGE_DATA'):\n", "issue": "DEP: python, numpy, GDAL versions for rasterio 1.4\nRelated #2064\r\n\r\n- Python 3.9+ (https://numpy.org/neps/nep-0029-deprecation_policy.html)\r\n- Numpy 1.21+\r\n- GDAL 3.3+\r\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 copy\nimport itertools\nimport logging\nimport os\nimport platform\nimport pprint\nimport shutil\nfrom subprocess import check_output\nimport sys\n\nfrom pkg_resources import parse_version\nfrom setuptools import setup\nfrom setuptools.extension import Extension\n\nlogging.basicConfig(stream=sys.stderr, level=logging.INFO)\nlog = logging.getLogger()\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    raise SystemExit(\n        \"ERROR: Cython.Build.cythonize not found. \"\n        \"Cython is required to build rasterio.\")\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\ngdalversion = None\ngdal_major_version = 0\ngdal_minor_version = 0\ngdal_patch_version = 0\n\ntry:\n    import numpy as np\n\n    include_dirs.append(np.get_include())\nexcept ImportError:\n    raise SystemExit(\"ERROR: Numpy and its headers are required to run setup().\")\n\nif \"clean\" not in sys.argv:\n    try:\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]).decode(\"utf-8\").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\n        gdalversion = gdal_output[3]\n        if gdalversion:\n            log.info(\"GDAL API version obtained from gdal-config: %s\",\n                     gdalversion)\n\n    except Exception as e:\n        if os.name == \"nt\":\n            log.info(\"Building on Windows requires extra options to setup.py \"\n                     \"to locate needed GDAL files. More information is available \"\n                     \"in the README.\")\n        else:\n            log.warning(\"Failed to get options via gdal-config: %s\", str(e))\n\n    # Get GDAL API version from environment variable.\n    if 'GDAL_VERSION' in os.environ:\n        gdalversion = os.environ['GDAL_VERSION']\n        log.info(\"GDAL API version obtained from environment: %s\", gdalversion)\n\n    # Get GDAL API version from the command line if specified there.\n    if '--gdalversion' in sys.argv:\n        index = sys.argv.index('--gdalversion')\n        sys.argv.pop(index)\n        gdalversion = sys.argv.pop(index)\n        log.info(\"GDAL API version obtained from command line option: %s\",\n                 gdalversion)\n\n    if not gdalversion:\n        raise SystemExit(\"ERROR: A GDAL API version must be specified. Provide a path \"\n                 \"to gdal-config using a GDAL_CONFIG environment variable \"\n                 \"or use a GDAL_VERSION environment variable.\")\n\n    gdal_major_version, gdal_minor_version, gdal_patch_version = parse_version(\n        gdalversion\n    ).base_version.split(\".\", maxsplit=3)\n    gdal_major_version = int(gdal_major_version)\n    gdal_minor_version = int(gdal_minor_version)\n    gdal_patch_version = int(gdal_patch_version)\n\n    if (gdal_major_version, gdal_minor_version) < (3, 1):\n        raise SystemExit(\"ERROR: GDAL >= 3.1 is required for rasterio. \"\n                 \"Please upgrade GDAL.\")\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 DATA.\n    projdatadir = os.environ.get('PROJ_DATA', 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\ncompile_time_env = {\n    \"CTE_GDAL_MAJOR_VERSION\": gdal_major_version,\n    \"CTE_GDAL_MINOR_VERSION\": gdal_minor_version,\n    \"CTE_GDAL_PATCH_VERSION\": gdal_patch_version,\n}\n\next_options = {\n    'include_dirs': include_dirs,\n    'library_dirs': library_dirs,\n    'libraries': libraries,\n    'extra_link_args': extra_link_args,\n    'define_macros': [],\n    'cython_compile_time_env': compile_time_env\n}\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\n# Copy extension options for cpp extension modules.\ncpp_ext_options = copy.deepcopy(ext_options)\n\n# Remove -std=c++11 from C extension options.\ntry:\n    ext_options['extra_link_args'].remove('-std=c++11')\n    ext_options['extra_compile_args'].remove('-std=c++11')\nexcept Exception:\n    pass\n\n# GDAL 2.3 and newer requires C++11\nif (gdal_major_version, gdal_minor_version) >= (2, 3):\n    cpp11_flag = '-std=c++11'\n\n    # 'extra_compile_args' may not be defined\n    eca = cpp_ext_options.get('extra_compile_args', [])\n\n    if platform.system() == 'Darwin':\n\n        if cpp11_flag not in eca:\n            eca.append(cpp11_flag)\n\n        eca += [cpp11_flag, '-mmacosx-version-min=10.9', '-stdlib=libc++']\n\n    # TODO: Windows\n\n    elif cpp11_flag not in eca:\n        eca.append(cpp11_flag)\n\n    cpp_ext_options['extra_compile_args'] = eca\n\n# Configure optional Cython coverage.\ncythonize_options = {\"language_level\": sys.version_info[0]}\nif os.environ.get('CYTHON_COVERAGE'):\n    cythonize_options['compiler_directives'] = {'linetrace': True}\n    cythonize_options['annotate'] = True\n    ext_options['define_macros'].extend(\n        [('CYTHON_TRACE', '1'), ('CYTHON_TRACE_NOGIL', '1')])\n\nlog.debug('ext_options:\\n%s', pprint.pformat(ext_options))\n\next_modules = None\nif \"clean\" not in sys.argv:\n    extensions = [\n        Extension(\n            'rasterio._base', ['rasterio/_base.pyx'], **ext_options),\n        Extension(\n            'rasterio._io', ['rasterio/_io.pyx'], **ext_options),\n        Extension(\n            'rasterio._features', ['rasterio/_features.pyx'], **ext_options),\n        Extension(\n            'rasterio._env', ['rasterio/_env.pyx'], **ext_options),\n        Extension(\n            'rasterio._warp', ['rasterio/_warp.pyx'], **cpp_ext_options),\n        Extension(\n            'rasterio._fill', ['rasterio/_fill.pyx'], **cpp_ext_options),\n        Extension(\n            'rasterio._err', ['rasterio/_err.pyx'], **ext_options),\n        Extension(\n            'rasterio._example', ['rasterio/_example.pyx'], **ext_options),\n        Extension(\n            'rasterio._version', ['rasterio/_version.pyx'], **ext_options),\n        Extension(\n            'rasterio.crs', ['rasterio/crs.pyx'], **ext_options),\n        Extension(\n            'rasterio.shutil', ['rasterio/shutil.pyx'], **ext_options),\n        Extension(\n            'rasterio._transform', ['rasterio/_transform.pyx'], **ext_options)]\n    if gdal_major_version >= 3:\n        # VSI Plugins are only 3.0+\n        extensions.append(\n            Extension(\n                'rasterio._filepath', ['rasterio/_filepath.pyx'], **cpp_ext_options))\n    ext_modules = cythonize(\n        extensions, quiet=True, compile_time_env=compile_time_env, **cythonize_options)\n\n\nwith open(\"README.rst\", encoding=\"utf-8\") as f:\n    readme = f.read()\n\n# Runtime requirements.\ninst_reqs = [\n    \"affine\",\n    \"attrs\",\n    \"certifi\",\n    \"click>=4.0\",\n    \"cligj>=0.5\",\n    \"numpy>=1.18\",\n    \"snuggs>=1.4.1\",\n    \"click-plugins\",\n    \"setuptools\",\n]\n\nextra_reqs = {\n    \"docs\": [\n        \"ghp-import\",\n        \"numpydoc\",\n        \"sphinx\",\n        \"sphinx-click\",\n        \"sphinx-rtd-theme\",\n    ],\n    \"ipython\": [\"ipython>=2.0\"],\n    \"plot\": [\"matplotlib\"],\n    \"s3\": [\"boto3>=1.2.4\"],\n    \"test\": [\n        \"boto3>=1.2.4\",\n        \"hypothesis\",\n        \"packaging\",\n        \"pytest-cov>=2.2.0\",\n        \"pytest>=2.8.2\",\n        \"shapely\",\n    ],\n}\n\n# Add all extra requirements\nextra_reqs[\"all\"] = list(set(itertools.chain(*extra_reqs.values())))\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 :: 5 - Production/Stable\",\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 :: Cython\",\n        \"Programming Language :: Python :: 3.8\",\n        \"Programming Language :: Python :: 3.9\",\n        \"Programming Language :: Python :: 3.10\",\n        \"Programming Language :: Python :: 3\",\n        \"Topic :: Multimedia :: Graphics :: Graphics Conversion\",\n        \"Topic :: Scientific/Engineering :: GIS\",\n    ],\n    keywords=\"raster gdal\",\n    author=\"Sean Gillies\",\n    author_email=\"sean@mapbox.com\",\n    url=\"https://github.com/rasterio/rasterio\",\n    license=\"BSD\",\n    package_dir={\"\": \".\"},\n    packages=[\"rasterio\", \"rasterio.rio\"],\n    include_package_data=True,\n    ext_modules=ext_modules,\n    zip_safe=False,\n    install_requires=inst_reqs,\n    extras_require=extra_reqs,\n    python_requires=\">=3.8\",\n)\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 copy\nimport itertools\nimport logging\nimport os\nimport platform\nimport pprint\nimport shutil\nfrom subprocess import check_output\nimport sys\n\nfrom pkg_resources import parse_version\nfrom setuptools import setup\nfrom setuptools.extension import Extension\n\nlogging.basicConfig(stream=sys.stderr, level=logging.INFO)\nlog = logging.getLogger()\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    raise SystemExit(\n        \"ERROR: Cython.Build.cythonize not found. \"\n        \"Cython is required to build rasterio.\")\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\ngdalversion = None\ngdal_major_version = 0\ngdal_minor_version = 0\ngdal_patch_version = 0\n\ntry:\n    import numpy as np\n\n    include_dirs.append(np.get_include())\nexcept ImportError:\n    raise SystemExit(\"ERROR: Numpy and its headers are required to run setup().\")\n\nif \"clean\" not in sys.argv:\n    try:\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]).decode(\"utf-8\").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\n        gdalversion = gdal_output[3]\n        if gdalversion:\n            log.info(\"GDAL API version obtained from gdal-config: %s\",\n                     gdalversion)\n\n    except Exception as e:\n        if os.name == \"nt\":\n            log.info(\"Building on Windows requires extra options to setup.py \"\n                     \"to locate needed GDAL files. More information is available \"\n                     \"in the README.\")\n        else:\n            log.warning(\"Failed to get options via gdal-config: %s\", str(e))\n\n    # Get GDAL API version from environment variable.\n    if 'GDAL_VERSION' in os.environ:\n        gdalversion = os.environ['GDAL_VERSION']\n        log.info(\"GDAL API version obtained from environment: %s\", gdalversion)\n\n    # Get GDAL API version from the command line if specified there.\n    if '--gdalversion' in sys.argv:\n        index = sys.argv.index('--gdalversion')\n        sys.argv.pop(index)\n        gdalversion = sys.argv.pop(index)\n        log.info(\"GDAL API version obtained from command line option: %s\",\n                 gdalversion)\n\n    if not gdalversion:\n        raise SystemExit(\"ERROR: A GDAL API version must be specified. Provide a path \"\n                 \"to gdal-config using a GDAL_CONFIG environment variable \"\n                 \"or use a GDAL_VERSION environment variable.\")\n\n    gdal_major_version, gdal_minor_version, gdal_patch_version = parse_version(\n        gdalversion\n    ).base_version.split(\".\", maxsplit=3)\n    gdal_major_version = int(gdal_major_version)\n    gdal_minor_version = int(gdal_minor_version)\n    gdal_patch_version = int(gdal_patch_version)\n\n    if (gdal_major_version, gdal_minor_version) < (3, 3):\n        raise SystemExit(\"ERROR: GDAL >= 3.3 is required for rasterio. \"\n                 \"Please upgrade GDAL.\")\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 DATA.\n    projdatadir = os.environ.get('PROJ_DATA', 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\ncompile_time_env = {\n    \"CTE_GDAL_MAJOR_VERSION\": gdal_major_version,\n    \"CTE_GDAL_MINOR_VERSION\": gdal_minor_version,\n    \"CTE_GDAL_PATCH_VERSION\": gdal_patch_version,\n}\n\next_options = {\n    'include_dirs': include_dirs,\n    'library_dirs': library_dirs,\n    'libraries': libraries,\n    'extra_link_args': extra_link_args,\n    'define_macros': [],\n    'cython_compile_time_env': compile_time_env\n}\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\n# Copy extension options for cpp extension modules.\ncpp_ext_options = copy.deepcopy(ext_options)\n\n# Remove -std=c++11 from C extension options.\ntry:\n    ext_options['extra_link_args'].remove('-std=c++11')\n    ext_options['extra_compile_args'].remove('-std=c++11')\nexcept Exception:\n    pass\n\n# GDAL 2.3 and newer requires C++11\nif (gdal_major_version, gdal_minor_version) >= (2, 3):\n    cpp11_flag = '-std=c++11'\n\n    # 'extra_compile_args' may not be defined\n    eca = cpp_ext_options.get('extra_compile_args', [])\n\n    if platform.system() == 'Darwin':\n\n        if cpp11_flag not in eca:\n            eca.append(cpp11_flag)\n\n        eca += [cpp11_flag, '-mmacosx-version-min=10.9', '-stdlib=libc++']\n\n    # TODO: Windows\n\n    elif cpp11_flag not in eca:\n        eca.append(cpp11_flag)\n\n    cpp_ext_options['extra_compile_args'] = eca\n\n# Configure optional Cython coverage.\ncythonize_options = {\"language_level\": sys.version_info[0]}\nif os.environ.get('CYTHON_COVERAGE'):\n    cythonize_options['compiler_directives'] = {'linetrace': True}\n    cythonize_options['annotate'] = True\n    ext_options['define_macros'].extend(\n        [('CYTHON_TRACE', '1'), ('CYTHON_TRACE_NOGIL', '1')])\n\nlog.debug('ext_options:\\n%s', pprint.pformat(ext_options))\n\next_modules = None\nif \"clean\" not in sys.argv:\n    extensions = [\n        Extension(\n            'rasterio._base', ['rasterio/_base.pyx'], **ext_options),\n        Extension(\n            'rasterio._io', ['rasterio/_io.pyx'], **ext_options),\n        Extension(\n            'rasterio._features', ['rasterio/_features.pyx'], **ext_options),\n        Extension(\n            'rasterio._env', ['rasterio/_env.pyx'], **ext_options),\n        Extension(\n            'rasterio._warp', ['rasterio/_warp.pyx'], **cpp_ext_options),\n        Extension(\n            'rasterio._fill', ['rasterio/_fill.pyx'], **cpp_ext_options),\n        Extension(\n            'rasterio._err', ['rasterio/_err.pyx'], **ext_options),\n        Extension(\n            'rasterio._example', ['rasterio/_example.pyx'], **ext_options),\n        Extension(\n            'rasterio._version', ['rasterio/_version.pyx'], **ext_options),\n        Extension(\n            'rasterio.crs', ['rasterio/crs.pyx'], **ext_options),\n        Extension(\n            'rasterio.shutil', ['rasterio/shutil.pyx'], **ext_options),\n        Extension(\n            'rasterio._transform', ['rasterio/_transform.pyx'], **ext_options)]\n    if gdal_major_version >= 3:\n        # VSI Plugins are only 3.0+\n        extensions.append(\n            Extension(\n                'rasterio._filepath', ['rasterio/_filepath.pyx'], **cpp_ext_options))\n    ext_modules = cythonize(\n        extensions, quiet=True, compile_time_env=compile_time_env, **cythonize_options)\n\n\nwith open(\"README.rst\", encoding=\"utf-8\") as f:\n    readme = f.read()\n\n# Runtime requirements.\ninst_reqs = [\n    \"affine\",\n    \"attrs\",\n    \"certifi\",\n    \"click>=4.0\",\n    \"cligj>=0.5\",\n    \"numpy>=1.21\",\n    \"snuggs>=1.4.1\",\n    \"click-plugins\",\n    \"setuptools\",\n]\n\nextra_reqs = {\n    \"docs\": [\n        \"ghp-import\",\n        \"numpydoc\",\n        \"sphinx\",\n        \"sphinx-click\",\n        \"sphinx-rtd-theme\",\n    ],\n    \"ipython\": [\"ipython>=2.0\"],\n    \"plot\": [\"matplotlib\"],\n    \"s3\": [\"boto3>=1.2.4\"],\n    \"test\": [\n        \"boto3>=1.2.4\",\n        \"hypothesis\",\n        \"packaging\",\n        \"pytest-cov>=2.2.0\",\n        \"pytest>=2.8.2\",\n        \"shapely\",\n    ],\n}\n\n# Add all extra requirements\nextra_reqs[\"all\"] = list(set(itertools.chain(*extra_reqs.values())))\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 :: 5 - Production/Stable\",\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 :: Cython\",\n        \"Programming Language :: Python :: 3.9\",\n        \"Programming Language :: Python :: 3.10\",\n        \"Programming Language :: Python :: 3\",\n        \"Topic :: Multimedia :: Graphics :: Graphics Conversion\",\n        \"Topic :: Scientific/Engineering :: GIS\",\n    ],\n    keywords=\"raster gdal\",\n    author=\"Sean Gillies\",\n    author_email=\"sean@mapbox.com\",\n    url=\"https://github.com/rasterio/rasterio\",\n    license=\"BSD\",\n    package_dir={\"\": \".\"},\n    packages=[\"rasterio\", \"rasterio.rio\"],\n    include_package_data=True,\n    ext_modules=ext_modules,\n    zip_safe=False,\n    install_requires=inst_reqs,\n    extras_require=extra_reqs,\n    python_requires=\">=3.9\",\n)\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"}]}