Repository: pypa/hatch

Issue:
`hatch version` fails for "unknown metadata hook"
With [this `pyproject.toml`](https://github.com/scikit-hep/awkward/blob/agoose77/chore/split-awkward-package/pyproject.toml), running 
```bash
hatch version
```
gives the following traceback:
```
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/hatch/cli/__init__.p │
│ y:205 in main                                                                                    │
│                                                                                                  │
│   202                                                                                            │
│   203 def main():  # no cov                                                                      │
│   204 │   try:                                                                                   │
│ ❱ 205 │   │   return hatch(windows_expand_args=False)                                            │
│   206 │   except Exception:                                                                      │
│   207 │   │   from rich.console import Console                                                   │
│   208                                                                                            │
│                                                                                                  │
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/click/core.py:1130   │
│ in __call__                                                                                      │
│                                                                                                  │
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/click/core.py:1055   │
│ in main                                                                                          │
│                                                                                                  │
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/click/core.py:1657   │
│ in invoke                                                                                        │
│                                                                                                  │
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/click/core.py:1404   │
│ in invoke                                                                                        │
│                                                                                                  │
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/click/core.py:760 in │
│ invoke                                                                                           │
│                                                                                                  │
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/click/decorators.py: │
│ 38 in new_func                                                                                   │
│                                                                                                  │
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/hatch/cli/version/__ │
│ init__.py:13 in version                                                                          │
│                                                                                                  │
│   10 │   │   if desired_version:                                                                 │
│   11 │   │   │   app.abort('Cannot set version when it is statically defined by the `project.    │
│   12 │   │   else:                                                                               │
│ ❱ 13 │   │   │   app.display_always(app.project.metadata.core.version)                           │
│   14 │   │   │   return                                                                          │
│   15 │                                                                                           │
│   16 │   from hatchling.dep.core import dependencies_in_sync                                     │
│                                                                                                  │
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/hatchling/metadata/c │
│ ore.py:139 in core                                                                               │
│                                                                                                  │
│    136 │   │   │   # Save the fields                                                             │
│    137 │   │   │   _ = self.dynamic                                                              │
│    138 │   │   │                                                                                 │
│ ❱  139 │   │   │   metadata_hooks = self.hatch.metadata.hooks                                    │
│    140 │   │   │   if metadata_hooks:                                                            │
│    141 │   │   │   │   static_fields = set(self.core_raw_metadata)                               │
│    142 │   │   │   │   if 'version' in self.hatch.config:                                        │
│                                                                                                  │
│ /home/angus/.local/pipx/.cache/953f6e33b1619f9/lib/python3.10/site-packages/hatchling/metadata/c │
│ ore.py:1400 in hooks                                                                             │
│                                                                                                  │
│   1397 │   │   │   │   if metadata_hook is None:                                                 │
│   1398 │   │   │   │   │   from hatchling.plugin.exceptions import UnknownPluginError            │
│   1399 │   │   │   │   │                                                                         │
│ ❱ 1400 │   │   │   │   │   raise UnknownPluginError(f'Unknown metadata hook: {hook_name}')       │
│   1401 │   │   │   │                                                                             │
│   1402 │   │   │   │   configured_hooks[hook_name] = metadata_hook(self.root, config)            │
│   1403                                                                                           │
╰──────────────────────────────────────────────────────────────
```

My expectation is that hatch installs any plugins that it needs, but otherwise does not. We have a mechanism for this with build plugins: https://hatch.pypa.io/latest/config/build/#dependencies 

In this case, we probably don't need to load this plugin to begin with, though.

Comments:

Patch:
diff --git a/docs/history/hatch.md b/docs/history/hatch.md
index f2076ec3..3930bafa 100644
--- a/docs/history/hatch.md
+++ b/docs/history/hatch.md
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 
 ***Fixed:***
 
+- Fix displaying the version with the `version` command when the version is static and build dependencies are unmet
 - Fix the `support-legacy` option for the `sdist` target when using a src-layout project structure
 
 ### [1.6.3](https://github.com/pypa/hatch/releases/tag/hatch-v1.6.3) - 2022-10-24 ### {: #hatch-v1.6.3 }
diff --git a/src/hatch/cli/version/__init__.py b/src/hatch/cli/version/__init__.py
index 5c619527..e22466b1 100644
--- a/src/hatch/cli/version/__init__.py
+++ b/src/hatch/cli/version/__init__.py
@@ -10,7 +10,7 @@ def version(app, desired_version):
         if desired_version:
             app.abort('Cannot set version when it is statically defined by the `project.version` field')
         else:
-            app.display_always(app.project.metadata.core.version)
+            app.display_always(app.project.metadata.config['project']['version'])
             return
 
     from hatchling.dep.core import dependencies_in_sync


Test patch:
diff --git a/tests/cli/version/test_version.py b/tests/cli/version/test_version.py
index 03d0dbf5..ea1441d7 100644
--- a/tests/cli/version/test_version.py
+++ b/tests/cli/version/test_version.py
@@ -130,6 +130,7 @@ def test_show_static(hatch, temp_dir):
     config = dict(project.raw_config)
     config['project']['version'] = '1.2.3'
     config['project']['dynamic'].remove('version')
+    config['tool']['hatch']['metadata'] = {'hooks': {'foo': {}}}
     project.save_config(config)
 
     with path.as_cwd():