We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Pickle5 may cause setup errors on Python 3.8 (future-proofing)
**Describe the bug**
When  installing GaNDLF on Python 3.8, an error occurs when installing the dependency "pickle5".
Note that pickle5 is redundant in 3.8 -- the backported functionality is the default/standard [[ref](https://github.com/pitrou/pickle5-backport/issues/12)]. 

You can solve this by adding this annotation in setup.py so that pickle5 is only installed on Python versions 3.7 or lower (example of this syntax: https://stackoverflow.com/a/32643122).
If pickle5 is imported directly in your code, you may also need to do a version check at import time, something like this:
``` python
# Both these should come standard if you have setuptools anyway
import platform
from packaging import version
if version.parse(platform.python_version()) < version.parse("3.8.0"):
    import pickle5 as pickle
else:
   import pickle
```

**To Reproduce**
Steps to reproduce the behavior:
1. Create a Python 3.8 environment using your mechanism of choice.
2. Install GaNDLF per instructions.
3. Receive error message while installing pickle5.

**GaNDLF Version**
Latest master (0.0.14.dev0 I think)

**Desktop (please complete the following information):**
Occurs in any system with Python 3.8 or greater. At least for me on Ubuntu-based machines.

**Additional context**
This issue is just a heads up for supporting 3.8 and greater. Hope this helps.


--- 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 """The setup script."""
4 
5 
6 import os
7 from setuptools import setup, find_packages
8 from setuptools.command.install import install
9 from setuptools.command.develop import develop
10 from setuptools.command.egg_info import egg_info
11 
12 with open("README.md") as readme_file:
13     readme = readme_file.read()
14 
15 
16 def git_submodule_update():
17     ## submodule update
18     os.system("git submodule update --init --recursive")
19 
20 
21 class CustomInstallCommand(install):
22     def run(self):
23         install.run(self)
24         git_submodule_update()
25 
26 
27 class CustomDevelopCommand(develop):
28     def run(self):
29         develop.run(self)
30         git_submodule_update()
31 
32 
33 class CustomEggInfoCommand(egg_info):
34     def run(self):
35         egg_info.run(self)
36         git_submodule_update()
37 
38 
39 # read version.py
40 import sys, re
41 
42 try:
43     filepath = "GANDLF/version.py"
44     version_file = open(filepath)
45     (__version__,) = re.findall('__version__ = "(.*)"', version_file.read())
46 
47 except Exception as error:
48     __version__ = "0.0.1"
49     sys.stderr.write("Warning: Could not open '%s' due %s\n" % (filepath, error))
50 
51 requirements = [
52     "black",
53     "numpy==1.21.0",
54     "scipy",
55     "SimpleITK!=2.0.*",
56     "torchvision",
57     "tqdm",
58     "torchio==0.18.57",
59     "pandas",
60     "pylint",
61     "scikit-learn>=0.23.2",
62     "scikit-image>=0.19.1",
63     "pickle5>=0.0.11",
64     "setuptools",
65     "seaborn",
66     "pyyaml",
67     "tiffslide",
68     "matplotlib",
69     "requests>=2.25.0",
70     "pyvips",
71     "pytest",
72     "coverage",
73     "pytest-cov",
74     "psutil",
75     "medcam",
76     "opencv-python",
77     "torchmetrics==0.5.1",  # newer versions have changed api for f1 invocation
78     "OpenPatchMiner==0.1.8",
79     "zarr==2.10.3",
80     "pydicom",
81     "onnx",
82 ]
83 
84 # pytorch doesn't have LTS support on OSX - https://github.com/CBICA/GaNDLF/issues/389
85 if sys.platform == "darwin":
86     requirements.append("torch==1.9.0")
87 else:
88     requirements.append("torch==1.8.2")
89 
90 setup(
91     name="GANDLF",
92     version=__version__,
93     author="Jose Agraz, Vinayak Ahluwalia, Bhakti Baheti, Spyridon Bakas, Ujjwal Baid, Megh Bhalerao, Brandon Edwards, Karol Gotkowski, Caleb Grenko, Orhun Güley, Ibrahim Ethem Hamamci, Sarthak Pati, Micah Sheller, Juliia Skobleva, Siddhesh Thakur, Spiros Thermos",  # alphabetical order
94     author_email="software@cbica.upenn.edu",
95     python_requires=">=3.7",
96     packages=find_packages(),
97     cmdclass={  # this ensures git_submodule_update is called during install
98         "install": CustomInstallCommand,
99         "develop": CustomDevelopCommand,
100         "egg_info": CustomEggInfoCommand,
101     },
102     scripts=[
103         "gandlf_run",
104         "gandlf_constructCSV",
105         "gandlf_collectStats",
106         "gandlf_patchMiner",
107         "gandlf_preprocess",
108         "gandlf_anonymizer",
109         "gandlf_verifyInstall",
110     ],
111     classifiers=[
112         "Development Status :: 3 - Alpha",
113         "Intended Audience :: Science/Research",
114         "License :: OSI Approved :: BSD License",
115         "Natural Language :: English",
116         "Operating System :: OS Independent",
117         "Programming Language :: Python :: 3.7",
118         "Programming Language :: Python :: 3.8",
119         "Programming Language :: Python :: 3.9",
120         "Topic :: Scientific/Engineering :: Medical Science Apps",
121     ],
122     description=(
123         "PyTorch-based framework that handles segmentation/regression/classification using various DL architectures for medical imaging."
124     ),
125     install_requires=requirements,
126     license="BSD-3-Clause License",
127     long_description=readme,
128     long_description_content_type="text/markdown",
129     include_package_data=True,
130     keywords="semantic, segmentation, regression, classification, data-augmentation, medical-imaging",
131     zip_safe=False,
132 )
133 
134 ## windows vips installation
135 if os.name == "nt":  # proceed for windows
136     from pathlib import Path
137 
138     # download and extract if main dll is absent
139     if not Path("./vips/vips-dev-8.10/bin/libvips-42.dll").exists():
140         print("Downloading and extracting VIPS for Windows")
141         url = "https://github.com/libvips/libvips/releases/download/v8.10.2/vips-dev-w64-all-8.10.2.zip"
142         zip_to_extract = "./vips.zip"
143         import urllib.request, zipfile
144 
145         urllib.request.urlretrieve(url, zip_to_extract)
146         z = zipfile.ZipFile(zip_to_extract)
147         z.extractall("./vips")
148         z.close()
149         os.remove(zip_to_extract)
150
```
--- 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
@@ -60,7 +60,7 @@
     "pylint",
     "scikit-learn>=0.23.2",
     "scikit-image>=0.19.1",
-    "pickle5>=0.0.11",
+    'pickle5>=0.0.11; python_version < "3.8.0"',
     "setuptools",
     "seaborn",
     "pyyaml",

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -60,7 +60,7 @@\n     \"pylint\",\n     \"scikit-learn>=0.23.2\",\n     \"scikit-image>=0.19.1\",\n-    \"pickle5>=0.0.11\",\n+    'pickle5>=0.0.11; python_version < \"3.8.0\"',\n     \"setuptools\",\n     \"seaborn\",\n     \"pyyaml\",\n", "issue": "Pickle5 may cause setup errors on Python 3.8 (future-proofing)\n**Describe the bug**\r\nWhen  installing GaNDLF on Python 3.8, an error occurs when installing the dependency \"pickle5\".\r\nNote that pickle5 is redundant in 3.8 -- the backported functionality is the default/standard [[ref](https://github.com/pitrou/pickle5-backport/issues/12)]. \r\n\r\nYou can solve this by adding this annotation in setup.py so that pickle5 is only installed on Python versions 3.7 or lower (example of this syntax: https://stackoverflow.com/a/32643122).\r\nIf pickle5 is imported directly in your code, you may also need to do a version check at import time, something like this:\r\n``` python\r\n# Both these should come standard if you have setuptools anyway\r\nimport platform\r\nfrom packaging import version\r\nif version.parse(platform.python_version()) < version.parse(\"3.8.0\"):\r\n    import pickle5 as pickle\r\nelse:\r\n   import pickle\r\n```\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Create a Python 3.8 environment using your mechanism of choice.\r\n2. Install GaNDLF per instructions.\r\n3. Receive error message while installing pickle5.\r\n\r\n**GaNDLF Version**\r\nLatest master (0.0.14.dev0 I think)\r\n\r\n**Desktop (please complete the following information):**\r\nOccurs in any system with Python 3.8 or greater. At least for me on Ubuntu-based machines.\r\n\r\n**Additional context**\r\nThis issue is just a heads up for supporting 3.8 and greater. Hope this helps.\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n\n\"\"\"The setup script.\"\"\"\n\n\nimport os\nfrom setuptools import setup, find_packages\nfrom setuptools.command.install import install\nfrom setuptools.command.develop import develop\nfrom setuptools.command.egg_info import egg_info\n\nwith open(\"README.md\") as readme_file:\n    readme = readme_file.read()\n\n\ndef git_submodule_update():\n    ## submodule update\n    os.system(\"git submodule update --init --recursive\")\n\n\nclass CustomInstallCommand(install):\n    def run(self):\n        install.run(self)\n        git_submodule_update()\n\n\nclass CustomDevelopCommand(develop):\n    def run(self):\n        develop.run(self)\n        git_submodule_update()\n\n\nclass CustomEggInfoCommand(egg_info):\n    def run(self):\n        egg_info.run(self)\n        git_submodule_update()\n\n\n# read version.py\nimport sys, re\n\ntry:\n    filepath = \"GANDLF/version.py\"\n    version_file = open(filepath)\n    (__version__,) = re.findall('__version__ = \"(.*)\"', version_file.read())\n\nexcept Exception as error:\n    __version__ = \"0.0.1\"\n    sys.stderr.write(\"Warning: Could not open '%s' due %s\\n\" % (filepath, error))\n\nrequirements = [\n    \"black\",\n    \"numpy==1.21.0\",\n    \"scipy\",\n    \"SimpleITK!=2.0.*\",\n    \"torchvision\",\n    \"tqdm\",\n    \"torchio==0.18.57\",\n    \"pandas\",\n    \"pylint\",\n    \"scikit-learn>=0.23.2\",\n    \"scikit-image>=0.19.1\",\n    \"pickle5>=0.0.11\",\n    \"setuptools\",\n    \"seaborn\",\n    \"pyyaml\",\n    \"tiffslide\",\n    \"matplotlib\",\n    \"requests>=2.25.0\",\n    \"pyvips\",\n    \"pytest\",\n    \"coverage\",\n    \"pytest-cov\",\n    \"psutil\",\n    \"medcam\",\n    \"opencv-python\",\n    \"torchmetrics==0.5.1\",  # newer versions have changed api for f1 invocation\n    \"OpenPatchMiner==0.1.8\",\n    \"zarr==2.10.3\",\n    \"pydicom\",\n    \"onnx\",\n]\n\n# pytorch doesn't have LTS support on OSX - https://github.com/CBICA/GaNDLF/issues/389\nif sys.platform == \"darwin\":\n    requirements.append(\"torch==1.9.0\")\nelse:\n    requirements.append(\"torch==1.8.2\")\n\nsetup(\n    name=\"GANDLF\",\n    version=__version__,\n    author=\"Jose Agraz, Vinayak Ahluwalia, Bhakti Baheti, Spyridon Bakas, Ujjwal Baid, Megh Bhalerao, Brandon Edwards, Karol Gotkowski, Caleb Grenko, Orhun G\u00fcley, Ibrahim Ethem Hamamci, Sarthak Pati, Micah Sheller, Juliia Skobleva, Siddhesh Thakur, Spiros Thermos\",  # alphabetical order\n    author_email=\"software@cbica.upenn.edu\",\n    python_requires=\">=3.7\",\n    packages=find_packages(),\n    cmdclass={  # this ensures git_submodule_update is called during install\n        \"install\": CustomInstallCommand,\n        \"develop\": CustomDevelopCommand,\n        \"egg_info\": CustomEggInfoCommand,\n    },\n    scripts=[\n        \"gandlf_run\",\n        \"gandlf_constructCSV\",\n        \"gandlf_collectStats\",\n        \"gandlf_patchMiner\",\n        \"gandlf_preprocess\",\n        \"gandlf_anonymizer\",\n        \"gandlf_verifyInstall\",\n    ],\n    classifiers=[\n        \"Development Status :: 3 - Alpha\",\n        \"Intended Audience :: Science/Research\",\n        \"License :: OSI Approved :: BSD License\",\n        \"Natural Language :: English\",\n        \"Operating System :: OS Independent\",\n        \"Programming Language :: Python :: 3.7\",\n        \"Programming Language :: Python :: 3.8\",\n        \"Programming Language :: Python :: 3.9\",\n        \"Topic :: Scientific/Engineering :: Medical Science Apps\",\n    ],\n    description=(\n        \"PyTorch-based framework that handles segmentation/regression/classification using various DL architectures for medical imaging.\"\n    ),\n    install_requires=requirements,\n    license=\"BSD-3-Clause License\",\n    long_description=readme,\n    long_description_content_type=\"text/markdown\",\n    include_package_data=True,\n    keywords=\"semantic, segmentation, regression, classification, data-augmentation, medical-imaging\",\n    zip_safe=False,\n)\n\n## windows vips installation\nif os.name == \"nt\":  # proceed for windows\n    from pathlib import Path\n\n    # download and extract if main dll is absent\n    if not Path(\"./vips/vips-dev-8.10/bin/libvips-42.dll\").exists():\n        print(\"Downloading and extracting VIPS for Windows\")\n        url = \"https://github.com/libvips/libvips/releases/download/v8.10.2/vips-dev-w64-all-8.10.2.zip\"\n        zip_to_extract = \"./vips.zip\"\n        import urllib.request, zipfile\n\n        urllib.request.urlretrieve(url, zip_to_extract)\n        z = zipfile.ZipFile(zip_to_extract)\n        z.extractall(\"./vips\")\n        z.close()\n        os.remove(zip_to_extract)\n", "path": "setup.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\n\"\"\"The setup script.\"\"\"\n\n\nimport os\nfrom setuptools import setup, find_packages\nfrom setuptools.command.install import install\nfrom setuptools.command.develop import develop\nfrom setuptools.command.egg_info import egg_info\n\nwith open(\"README.md\") as readme_file:\n    readme = readme_file.read()\n\n\ndef git_submodule_update():\n    ## submodule update\n    os.system(\"git submodule update --init --recursive\")\n\n\nclass CustomInstallCommand(install):\n    def run(self):\n        install.run(self)\n        git_submodule_update()\n\n\nclass CustomDevelopCommand(develop):\n    def run(self):\n        develop.run(self)\n        git_submodule_update()\n\n\nclass CustomEggInfoCommand(egg_info):\n    def run(self):\n        egg_info.run(self)\n        git_submodule_update()\n\n\n# read version.py\nimport sys, re\n\ntry:\n    filepath = \"GANDLF/version.py\"\n    version_file = open(filepath)\n    (__version__,) = re.findall('__version__ = \"(.*)\"', version_file.read())\n\nexcept Exception as error:\n    __version__ = \"0.0.1\"\n    sys.stderr.write(\"Warning: Could not open '%s' due %s\\n\" % (filepath, error))\n\nrequirements = [\n    \"black\",\n    \"numpy==1.21.0\",\n    \"scipy\",\n    \"SimpleITK!=2.0.*\",\n    \"torchvision\",\n    \"tqdm\",\n    \"torchio==0.18.57\",\n    \"pandas\",\n    \"pylint\",\n    \"scikit-learn>=0.23.2\",\n    \"scikit-image>=0.19.1\",\n    'pickle5>=0.0.11; python_version < \"3.8.0\"',\n    \"setuptools\",\n    \"seaborn\",\n    \"pyyaml\",\n    \"tiffslide\",\n    \"matplotlib\",\n    \"requests>=2.25.0\",\n    \"pyvips\",\n    \"pytest\",\n    \"coverage\",\n    \"pytest-cov\",\n    \"psutil\",\n    \"medcam\",\n    \"opencv-python\",\n    \"torchmetrics==0.5.1\",  # newer versions have changed api for f1 invocation\n    \"OpenPatchMiner==0.1.8\",\n    \"zarr==2.10.3\",\n    \"pydicom\",\n    \"onnx\",\n]\n\n# pytorch doesn't have LTS support on OSX - https://github.com/CBICA/GaNDLF/issues/389\nif sys.platform == \"darwin\":\n    requirements.append(\"torch==1.9.0\")\nelse:\n    requirements.append(\"torch==1.8.2\")\n\nsetup(\n    name=\"GANDLF\",\n    version=__version__,\n    author=\"Jose Agraz, Vinayak Ahluwalia, Bhakti Baheti, Spyridon Bakas, Ujjwal Baid, Megh Bhalerao, Brandon Edwards, Karol Gotkowski, Caleb Grenko, Orhun G\u00fcley, Ibrahim Ethem Hamamci, Sarthak Pati, Micah Sheller, Juliia Skobleva, Siddhesh Thakur, Spiros Thermos\",  # alphabetical order\n    author_email=\"software@cbica.upenn.edu\",\n    python_requires=\">=3.7\",\n    packages=find_packages(),\n    cmdclass={  # this ensures git_submodule_update is called during install\n        \"install\": CustomInstallCommand,\n        \"develop\": CustomDevelopCommand,\n        \"egg_info\": CustomEggInfoCommand,\n    },\n    scripts=[\n        \"gandlf_run\",\n        \"gandlf_constructCSV\",\n        \"gandlf_collectStats\",\n        \"gandlf_patchMiner\",\n        \"gandlf_preprocess\",\n        \"gandlf_anonymizer\",\n        \"gandlf_verifyInstall\",\n    ],\n    classifiers=[\n        \"Development Status :: 3 - Alpha\",\n        \"Intended Audience :: Science/Research\",\n        \"License :: OSI Approved :: BSD License\",\n        \"Natural Language :: English\",\n        \"Operating System :: OS Independent\",\n        \"Programming Language :: Python :: 3.7\",\n        \"Programming Language :: Python :: 3.8\",\n        \"Programming Language :: Python :: 3.9\",\n        \"Topic :: Scientific/Engineering :: Medical Science Apps\",\n    ],\n    description=(\n        \"PyTorch-based framework that handles segmentation/regression/classification using various DL architectures for medical imaging.\"\n    ),\n    install_requires=requirements,\n    license=\"BSD-3-Clause License\",\n    long_description=readme,\n    long_description_content_type=\"text/markdown\",\n    include_package_data=True,\n    keywords=\"semantic, segmentation, regression, classification, data-augmentation, medical-imaging\",\n    zip_safe=False,\n)\n\n## windows vips installation\nif os.name == \"nt\":  # proceed for windows\n    from pathlib import Path\n\n    # download and extract if main dll is absent\n    if not Path(\"./vips/vips-dev-8.10/bin/libvips-42.dll\").exists():\n        print(\"Downloading and extracting VIPS for Windows\")\n        url = \"https://github.com/libvips/libvips/releases/download/v8.10.2/vips-dev-w64-all-8.10.2.zip\"\n        zip_to_extract = \"./vips.zip\"\n        import urllib.request, zipfile\n\n        urllib.request.urlretrieve(url, zip_to_extract)\n        z = zipfile.ZipFile(zip_to_extract)\n        z.extractall(\"./vips\")\n        z.close()\n        os.remove(zip_to_extract)\n", "path": "setup.py"}]}