We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ver.20.0.0] The gunicorn config files cannot using '__file__' constants.
I configured app_root that base on the relative path in gunicorn files.

`app_root = os.path.abspath(os.path.join(__file__, '..', '..'))`

now I have occurred when upgrade gunicorn version to 20.0.0 and starting with config file.

`$ venv/bin/gunicorn -c /path/to/app/conf/gunicorn.conf.py wsgi:app`

> Failed to read config file: /path/to/app/conf/gunicorn.conf.py
Traceback (most recent call last):
  File "/path/to/app/venv/lib/python3.7/site-packages/gunicorn/app/base.py", line 102, in get_config_from_filename
    loader.exec_module(mod)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/path/to/app/conf/gunicorn.conf.py", line 9, in <module>
    app_root = os.path.abspath(os.path.join(__file__, '..', '..'))

Thanks to help me.

--- 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 # -*- coding: utf-8 -
2 #
3 # This file is part of gunicorn released under the MIT license.
4 # See the NOTICE for more information.
5 
6 import os
7 import sys
8 
9 from setuptools import setup, find_packages
10 from setuptools.command.test import test as TestCommand
11 
12 from gunicorn import __version__
13 
14 
15 CLASSIFIERS = [
16     'Development Status :: 4 - Beta',
17     'Environment :: Other Environment',
18     'Intended Audience :: Developers',
19     'License :: OSI Approved :: MIT License',
20     'Operating System :: MacOS :: MacOS X',
21     'Operating System :: POSIX',
22     'Programming Language :: Python',
23     'Programming Language :: Python :: 3',
24     'Programming Language :: Python :: 3.4',
25     'Programming Language :: Python :: 3.5',
26     'Programming Language :: Python :: 3.6',
27     'Programming Language :: Python :: 3.7',
28     'Programming Language :: Python :: 3.8',
29     'Programming Language :: Python :: 3 :: Only',
30     'Programming Language :: Python :: Implementation :: CPython',
31     'Programming Language :: Python :: Implementation :: PyPy',
32     'Topic :: Internet',
33     'Topic :: Utilities',
34     'Topic :: Software Development :: Libraries :: Python Modules',
35     'Topic :: Internet :: WWW/HTTP',
36     'Topic :: Internet :: WWW/HTTP :: WSGI',
37     'Topic :: Internet :: WWW/HTTP :: WSGI :: Server',
38     'Topic :: Internet :: WWW/HTTP :: Dynamic Content']
39 
40 # read long description
41 with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
42     long_description = f.read()
43 
44 # read dev requirements
45 fname = os.path.join(os.path.dirname(__file__), 'requirements_test.txt')
46 with open(fname) as f:
47     tests_require = [l.strip() for l in f.readlines()]
48 
49 class PyTestCommand(TestCommand):
50     user_options = [
51         ("cov", None, "measure coverage")
52     ]
53 
54     def initialize_options(self):
55         TestCommand.initialize_options(self)
56         self.cov = None
57 
58     def finalize_options(self):
59         TestCommand.finalize_options(self)
60         self.test_args = ['tests']
61         if self.cov:
62             self.test_args += ['--cov', 'gunicorn']
63         self.test_suite = True
64 
65     def run_tests(self):
66         import pytest
67         errno = pytest.main(self.test_args)
68         sys.exit(errno)
69 
70 
71 install_requires = [
72     # We depend on functioning pkg_resources.working_set.add_entry() and
73     # pkg_resources.load_entry_point(). These both work as of 3.0 which
74     # is the first version to support Python 3.4 which we require as a
75     # floor.
76     'setuptools>=3.0',
77 ]
78 
79 extras_require = {
80     'gevent':  ['gevent>=0.13'],
81     'eventlet': ['eventlet>=0.9.7'],
82     'tornado': ['tornado>=0.2'],
83     'gthread': [],
84     'setproctitle': ['setproctitle'],
85 }
86 
87 setup(
88     name='gunicorn',
89     version=__version__,
90 
91     description='WSGI HTTP Server for UNIX',
92     long_description=long_description,
93     author='Benoit Chesneau',
94     author_email='benoitc@e-engura.com',
95     license='MIT',
96     url='http://gunicorn.org',
97 
98     python_requires='>=3.4',
99     install_requires=install_requires,
100     classifiers=CLASSIFIERS,
101     zip_safe=False,
102     packages=find_packages(exclude=['examples', 'tests']),
103     include_package_data=True,
104 
105     tests_require=tests_require,
106     cmdclass={'test': PyTestCommand},
107 
108     entry_points="""
109     [console_scripts]
110     gunicorn=gunicorn.app.wsgiapp:run
111 
112     [paste.server_runner]
113     main=gunicorn.app.pasterapp:serve
114     """,
115     extras_require=extras_require,
116 )
117
```

Path: `gunicorn/app/base.py`
Content:
```
1 # -*- coding: utf-8 -
2 #
3 # This file is part of gunicorn released under the MIT license.
4 # See the NOTICE for more information.
5 import importlib.machinery
6 import os
7 import sys
8 import traceback
9 import types
10 
11 from gunicorn import util
12 from gunicorn.arbiter import Arbiter
13 from gunicorn.config import Config, get_default_config_file
14 from gunicorn import debug
15 
16 
17 class BaseApplication(object):
18     """
19     An application interface for configuring and loading
20     the various necessities for any given web framework.
21     """
22     def __init__(self, usage=None, prog=None):
23         self.usage = usage
24         self.cfg = None
25         self.callable = None
26         self.prog = prog
27         self.logger = None
28         self.do_load_config()
29 
30     def do_load_config(self):
31         """
32         Loads the configuration
33         """
34         try:
35             self.load_default_config()
36             self.load_config()
37         except Exception as e:
38             print("\nError: %s" % str(e), file=sys.stderr)
39             sys.stderr.flush()
40             sys.exit(1)
41 
42     def load_default_config(self):
43         # init configuration
44         self.cfg = Config(self.usage, prog=self.prog)
45 
46     def init(self, parser, opts, args):
47         raise NotImplementedError
48 
49     def load(self):
50         raise NotImplementedError
51 
52     def load_config(self):
53         """
54         This method is used to load the configuration from one or several input(s).
55         Custom Command line, configuration file.
56         You have to override this method in your class.
57         """
58         raise NotImplementedError
59 
60     def reload(self):
61         self.do_load_config()
62         if self.cfg.spew:
63             debug.spew()
64 
65     def wsgi(self):
66         if self.callable is None:
67             self.callable = self.load()
68         return self.callable
69 
70     def run(self):
71         try:
72             Arbiter(self).run()
73         except RuntimeError as e:
74             print("\nError: %s\n" % e, file=sys.stderr)
75             sys.stderr.flush()
76             sys.exit(1)
77 
78 
79 class Application(BaseApplication):
80 
81     # 'init' and 'load' methods are implemented by WSGIApplication.
82     # pylint: disable=abstract-method
83 
84     def chdir(self):
85         # chdir to the configured path before loading,
86         # default is the current dir
87         os.chdir(self.cfg.chdir)
88 
89         # add the path to sys.path
90         if self.cfg.chdir not in sys.path:
91             sys.path.insert(0, self.cfg.chdir)
92 
93     def get_config_from_filename(self, filename):
94 
95         if not os.path.exists(filename):
96             raise RuntimeError("%r doesn't exist" % filename)
97 
98         try:
99             module_name = '__config__'
100             mod = types.ModuleType(module_name)
101             loader = importlib.machinery.SourceFileLoader(module_name, filename)
102             loader.exec_module(mod)
103         except Exception:
104             print("Failed to read config file: %s" % filename, file=sys.stderr)
105             traceback.print_exc()
106             sys.stderr.flush()
107             sys.exit(1)
108 
109         return vars(mod)
110 
111     def get_config_from_module_name(self, module_name):
112         return vars(importlib.import_module(module_name))
113 
114     def load_config_from_module_name_or_filename(self, location):
115         """
116         Loads the configuration file: the file is a python file, otherwise raise an RuntimeError
117         Exception or stop the process if the configuration file contains a syntax error.
118         """
119 
120         if location.startswith("python:"):
121             module_name = location[len("python:"):]
122             cfg = self.get_config_from_module_name(module_name)
123         else:
124             if location.startswith("file:"):
125                 filename = location[len("file:"):]
126             else:
127                 filename = location
128             cfg = self.get_config_from_filename(filename)
129 
130         for k, v in cfg.items():
131             # Ignore unknown names
132             if k not in self.cfg.settings:
133                 continue
134             try:
135                 self.cfg.set(k.lower(), v)
136             except:
137                 print("Invalid value for %s: %s\n" % (k, v), file=sys.stderr)
138                 sys.stderr.flush()
139                 raise
140 
141         return cfg
142 
143     def load_config_from_file(self, filename):
144         return self.load_config_from_module_name_or_filename(location=filename)
145 
146     def load_config(self):
147         # parse console args
148         parser = self.cfg.parser()
149         args = parser.parse_args()
150 
151         # optional settings from apps
152         cfg = self.init(parser, args, args.args)
153 
154         # set up import paths and follow symlinks
155         self.chdir()
156 
157         # Load up the any app specific configuration
158         if cfg:
159             for k, v in cfg.items():
160                 self.cfg.set(k.lower(), v)
161 
162         env_args = parser.parse_args(self.cfg.get_cmd_args_from_env())
163 
164         if args.config:
165             self.load_config_from_file(args.config)
166         elif env_args.config:
167             self.load_config_from_file(env_args.config)
168         else:
169             default_config = get_default_config_file()
170             if default_config is not None:
171                 self.load_config_from_file(default_config)
172 
173         # Load up environment configuration
174         for k, v in vars(env_args).items():
175             if v is None:
176                 continue
177             if k == "args":
178                 continue
179             self.cfg.set(k.lower(), v)
180 
181         # Lastly, update the configuration with any command line settings.
182         for k, v in vars(args).items():
183             if v is None:
184                 continue
185             if k == "args":
186                 continue
187             self.cfg.set(k.lower(), v)
188 
189         # current directory might be changed by the config now
190         # set up import paths and follow symlinks
191         self.chdir()
192 
193     def run(self):
194         if self.cfg.check_config:
195             try:
196                 self.load()
197             except:
198                 msg = "\nError while loading the application:\n"
199                 print(msg, file=sys.stderr)
200                 traceback.print_exc()
201                 sys.stderr.flush()
202                 sys.exit(1)
203             sys.exit(0)
204 
205         if self.cfg.spew:
206             debug.spew()
207 
208         if self.cfg.daemon:
209             util.daemonize(self.cfg.enable_stdio_inheritance)
210 
211         # set python paths
212         if self.cfg.pythonpath:
213             paths = self.cfg.pythonpath.split(",")
214             for path in paths:
215                 pythonpath = os.path.abspath(path)
216                 if pythonpath not in sys.path:
217                     sys.path.insert(0, pythonpath)
218 
219         super().run()
220
```

Path: `gunicorn/__init__.py`
Content:
```
1 # -*- coding: utf-8 -
2 #
3 # This file is part of gunicorn released under the MIT license.
4 # See the NOTICE for more information.
5 
6 version_info = (20, 0, 0)
7 __version__ = ".".join([str(v) for v in version_info])
8 SERVER_SOFTWARE = "gunicorn/%s" % __version__
9
```
--- 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/gunicorn/__init__.py b/gunicorn/__init__.py
--- a/gunicorn/__init__.py
+++ b/gunicorn/__init__.py
@@ -3,6 +3,6 @@
 # This file is part of gunicorn released under the MIT license.
 # See the NOTICE for more information.
 
-version_info = (20, 0, 0)
+version_info = (20, 0, 1)
 __version__ = ".".join([str(v) for v in version_info])
 SERVER_SOFTWARE = "gunicorn/%s" % __version__
diff --git a/gunicorn/app/base.py b/gunicorn/app/base.py
--- a/gunicorn/app/base.py
+++ b/gunicorn/app/base.py
@@ -2,11 +2,10 @@
 #
 # This file is part of gunicorn released under the MIT license.
 # See the NOTICE for more information.
-import importlib.machinery
+import importlib.util
 import os
 import sys
 import traceback
-import types
 
 from gunicorn import util
 from gunicorn.arbiter import Arbiter
@@ -97,9 +96,10 @@
 
         try:
             module_name = '__config__'
-            mod = types.ModuleType(module_name)
-            loader = importlib.machinery.SourceFileLoader(module_name, filename)
-            loader.exec_module(mod)
+            spec = importlib.util.spec_from_file_location(module_name, filename)
+            mod = importlib.util.module_from_spec(spec)
+            sys.modules[module_name] = mod
+            spec.loader.exec_module(mod)
         except Exception:
             print("Failed to read config file: %s" % filename, file=sys.stderr)
             traceback.print_exc()
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,6 @@
     'Operating System :: POSIX',
     'Programming Language :: Python',
     'Programming Language :: Python :: 3',
-    'Programming Language :: Python :: 3.4',
     'Programming Language :: Python :: 3.5',
     'Programming Language :: Python :: 3.6',
     'Programming Language :: Python :: 3.7',

{"golden_diff": "diff --git a/gunicorn/__init__.py b/gunicorn/__init__.py\n--- a/gunicorn/__init__.py\n+++ b/gunicorn/__init__.py\n@@ -3,6 +3,6 @@\n # This file is part of gunicorn released under the MIT license.\n # See the NOTICE for more information.\n \n-version_info = (20, 0, 0)\n+version_info = (20, 0, 1)\n __version__ = \".\".join([str(v) for v in version_info])\n SERVER_SOFTWARE = \"gunicorn/%s\" % __version__\ndiff --git a/gunicorn/app/base.py b/gunicorn/app/base.py\n--- a/gunicorn/app/base.py\n+++ b/gunicorn/app/base.py\n@@ -2,11 +2,10 @@\n #\n # This file is part of gunicorn released under the MIT license.\n # See the NOTICE for more information.\n-import importlib.machinery\n+import importlib.util\n import os\n import sys\n import traceback\n-import types\n \n from gunicorn import util\n from gunicorn.arbiter import Arbiter\n@@ -97,9 +96,10 @@\n \n         try:\n             module_name = '__config__'\n-            mod = types.ModuleType(module_name)\n-            loader = importlib.machinery.SourceFileLoader(module_name, filename)\n-            loader.exec_module(mod)\n+            spec = importlib.util.spec_from_file_location(module_name, filename)\n+            mod = importlib.util.module_from_spec(spec)\n+            sys.modules[module_name] = mod\n+            spec.loader.exec_module(mod)\n         except Exception:\n             print(\"Failed to read config file: %s\" % filename, file=sys.stderr)\n             traceback.print_exc()\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -21,7 +21,6 @@\n     'Operating System :: POSIX',\n     'Programming Language :: Python',\n     'Programming Language :: Python :: 3',\n-    'Programming Language :: Python :: 3.4',\n     'Programming Language :: Python :: 3.5',\n     'Programming Language :: Python :: 3.6',\n     'Programming Language :: Python :: 3.7',\n", "issue": "[ver.20.0.0] The gunicorn config files cannot using '__file__' constants.\nI configured app_root that base on the relative path in gunicorn files.\r\n\r\n`app_root = os.path.abspath(os.path.join(__file__, '..', '..'))`\r\n\r\nnow I have occurred when upgrade gunicorn version to 20.0.0 and starting with config file.\r\n\r\n`$ venv/bin/gunicorn -c /path/to/app/conf/gunicorn.conf.py wsgi:app`\r\n\r\n> Failed to read config file: /path/to/app/conf/gunicorn.conf.py\r\nTraceback (most recent call last):\r\n  File \"/path/to/app/venv/lib/python3.7/site-packages/gunicorn/app/base.py\", line 102, in get_config_from_filename\r\n    loader.exec_module(mod)\r\n  File \"<frozen importlib._bootstrap_external>\", line 728, in exec_module\r\n  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\r\n  File \"/path/to/app/conf/gunicorn.conf.py\", line 9, in <module>\r\n    app_root = os.path.abspath(os.path.join(__file__, '..', '..'))\r\n\r\nThanks to help me.\n", "before_files": [{"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\n\nimport os\nimport sys\n\nfrom setuptools import setup, find_packages\nfrom setuptools.command.test import test as TestCommand\n\nfrom gunicorn import __version__\n\n\nCLASSIFIERS = [\n    'Development Status :: 4 - Beta',\n    'Environment :: Other Environment',\n    'Intended Audience :: Developers',\n    'License :: OSI Approved :: MIT License',\n    'Operating System :: MacOS :: MacOS X',\n    'Operating System :: POSIX',\n    'Programming Language :: Python',\n    'Programming Language :: Python :: 3',\n    'Programming Language :: Python :: 3.4',\n    'Programming Language :: Python :: 3.5',\n    'Programming Language :: Python :: 3.6',\n    'Programming Language :: Python :: 3.7',\n    'Programming Language :: Python :: 3.8',\n    'Programming Language :: Python :: 3 :: Only',\n    'Programming Language :: Python :: Implementation :: CPython',\n    'Programming Language :: Python :: Implementation :: PyPy',\n    'Topic :: Internet',\n    'Topic :: Utilities',\n    'Topic :: Software Development :: Libraries :: Python Modules',\n    'Topic :: Internet :: WWW/HTTP',\n    'Topic :: Internet :: WWW/HTTP :: WSGI',\n    'Topic :: Internet :: WWW/HTTP :: WSGI :: Server',\n    'Topic :: Internet :: WWW/HTTP :: Dynamic Content']\n\n# read long description\nwith open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:\n    long_description = f.read()\n\n# read dev requirements\nfname = os.path.join(os.path.dirname(__file__), 'requirements_test.txt')\nwith open(fname) as f:\n    tests_require = [l.strip() for l in f.readlines()]\n\nclass PyTestCommand(TestCommand):\n    user_options = [\n        (\"cov\", None, \"measure coverage\")\n    ]\n\n    def initialize_options(self):\n        TestCommand.initialize_options(self)\n        self.cov = None\n\n    def finalize_options(self):\n        TestCommand.finalize_options(self)\n        self.test_args = ['tests']\n        if self.cov:\n            self.test_args += ['--cov', 'gunicorn']\n        self.test_suite = True\n\n    def run_tests(self):\n        import pytest\n        errno = pytest.main(self.test_args)\n        sys.exit(errno)\n\n\ninstall_requires = [\n    # We depend on functioning pkg_resources.working_set.add_entry() and\n    # pkg_resources.load_entry_point(). These both work as of 3.0 which\n    # is the first version to support Python 3.4 which we require as a\n    # floor.\n    'setuptools>=3.0',\n]\n\nextras_require = {\n    'gevent':  ['gevent>=0.13'],\n    'eventlet': ['eventlet>=0.9.7'],\n    'tornado': ['tornado>=0.2'],\n    'gthread': [],\n    'setproctitle': ['setproctitle'],\n}\n\nsetup(\n    name='gunicorn',\n    version=__version__,\n\n    description='WSGI HTTP Server for UNIX',\n    long_description=long_description,\n    author='Benoit Chesneau',\n    author_email='benoitc@e-engura.com',\n    license='MIT',\n    url='http://gunicorn.org',\n\n    python_requires='>=3.4',\n    install_requires=install_requires,\n    classifiers=CLASSIFIERS,\n    zip_safe=False,\n    packages=find_packages(exclude=['examples', 'tests']),\n    include_package_data=True,\n\n    tests_require=tests_require,\n    cmdclass={'test': PyTestCommand},\n\n    entry_points=\"\"\"\n    [console_scripts]\n    gunicorn=gunicorn.app.wsgiapp:run\n\n    [paste.server_runner]\n    main=gunicorn.app.pasterapp:serve\n    \"\"\",\n    extras_require=extras_require,\n)\n", "path": "setup.py"}, {"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\nimport importlib.machinery\nimport os\nimport sys\nimport traceback\nimport types\n\nfrom gunicorn import util\nfrom gunicorn.arbiter import Arbiter\nfrom gunicorn.config import Config, get_default_config_file\nfrom gunicorn import debug\n\n\nclass BaseApplication(object):\n    \"\"\"\n    An application interface for configuring and loading\n    the various necessities for any given web framework.\n    \"\"\"\n    def __init__(self, usage=None, prog=None):\n        self.usage = usage\n        self.cfg = None\n        self.callable = None\n        self.prog = prog\n        self.logger = None\n        self.do_load_config()\n\n    def do_load_config(self):\n        \"\"\"\n        Loads the configuration\n        \"\"\"\n        try:\n            self.load_default_config()\n            self.load_config()\n        except Exception as e:\n            print(\"\\nError: %s\" % str(e), file=sys.stderr)\n            sys.stderr.flush()\n            sys.exit(1)\n\n    def load_default_config(self):\n        # init configuration\n        self.cfg = Config(self.usage, prog=self.prog)\n\n    def init(self, parser, opts, args):\n        raise NotImplementedError\n\n    def load(self):\n        raise NotImplementedError\n\n    def load_config(self):\n        \"\"\"\n        This method is used to load the configuration from one or several input(s).\n        Custom Command line, configuration file.\n        You have to override this method in your class.\n        \"\"\"\n        raise NotImplementedError\n\n    def reload(self):\n        self.do_load_config()\n        if self.cfg.spew:\n            debug.spew()\n\n    def wsgi(self):\n        if self.callable is None:\n            self.callable = self.load()\n        return self.callable\n\n    def run(self):\n        try:\n            Arbiter(self).run()\n        except RuntimeError as e:\n            print(\"\\nError: %s\\n\" % e, file=sys.stderr)\n            sys.stderr.flush()\n            sys.exit(1)\n\n\nclass Application(BaseApplication):\n\n    # 'init' and 'load' methods are implemented by WSGIApplication.\n    # pylint: disable=abstract-method\n\n    def chdir(self):\n        # chdir to the configured path before loading,\n        # default is the current dir\n        os.chdir(self.cfg.chdir)\n\n        # add the path to sys.path\n        if self.cfg.chdir not in sys.path:\n            sys.path.insert(0, self.cfg.chdir)\n\n    def get_config_from_filename(self, filename):\n\n        if not os.path.exists(filename):\n            raise RuntimeError(\"%r doesn't exist\" % filename)\n\n        try:\n            module_name = '__config__'\n            mod = types.ModuleType(module_name)\n            loader = importlib.machinery.SourceFileLoader(module_name, filename)\n            loader.exec_module(mod)\n        except Exception:\n            print(\"Failed to read config file: %s\" % filename, file=sys.stderr)\n            traceback.print_exc()\n            sys.stderr.flush()\n            sys.exit(1)\n\n        return vars(mod)\n\n    def get_config_from_module_name(self, module_name):\n        return vars(importlib.import_module(module_name))\n\n    def load_config_from_module_name_or_filename(self, location):\n        \"\"\"\n        Loads the configuration file: the file is a python file, otherwise raise an RuntimeError\n        Exception or stop the process if the configuration file contains a syntax error.\n        \"\"\"\n\n        if location.startswith(\"python:\"):\n            module_name = location[len(\"python:\"):]\n            cfg = self.get_config_from_module_name(module_name)\n        else:\n            if location.startswith(\"file:\"):\n                filename = location[len(\"file:\"):]\n            else:\n                filename = location\n            cfg = self.get_config_from_filename(filename)\n\n        for k, v in cfg.items():\n            # Ignore unknown names\n            if k not in self.cfg.settings:\n                continue\n            try:\n                self.cfg.set(k.lower(), v)\n            except:\n                print(\"Invalid value for %s: %s\\n\" % (k, v), file=sys.stderr)\n                sys.stderr.flush()\n                raise\n\n        return cfg\n\n    def load_config_from_file(self, filename):\n        return self.load_config_from_module_name_or_filename(location=filename)\n\n    def load_config(self):\n        # parse console args\n        parser = self.cfg.parser()\n        args = parser.parse_args()\n\n        # optional settings from apps\n        cfg = self.init(parser, args, args.args)\n\n        # set up import paths and follow symlinks\n        self.chdir()\n\n        # Load up the any app specific configuration\n        if cfg:\n            for k, v in cfg.items():\n                self.cfg.set(k.lower(), v)\n\n        env_args = parser.parse_args(self.cfg.get_cmd_args_from_env())\n\n        if args.config:\n            self.load_config_from_file(args.config)\n        elif env_args.config:\n            self.load_config_from_file(env_args.config)\n        else:\n            default_config = get_default_config_file()\n            if default_config is not None:\n                self.load_config_from_file(default_config)\n\n        # Load up environment configuration\n        for k, v in vars(env_args).items():\n            if v is None:\n                continue\n            if k == \"args\":\n                continue\n            self.cfg.set(k.lower(), v)\n\n        # Lastly, update the configuration with any command line settings.\n        for k, v in vars(args).items():\n            if v is None:\n                continue\n            if k == \"args\":\n                continue\n            self.cfg.set(k.lower(), v)\n\n        # current directory might be changed by the config now\n        # set up import paths and follow symlinks\n        self.chdir()\n\n    def run(self):\n        if self.cfg.check_config:\n            try:\n                self.load()\n            except:\n                msg = \"\\nError while loading the application:\\n\"\n                print(msg, file=sys.stderr)\n                traceback.print_exc()\n                sys.stderr.flush()\n                sys.exit(1)\n            sys.exit(0)\n\n        if self.cfg.spew:\n            debug.spew()\n\n        if self.cfg.daemon:\n            util.daemonize(self.cfg.enable_stdio_inheritance)\n\n        # set python paths\n        if self.cfg.pythonpath:\n            paths = self.cfg.pythonpath.split(\",\")\n            for path in paths:\n                pythonpath = os.path.abspath(path)\n                if pythonpath not in sys.path:\n                    sys.path.insert(0, pythonpath)\n\n        super().run()\n", "path": "gunicorn/app/base.py"}, {"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\n\nversion_info = (20, 0, 0)\n__version__ = \".\".join([str(v) for v in version_info])\nSERVER_SOFTWARE = \"gunicorn/%s\" % __version__\n", "path": "gunicorn/__init__.py"}], "after_files": [{"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\n\nimport os\nimport sys\n\nfrom setuptools import setup, find_packages\nfrom setuptools.command.test import test as TestCommand\n\nfrom gunicorn import __version__\n\n\nCLASSIFIERS = [\n    'Development Status :: 4 - Beta',\n    'Environment :: Other Environment',\n    'Intended Audience :: Developers',\n    'License :: OSI Approved :: MIT License',\n    'Operating System :: MacOS :: MacOS X',\n    'Operating System :: POSIX',\n    'Programming Language :: Python',\n    'Programming Language :: Python :: 3',\n    'Programming Language :: Python :: 3.5',\n    'Programming Language :: Python :: 3.6',\n    'Programming Language :: Python :: 3.7',\n    'Programming Language :: Python :: 3.8',\n    'Programming Language :: Python :: 3 :: Only',\n    'Programming Language :: Python :: Implementation :: CPython',\n    'Programming Language :: Python :: Implementation :: PyPy',\n    'Topic :: Internet',\n    'Topic :: Utilities',\n    'Topic :: Software Development :: Libraries :: Python Modules',\n    'Topic :: Internet :: WWW/HTTP',\n    'Topic :: Internet :: WWW/HTTP :: WSGI',\n    'Topic :: Internet :: WWW/HTTP :: WSGI :: Server',\n    'Topic :: Internet :: WWW/HTTP :: Dynamic Content']\n\n# read long description\nwith open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:\n    long_description = f.read()\n\n# read dev requirements\nfname = os.path.join(os.path.dirname(__file__), 'requirements_test.txt')\nwith open(fname) as f:\n    tests_require = [l.strip() for l in f.readlines()]\n\nclass PyTestCommand(TestCommand):\n    user_options = [\n        (\"cov\", None, \"measure coverage\")\n    ]\n\n    def initialize_options(self):\n        TestCommand.initialize_options(self)\n        self.cov = None\n\n    def finalize_options(self):\n        TestCommand.finalize_options(self)\n        self.test_args = ['tests']\n        if self.cov:\n            self.test_args += ['--cov', 'gunicorn']\n        self.test_suite = True\n\n    def run_tests(self):\n        import pytest\n        errno = pytest.main(self.test_args)\n        sys.exit(errno)\n\n\ninstall_requires = [\n    # We depend on functioning pkg_resources.working_set.add_entry() and\n    # pkg_resources.load_entry_point(). These both work as of 3.0 which\n    # is the first version to support Python 3.4 which we require as a\n    # floor.\n    'setuptools>=3.0',\n]\n\nextras_require = {\n    'gevent':  ['gevent>=0.13'],\n    'eventlet': ['eventlet>=0.9.7'],\n    'tornado': ['tornado>=0.2'],\n    'gthread': [],\n    'setproctitle': ['setproctitle'],\n}\n\nsetup(\n    name='gunicorn',\n    version=__version__,\n\n    description='WSGI HTTP Server for UNIX',\n    long_description=long_description,\n    author='Benoit Chesneau',\n    author_email='benoitc@e-engura.com',\n    license='MIT',\n    url='http://gunicorn.org',\n\n    python_requires='>=3.4',\n    install_requires=install_requires,\n    classifiers=CLASSIFIERS,\n    zip_safe=False,\n    packages=find_packages(exclude=['examples', 'tests']),\n    include_package_data=True,\n\n    tests_require=tests_require,\n    cmdclass={'test': PyTestCommand},\n\n    entry_points=\"\"\"\n    [console_scripts]\n    gunicorn=gunicorn.app.wsgiapp:run\n\n    [paste.server_runner]\n    main=gunicorn.app.pasterapp:serve\n    \"\"\",\n    extras_require=extras_require,\n)\n", "path": "setup.py"}, {"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\nimport importlib.util\nimport os\nimport sys\nimport traceback\n\nfrom gunicorn import util\nfrom gunicorn.arbiter import Arbiter\nfrom gunicorn.config import Config, get_default_config_file\nfrom gunicorn import debug\n\n\nclass BaseApplication(object):\n    \"\"\"\n    An application interface for configuring and loading\n    the various necessities for any given web framework.\n    \"\"\"\n    def __init__(self, usage=None, prog=None):\n        self.usage = usage\n        self.cfg = None\n        self.callable = None\n        self.prog = prog\n        self.logger = None\n        self.do_load_config()\n\n    def do_load_config(self):\n        \"\"\"\n        Loads the configuration\n        \"\"\"\n        try:\n            self.load_default_config()\n            self.load_config()\n        except Exception as e:\n            print(\"\\nError: %s\" % str(e), file=sys.stderr)\n            sys.stderr.flush()\n            sys.exit(1)\n\n    def load_default_config(self):\n        # init configuration\n        self.cfg = Config(self.usage, prog=self.prog)\n\n    def init(self, parser, opts, args):\n        raise NotImplementedError\n\n    def load(self):\n        raise NotImplementedError\n\n    def load_config(self):\n        \"\"\"\n        This method is used to load the configuration from one or several input(s).\n        Custom Command line, configuration file.\n        You have to override this method in your class.\n        \"\"\"\n        raise NotImplementedError\n\n    def reload(self):\n        self.do_load_config()\n        if self.cfg.spew:\n            debug.spew()\n\n    def wsgi(self):\n        if self.callable is None:\n            self.callable = self.load()\n        return self.callable\n\n    def run(self):\n        try:\n            Arbiter(self).run()\n        except RuntimeError as e:\n            print(\"\\nError: %s\\n\" % e, file=sys.stderr)\n            sys.stderr.flush()\n            sys.exit(1)\n\n\nclass Application(BaseApplication):\n\n    # 'init' and 'load' methods are implemented by WSGIApplication.\n    # pylint: disable=abstract-method\n\n    def chdir(self):\n        # chdir to the configured path before loading,\n        # default is the current dir\n        os.chdir(self.cfg.chdir)\n\n        # add the path to sys.path\n        if self.cfg.chdir not in sys.path:\n            sys.path.insert(0, self.cfg.chdir)\n\n    def get_config_from_filename(self, filename):\n\n        if not os.path.exists(filename):\n            raise RuntimeError(\"%r doesn't exist\" % filename)\n\n        try:\n            module_name = '__config__'\n            spec = importlib.util.spec_from_file_location(module_name, filename)\n            mod = importlib.util.module_from_spec(spec)\n            sys.modules[module_name] = mod\n            spec.loader.exec_module(mod)\n        except Exception:\n            print(\"Failed to read config file: %s\" % filename, file=sys.stderr)\n            traceback.print_exc()\n            sys.stderr.flush()\n            sys.exit(1)\n\n        return vars(mod)\n\n    def get_config_from_module_name(self, module_name):\n        return vars(importlib.import_module(module_name))\n\n    def load_config_from_module_name_or_filename(self, location):\n        \"\"\"\n        Loads the configuration file: the file is a python file, otherwise raise an RuntimeError\n        Exception or stop the process if the configuration file contains a syntax error.\n        \"\"\"\n\n        if location.startswith(\"python:\"):\n            module_name = location[len(\"python:\"):]\n            cfg = self.get_config_from_module_name(module_name)\n        else:\n            if location.startswith(\"file:\"):\n                filename = location[len(\"file:\"):]\n            else:\n                filename = location\n            cfg = self.get_config_from_filename(filename)\n\n        for k, v in cfg.items():\n            # Ignore unknown names\n            if k not in self.cfg.settings:\n                continue\n            try:\n                self.cfg.set(k.lower(), v)\n            except:\n                print(\"Invalid value for %s: %s\\n\" % (k, v), file=sys.stderr)\n                sys.stderr.flush()\n                raise\n\n        return cfg\n\n    def load_config_from_file(self, filename):\n        return self.load_config_from_module_name_or_filename(location=filename)\n\n    def load_config(self):\n        # parse console args\n        parser = self.cfg.parser()\n        args = parser.parse_args()\n\n        # optional settings from apps\n        cfg = self.init(parser, args, args.args)\n\n        # set up import paths and follow symlinks\n        self.chdir()\n\n        # Load up the any app specific configuration\n        if cfg:\n            for k, v in cfg.items():\n                self.cfg.set(k.lower(), v)\n\n        env_args = parser.parse_args(self.cfg.get_cmd_args_from_env())\n\n        if args.config:\n            self.load_config_from_file(args.config)\n        elif env_args.config:\n            self.load_config_from_file(env_args.config)\n        else:\n            default_config = get_default_config_file()\n            if default_config is not None:\n                self.load_config_from_file(default_config)\n\n        # Load up environment configuration\n        for k, v in vars(env_args).items():\n            if v is None:\n                continue\n            if k == \"args\":\n                continue\n            self.cfg.set(k.lower(), v)\n\n        # Lastly, update the configuration with any command line settings.\n        for k, v in vars(args).items():\n            if v is None:\n                continue\n            if k == \"args\":\n                continue\n            self.cfg.set(k.lower(), v)\n\n        # current directory might be changed by the config now\n        # set up import paths and follow symlinks\n        self.chdir()\n\n    def run(self):\n        if self.cfg.check_config:\n            try:\n                self.load()\n            except:\n                msg = \"\\nError while loading the application:\\n\"\n                print(msg, file=sys.stderr)\n                traceback.print_exc()\n                sys.stderr.flush()\n                sys.exit(1)\n            sys.exit(0)\n\n        if self.cfg.spew:\n            debug.spew()\n\n        if self.cfg.daemon:\n            util.daemonize(self.cfg.enable_stdio_inheritance)\n\n        # set python paths\n        if self.cfg.pythonpath:\n            paths = self.cfg.pythonpath.split(\",\")\n            for path in paths:\n                pythonpath = os.path.abspath(path)\n                if pythonpath not in sys.path:\n                    sys.path.insert(0, pythonpath)\n\n        super().run()\n", "path": "gunicorn/app/base.py"}, {"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\n\nversion_info = (20, 0, 1)\n__version__ = \".\".join([str(v) for v in version_info])\nSERVER_SOFTWARE = \"gunicorn/%s\" % __version__\n", "path": "gunicorn/__init__.py"}]}