We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
"checkov --add-check" failing due to missing templates directory in setup.py
When running `checkov --add-check`, you get an error due to the templates not being installed properly

```
gitpod /workspace/checkov $ checkov --add-check

       _               _              
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V / 
  \___|_| |_|\___|\___|_|\_\___/ \_/  
                                      
By bridgecrew.io | version: 2.0.744 
What action would you like to take? (add) [add]: 

Enter the title of your new check (without a .py) [MyNewTest]: 

Select a category for this check (application_security, backup_and_recoveryconvention, encryption, general_security, iam, kubernetes, logging, networking, secrets) [iam]: 

Describe what this check does [Ensure that X does Y...]: 

What kind of check would you like to add? (terraform) [terraform]: 

Select the cloud provider this will run on (azure, aws, gcp) [aws]: 

Select a terraform object for this check (data, provider, resource) [resource]: 

Enter the terraform object type [aws_iam_policy]: 

Please ensure you are at the root of the Checkov repository before completing this prompt
Traceback (most recent call last):
  File "/home/gitpod/.pyenv/versions/3.8.12/bin/checkov", line 9, in <module>
    sys.exit(run())
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/main.py", line 77, in run
    check.action()
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py", line 184, in action
    getattr(self, self.chosen_action)()
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py", line 189, in add
    self.populate_templates()
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py", line 196, in populate_templates
    tf_unit_test_template = self.template_env().get_template("unittest-terraform.jinja2")
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py", line 167, in template_env
    print("jinja2.list_templates: %s" % jinja2.list_templates())
AttributeError: module 'jinja2' has no attribute 'list_templates'
gitpod /workspace/checkov $ 
```
The problem occurs on Mac, regardless of whether checkov is installed using `pip3 install checkov` or `brew install checkov`. I think it will probably occur in other environments as well.

The fix inside checkov's gitpod environment seems to be fairly simple - just copy the template files from the repo into the installed package:
```
gitpod /workspace/checkov $ ls /home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/templates/
__init__.py  __pycache__
gitpod /workspace/checkov $ cp checkov/common/util/templates/*.jinja2 /home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/templates/
gitpod /workspace/checkov $ checkov --add-check
       _               _              
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V / 
  \___|_| |_|\___|\___|_|\_\___/ \_/  
                                      
By bridgecrew.io | version: 2.0.744 
What action would you like to take? (add) [add]: 

Enter the title of your new check (without a .py) [MyNewTest]: 

Select a category for this check (application_security, backup_and_recoveryconvention, encryption, general_security, iam, kubernetes, logging, networking, secrets) [iam]: 

Describe what this check does [Ensure that X does Y...]: 

What kind of check would you like to add? (terraform) [terraform]: 

Select the cloud provider this will run on (azure, aws, gcp) [aws]: 

Select a terraform object for this check (data, provider, resource) [resource]: 

Enter the terraform object type [aws_iam_policy]: 

Please ensure you are at the root of the Checkov repository before completing this prompt
Creating Check MyNewTest.py in /workspace/checkov/checkov/terraform/checks/resource/aws
        Successfully created /workspace/checkov/checkov/terraform/checks/resource/aws/MyNewTest.py
Creating Unit Test Stubs for MyNewTest in /workspace/checkov/tests/terraform/checks/resource/aws
        Successfully created /workspace/checkov/tests/terraform/checks/resource/aws/example_MyNewTest/MyNewTest.tf
        Successfully created /workspace/checkov/tests/terraform/checks/resource/aws/test_MyNewTest.py

Next steps:
        1) Edit your new check located in the checks/ directory listed above
        2) Add both a PASS and FAIL unit test to the newly created unit test under the tests/ directory to show others how to fix failures

gitpod /workspace/checkov $ 
```

I _think_ the problem is simply due to the template files being inadvertently left out of checkov's `setup.py`, and that adding them into the `package_dir` section as below should probably fix things:
```
    package_dir={
        "checkov.terraform.checks.graph_checks": "checkov/terraform/checks/graph_checks",
        "checkov.common.util.templates": "checkov.common.util.templates"
    },
```

However there's a number of directories under `checkov.common` that maybe should also be added to checkov's `setup.py`, and I'm not familiar enough with all of checkov's use cases to know which ones are important

