We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Require setuptools, mkdocs/commands/gh_deploy.py imports pkg_resources


--- 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 from setuptools import setup
4 import re
5 import os
6 import sys
7 
8 
9 with open('README.md') as f:
10     long_description = f.read()
11 
12 
13 def get_version(package):
14     """Return package version as listed in `__version__` in `init.py`."""
15     init_py = open(os.path.join(package, '__init__.py')).read()
16     return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
17 
18 
19 def get_packages(package):
20     """Return root package and all sub-packages."""
21     return [dirpath
22             for dirpath, dirnames, filenames in os.walk(package)
23             if os.path.exists(os.path.join(dirpath, '__init__.py'))]
24 
25 
26 if sys.argv[-1] == 'publish':
27     if os.system("pip freeze | grep wheel"):
28         print("wheel not installed.\nUse `pip install wheel`.\nExiting.")
29         sys.exit()
30     if os.system("pip freeze | grep twine"):
31         print("twine not installed.\nUse `pip install twine`.\nExiting.")
32         sys.exit()
33     os.system("python setup.py sdist bdist_wheel")
34     os.system("twine upload dist/*")
35     print("You probably want to also tag the version now:")
36     print("  git tag -a {0} -m 'version {0}'".format(get_version("mkdocs")))
37     print("  git push --tags")
38     sys.exit()
39 
40 
41 setup(
42     name="mkdocs",
43     version=get_version("mkdocs"),
44     url='https://www.mkdocs.org',
45     license='BSD',
46     description='Project documentation with Markdown.',
47     long_description=long_description,
48     long_description_content_type='text/markdown',
49     author='Tom Christie',
50     author_email='tom@tomchristie.com',  # SEE NOTE BELOW (*)
51     packages=get_packages("mkdocs"),
52     include_package_data=True,
53     install_requires=[
54         'click>=3.3',
55         'Jinja2>=2.10.1',
56         'livereload>=2.5.1',
57         'lunr[languages]==0.5.8',  # must support lunr.js version included in search
58         'Markdown>=3.2.1',
59         'PyYAML>=3.10',
60         'tornado>=5.0',
61         'ghp-import>=1.0',
62         'pyyaml_env_tag>=0.1',
63         'importlib_metadata>=3.10'
64     ],
65     python_requires='>=3.6',
66     entry_points={
67         'console_scripts': [
68             'mkdocs = mkdocs.__main__:cli',
69         ],
70         'mkdocs.themes': [
71             'mkdocs = mkdocs.themes.mkdocs',
72             'readthedocs = mkdocs.themes.readthedocs',
73         ],
74         'mkdocs.plugins': [
75             'search = mkdocs.contrib.search:SearchPlugin',
76         ],
77     },
78     classifiers=[
79         'Development Status :: 5 - Production/Stable',
80         'Environment :: Console',
81         'Environment :: Web Environment',
82         'Intended Audience :: Developers',
83         'License :: OSI Approved :: BSD License',
84         'Operating System :: OS Independent',
85         'Programming Language :: Python',
86         'Programming Language :: Python :: 3',
87         'Programming Language :: Python :: 3.6',
88         'Programming Language :: Python :: 3.7',
89         'Programming Language :: Python :: 3.8',
90         'Programming Language :: Python :: 3.9',
91         'Programming Language :: Python :: 3 :: Only',
92         "Programming Language :: Python :: Implementation :: CPython",
93         "Programming Language :: Python :: Implementation :: PyPy",
94         'Topic :: Documentation',
95         'Topic :: Text Processing',
96     ],
97     zip_safe=False,
98 )
99 
100 # (*) Please direct queries to the discussion group:
101 #     https://groups.google.com/forum/#!forum/mkdocs
102
```

Path: `mkdocs/commands/gh_deploy.py`
Content:
```
1 import logging
2 import subprocess
3 import os
4 import re
5 from pkg_resources import parse_version
6 
7 import mkdocs
8 import ghp_import
9 
10 log = logging.getLogger(__name__)
11 
12 default_message = """Deployed {sha} with MkDocs version: {version}"""
13 
14 
15 def _is_cwd_git_repo():
16     try:
17         proc = subprocess.Popen(
18             ['git', 'rev-parse', '--is-inside-work-tree'],
19             stdout=subprocess.PIPE,
20             stderr=subprocess.PIPE
21         )
22     except FileNotFoundError:
23         log.error("Could not find git - is it installed and on your path?")
24         raise SystemExit(1)
25     proc.communicate()
26     return proc.wait() == 0
27 
28 
29 def _get_current_sha(repo_path):
30 
31     proc = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], cwd=repo_path,
32                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
33 
34     stdout, _ = proc.communicate()
35     sha = stdout.decode('utf-8').strip()
36     return sha
37 
38 
39 def _get_remote_url(remote_name):
40 
41     # No CNAME found.  We will use the origin URL to determine the GitHub
42     # pages location.
43     remote = "remote.%s.url" % remote_name
44     proc = subprocess.Popen(["git", "config", "--get", remote],
45                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
46 
47     stdout, _ = proc.communicate()
48     url = stdout.decode('utf-8').strip()
49 
50     host = None
51     path = None
52     if 'github.com/' in url:
53         host, path = url.split('github.com/', 1)
54     elif 'github.com:' in url:
55         host, path = url.split('github.com:', 1)
56 
57     return host, path
58 
59 
60 def _check_version(branch):
61 
62     proc = subprocess.Popen(['git', 'show', '-s', '--format=%s', 'refs/heads/{}'.format(branch)],
63                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
64 
65     stdout, _ = proc.communicate()
66     msg = stdout.decode('utf-8').strip()
67     m = re.search(r'\d+(\.\d+)+((a|b|rc)\d+)?(\.post\d+)?(\.dev\d+)?', msg, re.X | re.I)
68     previousv = parse_version(m.group()) if m else None
69     currentv = parse_version(mkdocs.__version__)
70     if not previousv:
71         log.warning('Version check skipped: No version specified in previous deployment.')
72     elif currentv > previousv:
73         log.info(
74             'Previous deployment was done with MkDocs version {}; '
75             'you are deploying with a newer version ({})'.format(previousv, currentv)
76         )
77     elif currentv < previousv:
78         log.error(
79             'Deployment terminated: Previous deployment was made with MkDocs version {}; '
80             'you are attempting to deploy with an older version ({}). Use --ignore-version '
81             'to deploy anyway.'.format(previousv, currentv)
82         )
83         raise SystemExit(1)
84 
85 
86 def gh_deploy(config, message=None, force=False, ignore_version=False, shell=False):
87 
88     if not _is_cwd_git_repo():
89         log.error('Cannot deploy - this directory does not appear to be a git '
90                   'repository')
91 
92     remote_branch = config['remote_branch']
93     remote_name = config['remote_name']
94 
95     if not ignore_version:
96         _check_version(remote_branch)
97 
98     if message is None:
99         message = default_message
100     sha = _get_current_sha(os.path.dirname(config.config_file_path))
101     message = message.format(version=mkdocs.__version__, sha=sha)
102 
103     log.info("Copying '%s' to '%s' branch and pushing to GitHub.",
104              config['site_dir'], config['remote_branch'])
105 
106     try:
107         ghp_import.ghp_import(
108             config['site_dir'],
109             mesg=message,
110             remote=remote_name,
111             branch=remote_branch,
112             push=force,
113             use_shell=shell,
114             nojekyll=True
115         )
116     except ghp_import.GhpError as e:
117         log.error("Failed to deploy to GitHub with error: \n{}".format(e.message))
118         raise SystemExit(1)
119 
120     cname_file = os.path.join(config['site_dir'], 'CNAME')
121     # Does this repository have a CNAME set for GitHub pages?
122     if os.path.isfile(cname_file):
123         # This GitHub pages repository has a CNAME configured.
124         with(open(cname_file, 'r')) as f:
125             cname_host = f.read().strip()
126         log.info('Based on your CNAME file, your documentation should be '
127                  'available shortly at: http://%s', cname_host)
128         log.info('NOTE: Your DNS records must be configured appropriately for '
129                  'your CNAME URL to work.')
130         return
131 
132     host, path = _get_remote_url(remote_name)
133 
134     if host is None:
135         # This could be a GitHub Enterprise deployment.
136         log.info('Your documentation should be available shortly.')
137     else:
138         username, repo = path.split('/', 1)
139         if repo.endswith('.git'):
140             repo = repo[:-len('.git')]
141         url = 'https://{}.github.io/{}/'.format(username, repo)
142         log.info('Your documentation should shortly be available at: ' + url)
143
```
--- 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/mkdocs/commands/gh_deploy.py b/mkdocs/commands/gh_deploy.py
--- a/mkdocs/commands/gh_deploy.py
+++ b/mkdocs/commands/gh_deploy.py
@@ -2,7 +2,7 @@
 import subprocess
 import os
 import re
-from pkg_resources import parse_version
+from packaging import version
 
 import mkdocs
 import ghp_import
@@ -65,20 +65,20 @@
     stdout, _ = proc.communicate()
     msg = stdout.decode('utf-8').strip()
     m = re.search(r'\d+(\.\d+)+((a|b|rc)\d+)?(\.post\d+)?(\.dev\d+)?', msg, re.X | re.I)
-    previousv = parse_version(m.group()) if m else None
-    currentv = parse_version(mkdocs.__version__)
+    previousv = version.parse(m.group()) if m else None
+    currentv = version.parse(mkdocs.__version__)
     if not previousv:
         log.warning('Version check skipped: No version specified in previous deployment.')
     elif currentv > previousv:
         log.info(
-            'Previous deployment was done with MkDocs version {}; '
-            'you are deploying with a newer version ({})'.format(previousv, currentv)
+            f'Previous deployment was done with MkDocs version {previousv}; '
+            f'you are deploying with a newer version ({currentv})'
         )
     elif currentv < previousv:
         log.error(
-            'Deployment terminated: Previous deployment was made with MkDocs version {}; '
-            'you are attempting to deploy with an older version ({}). Use --ignore-version '
-            'to deploy anyway.'.format(previousv, currentv)
+            f'Deployment terminated: Previous deployment was made with MkDocs version {previousv}; '
+            f'you are attempting to deploy with an older version ({currentv}). Use --ignore-version '
+            'to deploy anyway.'
         )
         raise SystemExit(1)
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -60,7 +60,8 @@
         'tornado>=5.0',
         'ghp-import>=1.0',
         'pyyaml_env_tag>=0.1',
-        'importlib_metadata>=3.10'
+        'importlib_metadata>=3.10',
+        'packaging>=20.5'
     ],
     python_requires='>=3.6',
     entry_points={

{"golden_diff": "diff --git a/mkdocs/commands/gh_deploy.py b/mkdocs/commands/gh_deploy.py\n--- a/mkdocs/commands/gh_deploy.py\n+++ b/mkdocs/commands/gh_deploy.py\n@@ -2,7 +2,7 @@\n import subprocess\n import os\n import re\n-from pkg_resources import parse_version\n+from packaging import version\n \n import mkdocs\n import ghp_import\n@@ -65,20 +65,20 @@\n     stdout, _ = proc.communicate()\n     msg = stdout.decode('utf-8').strip()\n     m = re.search(r'\\d+(\\.\\d+)+((a|b|rc)\\d+)?(\\.post\\d+)?(\\.dev\\d+)?', msg, re.X | re.I)\n-    previousv = parse_version(m.group()) if m else None\n-    currentv = parse_version(mkdocs.__version__)\n+    previousv = version.parse(m.group()) if m else None\n+    currentv = version.parse(mkdocs.__version__)\n     if not previousv:\n         log.warning('Version check skipped: No version specified in previous deployment.')\n     elif currentv > previousv:\n         log.info(\n-            'Previous deployment was done with MkDocs version {}; '\n-            'you are deploying with a newer version ({})'.format(previousv, currentv)\n+            f'Previous deployment was done with MkDocs version {previousv}; '\n+            f'you are deploying with a newer version ({currentv})'\n         )\n     elif currentv < previousv:\n         log.error(\n-            'Deployment terminated: Previous deployment was made with MkDocs version {}; '\n-            'you are attempting to deploy with an older version ({}). Use --ignore-version '\n-            'to deploy anyway.'.format(previousv, currentv)\n+            f'Deployment terminated: Previous deployment was made with MkDocs version {previousv}; '\n+            f'you are attempting to deploy with an older version ({currentv}). Use --ignore-version '\n+            'to deploy anyway.'\n         )\n         raise SystemExit(1)\n \ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -60,7 +60,8 @@\n         'tornado>=5.0',\n         'ghp-import>=1.0',\n         'pyyaml_env_tag>=0.1',\n-        'importlib_metadata>=3.10'\n+        'importlib_metadata>=3.10',\n+        'packaging>=20.5'\n     ],\n     python_requires='>=3.6',\n     entry_points={\n", "issue": "Require setuptools, mkdocs/commands/gh_deploy.py imports pkg_resources\n\n", "before_files": [{"content": "#!/usr/bin/env python\n\nfrom setuptools import setup\nimport re\nimport os\nimport sys\n\n\nwith open('README.md') as f:\n    long_description = f.read()\n\n\ndef get_version(package):\n    \"\"\"Return package version as listed in `__version__` in `init.py`.\"\"\"\n    init_py = open(os.path.join(package, '__init__.py')).read()\n    return re.search(\"__version__ = ['\\\"]([^'\\\"]+)['\\\"]\", init_py).group(1)\n\n\ndef get_packages(package):\n    \"\"\"Return root package and all sub-packages.\"\"\"\n    return [dirpath\n            for dirpath, dirnames, filenames in os.walk(package)\n            if os.path.exists(os.path.join(dirpath, '__init__.py'))]\n\n\nif sys.argv[-1] == 'publish':\n    if os.system(\"pip freeze | grep wheel\"):\n        print(\"wheel not installed.\\nUse `pip install wheel`.\\nExiting.\")\n        sys.exit()\n    if os.system(\"pip freeze | grep twine\"):\n        print(\"twine not installed.\\nUse `pip install twine`.\\nExiting.\")\n        sys.exit()\n    os.system(\"python setup.py sdist bdist_wheel\")\n    os.system(\"twine upload dist/*\")\n    print(\"You probably want to also tag the version now:\")\n    print(\"  git tag -a {0} -m 'version {0}'\".format(get_version(\"mkdocs\")))\n    print(\"  git push --tags\")\n    sys.exit()\n\n\nsetup(\n    name=\"mkdocs\",\n    version=get_version(\"mkdocs\"),\n    url='https://www.mkdocs.org',\n    license='BSD',\n    description='Project documentation with Markdown.',\n    long_description=long_description,\n    long_description_content_type='text/markdown',\n    author='Tom Christie',\n    author_email='tom@tomchristie.com',  # SEE NOTE BELOW (*)\n    packages=get_packages(\"mkdocs\"),\n    include_package_data=True,\n    install_requires=[\n        'click>=3.3',\n        'Jinja2>=2.10.1',\n        'livereload>=2.5.1',\n        'lunr[languages]==0.5.8',  # must support lunr.js version included in search\n        'Markdown>=3.2.1',\n        'PyYAML>=3.10',\n        'tornado>=5.0',\n        'ghp-import>=1.0',\n        'pyyaml_env_tag>=0.1',\n        'importlib_metadata>=3.10'\n    ],\n    python_requires='>=3.6',\n    entry_points={\n        'console_scripts': [\n            'mkdocs = mkdocs.__main__:cli',\n        ],\n        'mkdocs.themes': [\n            'mkdocs = mkdocs.themes.mkdocs',\n            'readthedocs = mkdocs.themes.readthedocs',\n        ],\n        'mkdocs.plugins': [\n            'search = mkdocs.contrib.search:SearchPlugin',\n        ],\n    },\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Environment :: Console',\n        'Environment :: Web Environment',\n        'Intended Audience :: Developers',\n        'License :: OSI Approved :: BSD License',\n        'Operating System :: OS Independent',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: 3.8',\n        'Programming Language :: Python :: 3.9',\n        'Programming Language :: Python :: 3 :: Only',\n        \"Programming Language :: Python :: Implementation :: CPython\",\n        \"Programming Language :: Python :: Implementation :: PyPy\",\n        'Topic :: Documentation',\n        'Topic :: Text Processing',\n    ],\n    zip_safe=False,\n)\n\n# (*) Please direct queries to the discussion group:\n#     https://groups.google.com/forum/#!forum/mkdocs\n", "path": "setup.py"}, {"content": "import logging\nimport subprocess\nimport os\nimport re\nfrom pkg_resources import parse_version\n\nimport mkdocs\nimport ghp_import\n\nlog = logging.getLogger(__name__)\n\ndefault_message = \"\"\"Deployed {sha} with MkDocs version: {version}\"\"\"\n\n\ndef _is_cwd_git_repo():\n    try:\n        proc = subprocess.Popen(\n            ['git', 'rev-parse', '--is-inside-work-tree'],\n            stdout=subprocess.PIPE,\n            stderr=subprocess.PIPE\n        )\n    except FileNotFoundError:\n        log.error(\"Could not find git - is it installed and on your path?\")\n        raise SystemExit(1)\n    proc.communicate()\n    return proc.wait() == 0\n\n\ndef _get_current_sha(repo_path):\n\n    proc = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], cwd=repo_path,\n                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n    stdout, _ = proc.communicate()\n    sha = stdout.decode('utf-8').strip()\n    return sha\n\n\ndef _get_remote_url(remote_name):\n\n    # No CNAME found.  We will use the origin URL to determine the GitHub\n    # pages location.\n    remote = \"remote.%s.url\" % remote_name\n    proc = subprocess.Popen([\"git\", \"config\", \"--get\", remote],\n                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n    stdout, _ = proc.communicate()\n    url = stdout.decode('utf-8').strip()\n\n    host = None\n    path = None\n    if 'github.com/' in url:\n        host, path = url.split('github.com/', 1)\n    elif 'github.com:' in url:\n        host, path = url.split('github.com:', 1)\n\n    return host, path\n\n\ndef _check_version(branch):\n\n    proc = subprocess.Popen(['git', 'show', '-s', '--format=%s', 'refs/heads/{}'.format(branch)],\n                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n    stdout, _ = proc.communicate()\n    msg = stdout.decode('utf-8').strip()\n    m = re.search(r'\\d+(\\.\\d+)+((a|b|rc)\\d+)?(\\.post\\d+)?(\\.dev\\d+)?', msg, re.X | re.I)\n    previousv = parse_version(m.group()) if m else None\n    currentv = parse_version(mkdocs.__version__)\n    if not previousv:\n        log.warning('Version check skipped: No version specified in previous deployment.')\n    elif currentv > previousv:\n        log.info(\n            'Previous deployment was done with MkDocs version {}; '\n            'you are deploying with a newer version ({})'.format(previousv, currentv)\n        )\n    elif currentv < previousv:\n        log.error(\n            'Deployment terminated: Previous deployment was made with MkDocs version {}; '\n            'you are attempting to deploy with an older version ({}). Use --ignore-version '\n            'to deploy anyway.'.format(previousv, currentv)\n        )\n        raise SystemExit(1)\n\n\ndef gh_deploy(config, message=None, force=False, ignore_version=False, shell=False):\n\n    if not _is_cwd_git_repo():\n        log.error('Cannot deploy - this directory does not appear to be a git '\n                  'repository')\n\n    remote_branch = config['remote_branch']\n    remote_name = config['remote_name']\n\n    if not ignore_version:\n        _check_version(remote_branch)\n\n    if message is None:\n        message = default_message\n    sha = _get_current_sha(os.path.dirname(config.config_file_path))\n    message = message.format(version=mkdocs.__version__, sha=sha)\n\n    log.info(\"Copying '%s' to '%s' branch and pushing to GitHub.\",\n             config['site_dir'], config['remote_branch'])\n\n    try:\n        ghp_import.ghp_import(\n            config['site_dir'],\n            mesg=message,\n            remote=remote_name,\n            branch=remote_branch,\n            push=force,\n            use_shell=shell,\n            nojekyll=True\n        )\n    except ghp_import.GhpError as e:\n        log.error(\"Failed to deploy to GitHub with error: \\n{}\".format(e.message))\n        raise SystemExit(1)\n\n    cname_file = os.path.join(config['site_dir'], 'CNAME')\n    # Does this repository have a CNAME set for GitHub pages?\n    if os.path.isfile(cname_file):\n        # This GitHub pages repository has a CNAME configured.\n        with(open(cname_file, 'r')) as f:\n            cname_host = f.read().strip()\n        log.info('Based on your CNAME file, your documentation should be '\n                 'available shortly at: http://%s', cname_host)\n        log.info('NOTE: Your DNS records must be configured appropriately for '\n                 'your CNAME URL to work.')\n        return\n\n    host, path = _get_remote_url(remote_name)\n\n    if host is None:\n        # This could be a GitHub Enterprise deployment.\n        log.info('Your documentation should be available shortly.')\n    else:\n        username, repo = path.split('/', 1)\n        if repo.endswith('.git'):\n            repo = repo[:-len('.git')]\n        url = 'https://{}.github.io/{}/'.format(username, repo)\n        log.info('Your documentation should shortly be available at: ' + url)\n", "path": "mkdocs/commands/gh_deploy.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\nfrom setuptools import setup\nimport re\nimport os\nimport sys\n\n\nwith open('README.md') as f:\n    long_description = f.read()\n\n\ndef get_version(package):\n    \"\"\"Return package version as listed in `__version__` in `init.py`.\"\"\"\n    init_py = open(os.path.join(package, '__init__.py')).read()\n    return re.search(\"__version__ = ['\\\"]([^'\\\"]+)['\\\"]\", init_py).group(1)\n\n\ndef get_packages(package):\n    \"\"\"Return root package and all sub-packages.\"\"\"\n    return [dirpath\n            for dirpath, dirnames, filenames in os.walk(package)\n            if os.path.exists(os.path.join(dirpath, '__init__.py'))]\n\n\nif sys.argv[-1] == 'publish':\n    if os.system(\"pip freeze | grep wheel\"):\n        print(\"wheel not installed.\\nUse `pip install wheel`.\\nExiting.\")\n        sys.exit()\n    if os.system(\"pip freeze | grep twine\"):\n        print(\"twine not installed.\\nUse `pip install twine`.\\nExiting.\")\n        sys.exit()\n    os.system(\"python setup.py sdist bdist_wheel\")\n    os.system(\"twine upload dist/*\")\n    print(\"You probably want to also tag the version now:\")\n    print(\"  git tag -a {0} -m 'version {0}'\".format(get_version(\"mkdocs\")))\n    print(\"  git push --tags\")\n    sys.exit()\n\n\nsetup(\n    name=\"mkdocs\",\n    version=get_version(\"mkdocs\"),\n    url='https://www.mkdocs.org',\n    license='BSD',\n    description='Project documentation with Markdown.',\n    long_description=long_description,\n    long_description_content_type='text/markdown',\n    author='Tom Christie',\n    author_email='tom@tomchristie.com',  # SEE NOTE BELOW (*)\n    packages=get_packages(\"mkdocs\"),\n    include_package_data=True,\n    install_requires=[\n        'click>=3.3',\n        'Jinja2>=2.10.1',\n        'livereload>=2.5.1',\n        'lunr[languages]==0.5.8',  # must support lunr.js version included in search\n        'Markdown>=3.2.1',\n        'PyYAML>=3.10',\n        'tornado>=5.0',\n        'ghp-import>=1.0',\n        'pyyaml_env_tag>=0.1',\n        'importlib_metadata>=3.10',\n        'packaging>=20.5'\n    ],\n    python_requires='>=3.6',\n    entry_points={\n        'console_scripts': [\n            'mkdocs = mkdocs.__main__:cli',\n        ],\n        'mkdocs.themes': [\n            'mkdocs = mkdocs.themes.mkdocs',\n            'readthedocs = mkdocs.themes.readthedocs',\n        ],\n        'mkdocs.plugins': [\n            'search = mkdocs.contrib.search:SearchPlugin',\n        ],\n    },\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Environment :: Console',\n        'Environment :: Web Environment',\n        'Intended Audience :: Developers',\n        'License :: OSI Approved :: BSD License',\n        'Operating System :: OS Independent',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: 3.8',\n        'Programming Language :: Python :: 3.9',\n        'Programming Language :: Python :: 3 :: Only',\n        \"Programming Language :: Python :: Implementation :: CPython\",\n        \"Programming Language :: Python :: Implementation :: PyPy\",\n        'Topic :: Documentation',\n        'Topic :: Text Processing',\n    ],\n    zip_safe=False,\n)\n\n# (*) Please direct queries to the discussion group:\n#     https://groups.google.com/forum/#!forum/mkdocs\n", "path": "setup.py"}, {"content": "import logging\nimport subprocess\nimport os\nimport re\nfrom packaging import version\n\nimport mkdocs\nimport ghp_import\n\nlog = logging.getLogger(__name__)\n\ndefault_message = \"\"\"Deployed {sha} with MkDocs version: {version}\"\"\"\n\n\ndef _is_cwd_git_repo():\n    try:\n        proc = subprocess.Popen(\n            ['git', 'rev-parse', '--is-inside-work-tree'],\n            stdout=subprocess.PIPE,\n            stderr=subprocess.PIPE\n        )\n    except FileNotFoundError:\n        log.error(\"Could not find git - is it installed and on your path?\")\n        raise SystemExit(1)\n    proc.communicate()\n    return proc.wait() == 0\n\n\ndef _get_current_sha(repo_path):\n\n    proc = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], cwd=repo_path,\n                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n    stdout, _ = proc.communicate()\n    sha = stdout.decode('utf-8').strip()\n    return sha\n\n\ndef _get_remote_url(remote_name):\n\n    # No CNAME found.  We will use the origin URL to determine the GitHub\n    # pages location.\n    remote = \"remote.%s.url\" % remote_name\n    proc = subprocess.Popen([\"git\", \"config\", \"--get\", remote],\n                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n    stdout, _ = proc.communicate()\n    url = stdout.decode('utf-8').strip()\n\n    host = None\n    path = None\n    if 'github.com/' in url:\n        host, path = url.split('github.com/', 1)\n    elif 'github.com:' in url:\n        host, path = url.split('github.com:', 1)\n\n    return host, path\n\n\ndef _check_version(branch):\n\n    proc = subprocess.Popen(['git', 'show', '-s', '--format=%s', 'refs/heads/{}'.format(branch)],\n                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n    stdout, _ = proc.communicate()\n    msg = stdout.decode('utf-8').strip()\n    m = re.search(r'\\d+(\\.\\d+)+((a|b|rc)\\d+)?(\\.post\\d+)?(\\.dev\\d+)?', msg, re.X | re.I)\n    previousv = version.parse(m.group()) if m else None\n    currentv = version.parse(mkdocs.__version__)\n    if not previousv:\n        log.warning('Version check skipped: No version specified in previous deployment.')\n    elif currentv > previousv:\n        log.info(\n            f'Previous deployment was done with MkDocs version {previousv}; '\n            f'you are deploying with a newer version ({currentv})'\n        )\n    elif currentv < previousv:\n        log.error(\n            f'Deployment terminated: Previous deployment was made with MkDocs version {previousv}; '\n            f'you are attempting to deploy with an older version ({currentv}). Use --ignore-version '\n            'to deploy anyway.'\n        )\n        raise SystemExit(1)\n\n\ndef gh_deploy(config, message=None, force=False, ignore_version=False, shell=False):\n\n    if not _is_cwd_git_repo():\n        log.error('Cannot deploy - this directory does not appear to be a git '\n                  'repository')\n\n    remote_branch = config['remote_branch']\n    remote_name = config['remote_name']\n\n    if not ignore_version:\n        _check_version(remote_branch)\n\n    if message is None:\n        message = default_message\n    sha = _get_current_sha(os.path.dirname(config.config_file_path))\n    message = message.format(version=mkdocs.__version__, sha=sha)\n\n    log.info(\"Copying '%s' to '%s' branch and pushing to GitHub.\",\n             config['site_dir'], config['remote_branch'])\n\n    try:\n        ghp_import.ghp_import(\n            config['site_dir'],\n            mesg=message,\n            remote=remote_name,\n            branch=remote_branch,\n            push=force,\n            use_shell=shell,\n            nojekyll=True\n        )\n    except ghp_import.GhpError as e:\n        log.error(\"Failed to deploy to GitHub with error: \\n{}\".format(e.message))\n        raise SystemExit(1)\n\n    cname_file = os.path.join(config['site_dir'], 'CNAME')\n    # Does this repository have a CNAME set for GitHub pages?\n    if os.path.isfile(cname_file):\n        # This GitHub pages repository has a CNAME configured.\n        with(open(cname_file, 'r')) as f:\n            cname_host = f.read().strip()\n        log.info('Based on your CNAME file, your documentation should be '\n                 'available shortly at: http://%s', cname_host)\n        log.info('NOTE: Your DNS records must be configured appropriately for '\n                 'your CNAME URL to work.')\n        return\n\n    host, path = _get_remote_url(remote_name)\n\n    if host is None:\n        # This could be a GitHub Enterprise deployment.\n        log.info('Your documentation should be available shortly.')\n    else:\n        username, repo = path.split('/', 1)\n        if repo.endswith('.git'):\n            repo = repo[:-len('.git')]\n        url = 'https://{}.github.io/{}/'.format(username, repo)\n        log.info('Your documentation should shortly be available at: ' + url)\n", "path": "mkdocs/commands/gh_deploy.py"}]}