--- 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 import logging
3 import os
4 from importlib import util
5 from os import path
6 
7 import setuptools
8 from setuptools import setup
9 
10 # read the contents of your README file
11 this_directory = path.abspath(path.dirname(__file__))
12 with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
13     long_description = f.read()
14 
15 logger = logging.getLogger(__name__)
16 spec = util.spec_from_file_location(
17     "checkov.version", os.path.join("checkov", "version.py")
18 )
19 # noinspection PyUnresolvedReferences
20 mod = util.module_from_spec(spec)
21 spec.loader.exec_module(mod)  # type: ignore
22 version = mod.version  # type: ignore
23 
24 setup(
25     extras_require={
26         "dev": [
27             "pytest==5.3.1",
28             "coverage==5.5",
29             "coverage-badge",
30             "GitPython==3.1.7",
31             "bandit",
32             "jsonschema",
33         ]
34     },
35     install_requires=[
36         "bc-python-hcl2>=0.3.24",
37         "cloudsplaining>=0.4.1",
38         "deep_merge",
39         "tabulate",
40         "colorama",
41         "termcolor",
42         "junit-xml>=1.9",
43         "dpath>=1.5.0,<2",
44         "pyyaml>=5.4.1",
45         "boto3>=1.17",
46         "GitPython",
47         "jmespath",
48         "tqdm",
49         "update_checker",
50         "semantic_version",
51         "packaging",
52         "networkx",
53         "dockerfile-parse",
54         "docker",
55         "configargparse",
56         "argcomplete",
57         "detect-secrets",
58         "policyuniverse",
59         "typing-extensions",
60         "cachetools",
61         "cyclonedx-python-lib>=0.11.0,<1.0.0",
62         "click>=8.0.0",
63         "aiohttp",
64         "aiodns",
65         "aiomultiprocess",
66         "jsonpath_ng",
67         "jsonschema~=3.0"
68     ],
69     license="Apache License 2.0",
70     name="checkov",
71     version=version,
72     python_requires=">=3.7",
73     description="Infrastructure as code static analysis",
74     author="bridgecrew",
75     author_email="meet@bridgecrew.io",
76     url="https://github.com/bridgecrewio/checkov",
77     packages=setuptools.find_packages(exclude=["tests*", "integration_tests*"]),
78     include_package_data=True,
79     package_dir={
80         "checkov.terraform.checks.graph_checks": "checkov/terraform/checks/graph_checks"
81     },
82     package_data={
83         "checkov.terraform.checks.graph_checks": [
84             "aws/*.yaml",
85             "gcp/*.yaml",
86             "azure/*.yaml",
87         ]
88     },
89     scripts=["bin/checkov", "bin/checkov.cmd"],
90     long_description=long_description,
91     long_description_content_type="text/markdown",
92     classifiers=[
93         "Environment :: Console",
94         "Intended Audience :: Developers",
95         "Intended Audience :: System Administrators",
96         "Programming Language :: Python :: 3.7",
97         "Programming Language :: Python :: 3.8",
98         "Programming Language :: Python :: 3.9",
99         "Programming Language :: Python :: 3.10",
100         "Topic :: Security",
101         "Topic :: Software Development :: Build Tools",
102     ],
103 )
104
```
--- 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
@@ -84,6 +84,9 @@
             "aws/*.yaml",
             "gcp/*.yaml",
             "azure/*.yaml",
+        ],
+        "checkov.common.util.templates": [
+            "*.jinja2"
         ]
     },
     scripts=["bin/checkov", "bin/checkov.cmd"],

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -84,6 +84,9 @@\n             \"aws/*.yaml\",\n             \"gcp/*.yaml\",\n             \"azure/*.yaml\",\n+        ],\n+        \"checkov.common.util.templates\": [\n+            \"*.jinja2\"\n         ]\n     },\n     scripts=[\"bin/checkov\", \"bin/checkov.cmd\"],\n", "issue": "\"checkov --add-check\" failing due to missing templates directory in setup.py\nWhen running `checkov --add-check`, you get an error due to the templates not being installed properly\r\n\r\n```\r\ngitpod /workspace/checkov $ checkov --add-check\r\n\r\n       _               _              \r\n   ___| |__   ___  ___| | _______   __\r\n  / __| '_ \\ / _ \\/ __| |/ / _ \\ \\ / /\r\n | (__| | | |  __/ (__|   < (_) \\ V / \r\n  \\___|_| |_|\\___|\\___|_|\\_\\___/ \\_/  \r\n                                      \r\nBy bridgecrew.io | version: 2.0.744 \r\nWhat action would you like to take? (add) [add]: \r\n\r\nEnter the title of your new check (without a .py) [MyNewTest]: \r\n\r\nSelect a category for this check (application_security, backup_and_recoveryconvention, encryption, general_security, iam, kubernetes, logging, networking, secrets) [iam]: \r\n\r\nDescribe what this check does [Ensure that X does Y...]: \r\n\r\nWhat kind of check would you like to add? (terraform) [terraform]: \r\n\r\nSelect the cloud provider this will run on (azure, aws, gcp) [aws]: \r\n\r\nSelect a terraform object for this check (data, provider, resource) [resource]: \r\n\r\nEnter the terraform object type [aws_iam_policy]: \r\n\r\nPlease ensure you are at the root of the Checkov repository before completing this prompt\r\nTraceback (most recent call last):\r\n  File \"/home/gitpod/.pyenv/versions/3.8.12/bin/checkov\", line 9, in <module>\r\n    sys.exit(run())\r\n  File \"/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/main.py\", line 77, in run\r\n    check.action()\r\n  File \"/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py\", line 184, in action\r\n    getattr(self, self.chosen_action)()\r\n  File \"/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py\", line 189, in add\r\n    self.populate_templates()\r\n  File \"/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py\", line 196, in populate_templates\r\n    tf_unit_test_template = self.template_env().get_template(\"unittest-terraform.jinja2\")\r\n  File \"/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py\", line 167, in template_env\r\n    print(\"jinja2.list_templates: %s\" % jinja2.list_templates())\r\nAttributeError: module 'jinja2' has no attribute 'list_templates'\r\ngitpod /workspace/checkov $ \r\n```\r\nThe problem occurs on Mac, regardless of whether checkov is installed using `pip3 install checkov` or `brew install checkov`. I think it will probably occur in other environments as well.\r\n\r\nThe fix inside checkov's gitpod environment seems to be fairly simple - just copy the template files from the repo into the installed package:\r\n```\r\ngitpod /workspace/checkov $ ls /home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/templates/\r\n__init__.py  __pycache__\r\ngitpod /workspace/checkov $ cp checkov/common/util/templates/*.jinja2 /home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/templates/\r\ngitpod /workspace/checkov $ checkov --add-check\r\n       _               _              \r\n   ___| |__   ___  ___| | _______   __\r\n  / __| '_ \\ / _ \\/ __| |/ / _ \\ \\ / /\r\n | (__| | | |  __/ (__|   < (_) \\ V / \r\n  \\___|_| |_|\\___|\\___|_|\\_\\___/ \\_/  \r\n                                      \r\nBy bridgecrew.io | version: 2.0.744 \r\nWhat action would you like to take? (add) [add]: \r\n\r\nEnter the title of your new check (without a .py) [MyNewTest]: \r\n\r\nSelect a category for this check (application_security, backup_and_recoveryconvention, encryption, general_security, iam, kubernetes, logging, networking, secrets) [iam]: \r\n\r\nDescribe what this check does [Ensure that X does Y...]: \r\n\r\nWhat kind of check would you like to add? (terraform) [terraform]: \r\n\r\nSelect the cloud provider this will run on (azure, aws, gcp) [aws]: \r\n\r\nSelect a terraform object for this check (data, provider, resource) [resource]: \r\n\r\nEnter the terraform object type [aws_iam_policy]: \r\n\r\nPlease ensure you are at the root of the Checkov repository before completing this prompt\r\nCreating Check MyNewTest.py in /workspace/checkov/checkov/terraform/checks/resource/aws\r\n        Successfully created /workspace/checkov/checkov/terraform/checks/resource/aws/MyNewTest.py\r\nCreating Unit Test Stubs for MyNewTest in /workspace/checkov/tests/terraform/checks/resource/aws\r\n        Successfully created /workspace/checkov/tests/terraform/checks/resource/aws/example_MyNewTest/MyNewTest.tf\r\n        Successfully created /workspace/checkov/tests/terraform/checks/resource/aws/test_MyNewTest.py\r\n\r\nNext steps:\r\n        1) Edit your new check located in the checks/ directory listed above\r\n        2) Add both a PASS and FAIL unit test to the newly created unit test under the tests/ directory to show others how to fix failures\r\n\r\ngitpod /workspace/checkov $ \r\n```\r\n\r\nI _think_ the problem is simply due to the template files being inadvertently left out of checkov's `setup.py`, and that adding them into the `package_dir` section as below should probably fix things:\r\n```\r\n    package_dir={\r\n        \"checkov.terraform.checks.graph_checks\": \"checkov/terraform/checks/graph_checks\",\r\n        \"checkov.common.util.templates\": \"checkov.common.util.templates\"\r\n    },\r\n```\r\n\r\nHowever there's a number of directories under `checkov.common` that maybe should also be added to checkov's `setup.py`, and I'm not familiar enough with all of checkov's use cases to know which ones are important\n", "before_files": [{"content": "#!/usr/bin/env python\nimport logging\nimport os\nfrom importlib import util\nfrom os import path\n\nimport setuptools\nfrom setuptools import setup\n\n# read the contents of your README file\nthis_directory = path.abspath(path.dirname(__file__))\nwith open(path.join(this_directory, \"README.md\"), encoding=\"utf-8\") as f:\n    long_description = f.read()\n\nlogger = logging.getLogger(__name__)\nspec = util.spec_from_file_location(\n    \"checkov.version\", os.path.join(\"checkov\", \"version.py\")\n)\n# noinspection PyUnresolvedReferences\nmod = util.module_from_spec(spec)\nspec.loader.exec_module(mod)  # type: ignore\nversion = mod.version  # type: ignore\n\nsetup(\n    extras_require={\n        \"dev\": [\n            \"pytest==5.3.1\",\n            \"coverage==5.5\",\n            \"coverage-badge\",\n            \"GitPython==3.1.7\",\n            \"bandit\",\n            \"jsonschema\",\n        ]\n    },\n    install_requires=[\n        \"bc-python-hcl2>=0.3.24\",\n        \"cloudsplaining>=0.4.1\",\n        \"deep_merge\",\n        \"tabulate\",\n        \"colorama\",\n        \"termcolor\",\n        \"junit-xml>=1.9\",\n        \"dpath>=1.5.0,<2\",\n        \"pyyaml>=5.4.1\",\n        \"boto3>=1.17\",\n        \"GitPython\",\n        \"jmespath\",\n        \"tqdm\",\n        \"update_checker\",\n        \"semantic_version\",\n        \"packaging\",\n        \"networkx\",\n        \"dockerfile-parse\",\n        \"docker\",\n        \"configargparse\",\n        \"argcomplete\",\n        \"detect-secrets\",\n        \"policyuniverse\",\n        \"typing-extensions\",\n        \"cachetools\",\n        \"cyclonedx-python-lib>=0.11.0,<1.0.0\",\n        \"click>=8.0.0\",\n        \"aiohttp\",\n        \"aiodns\",\n        \"aiomultiprocess\",\n        \"jsonpath_ng\",\n        \"jsonschema~=3.0\"\n    ],\n    license=\"Apache License 2.0\",\n    name=\"checkov\",\n    version=version,\n    python_requires=\">=3.7\",\n    description=\"Infrastructure as code static analysis\",\n    author=\"bridgecrew\",\n    author_email=\"meet@bridgecrew.io\",\n    url=\"https://github.com/bridgecrewio/checkov\",\n    packages=setuptools.find_packages(exclude=[\"tests*\", \"integration_tests*\"]),\n    include_package_data=True,\n    package_dir={\n        \"checkov.terraform.checks.graph_checks\": \"checkov/terraform/checks/graph_checks\"\n    },\n    package_data={\n        \"checkov.terraform.checks.graph_checks\": [\n            \"aws/*.yaml\",\n            \"gcp/*.yaml\",\n            \"azure/*.yaml\",\n        ]\n    },\n    scripts=[\"bin/checkov\", \"bin/checkov.cmd\"],\n    long_description=long_description,\n    long_description_content_type=\"text/markdown\",\n    classifiers=[\n        \"Environment :: Console\",\n        \"Intended Audience :: Developers\",\n        \"Intended Audience :: System Administrators\",\n        \"Programming Language :: Python :: 3.7\",\n        \"Programming Language :: Python :: 3.8\",\n        \"Programming Language :: Python :: 3.9\",\n        \"Programming Language :: Python :: 3.10\",\n        \"Topic :: Security\",\n        \"Topic :: Software Development :: Build Tools\",\n    ],\n)\n", "path": "setup.py"}], "after_files": [{"content": "#!/usr/bin/env python\nimport logging\nimport os\nfrom importlib import util\nfrom os import path\n\nimport setuptools\nfrom setuptools import setup\n\n# read the contents of your README file\nthis_directory = path.abspath(path.dirname(__file__))\nwith open(path.join(this_directory, \"README.md\"), encoding=\"utf-8\") as f:\n    long_description = f.read()\n\nlogger = logging.getLogger(__name__)\nspec = util.spec_from_file_location(\n    \"checkov.version\", os.path.join(\"checkov\", \"version.py\")\n)\n# noinspection PyUnresolvedReferences\nmod = util.module_from_spec(spec)\nspec.loader.exec_module(mod)  # type: ignore\nversion = mod.version  # type: ignore\n\nsetup(\n    extras_require={\n        \"dev\": [\n            \"pytest==5.3.1\",\n            \"coverage==5.5\",\n            \"coverage-badge\",\n            \"GitPython==3.1.7\",\n            \"bandit\",\n            \"jsonschema\",\n        ]\n    },\n    install_requires=[\n        \"bc-python-hcl2>=0.3.24\",\n        \"cloudsplaining>=0.4.1\",\n        \"deep_merge\",\n        \"tabulate\",\n        \"colorama\",\n        \"termcolor\",\n        \"junit-xml>=1.9\",\n        \"dpath>=1.5.0,<2\",\n        \"pyyaml>=5.4.1\",\n        \"boto3>=1.17\",\n        \"GitPython\",\n        \"jmespath\",\n        \"tqdm\",\n        \"update_checker\",\n        \"semantic_version\",\n        \"packaging\",\n        \"networkx\",\n        \"dockerfile-parse\",\n        \"docker\",\n        \"configargparse\",\n        \"argcomplete\",\n        \"detect-secrets\",\n        \"policyuniverse\",\n        \"typing-extensions\",\n        \"cachetools\",\n        \"cyclonedx-python-lib>=0.11.0,<1.0.0\",\n        \"click>=8.0.0\",\n        \"aiohttp\",\n        \"aiodns\",\n        \"aiomultiprocess\",\n        \"jsonpath_ng\",\n        \"jsonschema~=3.0\"\n    ],\n    license=\"Apache License 2.0\",\n    name=\"checkov\",\n    version=version,\n    python_requires=\">=3.7\",\n    description=\"Infrastructure as code static analysis\",\n    author=\"bridgecrew\",\n    author_email=\"meet@bridgecrew.io\",\n    url=\"https://github.com/bridgecrewio/checkov\",\n    packages=setuptools.find_packages(exclude=[\"tests*\", \"integration_tests*\"]),\n    include_package_data=True,\n    package_dir={\n        \"checkov.terraform.checks.graph_checks\": \"checkov/terraform/checks/graph_checks\"\n    },\n    package_data={\n        \"checkov.terraform.checks.graph_checks\": [\n            \"aws/*.yaml\",\n            \"gcp/*.yaml\",\n            \"azure/*.yaml\",\n        ],\n        \"checkov.common.util.templates\": [\n            \"*.jinja2\"\n        ]\n    },\n    scripts=[\"bin/checkov\", \"bin/checkov.cmd\"],\n    long_description=long_description,\n    long_description_content_type=\"text/markdown\",\n    classifiers=[\n        \"Environment :: Console\",\n        \"Intended Audience :: Developers\",\n        \"Intended Audience :: System Administrators\",\n        \"Programming Language :: Python :: 3.7\",\n        \"Programming Language :: Python :: 3.8\",\n        \"Programming Language :: Python :: 3.9\",\n        \"Programming Language :: Python :: 3.10\",\n        \"Topic :: Security\",\n        \"Topic :: Software Development :: Build Tools\",\n    ],\n)\n", "path": "setup.py"}]}