Repository: pypa/setuptools_scm

Issue:
regression from 7.x: unable to install some libraries (e.g. setuptools_scm_git_archive, pikepdf) - version detected as 0.0
The following works:

```bash
docker run -it python:3.9-alpine /bin/sh -c \
  'pip install setuptools_scm==6.4.2 && pip install --no-build-isolation setuptools_scm_git_archive==1.2 --no-binary :all:'
```

But fails when upgrading to 7.0.2:
```bash
docker run -it python:3.9-alpine /bin/sh -c \
  'pip install setuptools_scm==7.0.2 && pip install --no-build-isolation setuptools_scm_git_archive==1.2 --no-binary :all:'
```

Output:
```
Collecting setuptools_scm==7.0.2
  Downloading setuptools_scm-7.0.2-py3-none-any.whl (40 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.7/40.7 KB 2.9 MB/s eta 0:00:00
Collecting packaging>=20.0
  Downloading packaging-21.3-py3-none-any.whl (40 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 KB 6.7 MB/s eta 0:00:00
Collecting tomli>=1.0.0
  Downloading tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting typing-extensions
  Downloading typing_extensions-4.2.0-py3-none-any.whl (24 kB)
Requirement already satisfied: setuptools in /usr/local/lib/python3.9/site-packages (from setuptools_scm==7.0.2) (58.1.0)
Collecting pyparsing!=3.0.5,>=2.0.2
  Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 KB 10.8 MB/s eta 0:00:00
Installing collected packages: typing-extensions, tomli, pyparsing, packaging, setuptools_scm
Successfully installed packaging-21.3 pyparsing-3.0.9 setuptools_scm-7.0.2 tomli-2.0.1 typing-extensions-4.2.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Collecting setuptools_scm_git_archive==1.2
  Downloading setuptools_scm_git_archive-1.2.tar.gz (3.4 kB)
  Preparing metadata (setup.py) ... done
  WARNING: Requested setuptools_scm_git_archive==1.2 from https://files.pythonhosted.org/packages/78/a2/aee5edbf18bbd5dd6b90a762e54d15182bc840e8ac34fc1993f99795ebe7/setuptools_scm_git_archive-1.2.tar.gz#sha256=92e8149c1f4a62fe170962b4ff8cb3d53bfa90fc944f1f1758cebaef56a67f13, but installing version 0.0
Discarding https://files.pythonhosted.org/packages/78/a2/aee5edbf18bbd5dd6b90a762e54d15182bc840e8ac34fc1993f99795ebe7/setuptools_scm_git_archive-1.2.tar.gz#sha256=92e8149c1f4a62fe170962b4ff8cb3d53bfa90fc944f1f1758cebaef56a67f13 (from https://pypi.org/simple/setuptools-scm-git-archive/): Requested setuptools_scm_git_archive==1.2 from https://files.pythonhosted.org/packages/78/a2/aee5edbf18bbd5dd6b90a762e54d15182bc840e8ac34fc1993f99795ebe7/setuptools_scm_git_archive-1.2.tar.gz#sha256=92e8149c1f4a62fe170962b4ff8cb3d53bfa90fc944f1f1758cebaef56a67f13 has inconsistent version: filename has '1.2', but metadata has '0.0'
ERROR: Could not find a version that satisfies the requirement setuptools_scm_git_archive==1.2 (from versions: 1.0, 1.1, 1.2)
ERROR: No matching distribution found for setuptools_scm_git_archive==1.2
WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
```

The notable line in the output is: 
> https://files.pythonhosted.org/packages/78/a2/aee5edbf18bbd5dd6b90a762e54d15182bc840e8ac34fc1993f99795ebe7/setuptools_scm_git_archive-1.2.tar.gz#sha256=92e8149c1f4a62fe170962b4ff8cb3d53bfa90fc944f1f1758cebaef56a67f13 (from https://pypi.org/simple/setuptools-scm-git-archive/): Requested setuptools_scm_git_archive==1.2 from https://files.pythonhosted.org/packages/78/a2/aee5edbf18bbd5dd6b90a762e54d15182bc840e8ac34fc1993f99795ebe7/setuptools_scm_git_archive-1.2.tar.gz#sha256=92e8149c1f4a62fe170962b4ff8cb3d53bfa90fc944f1f1758cebaef56a67f13 has inconsistent version: **filename has '1.2', but metadata has '0.0'**

A workaround I've found is to use this escape hatch: https://github.com/pypa/setuptools_scm/blob/f1f35bd0f20a983a919d73a646a2ad9a3e36d5d4/src/setuptools_scm/_overrides.py#L15-L20
```
docker run -it -e 'SETUPTOOLS_SCM_PRETEND_VERSION_FOR_SETUPTOOLS_SCM_GIT_ARCHIVE=1.2' python:3.9-alpine /bin/sh -c \
  'pip install setuptools_scm==7.0.2 && pip install --no-build-isolation setuptools_scm_git_archive==1.2 --no-binary :all:'
```




Discussion:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 4c9bd24..f140523 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,3 +1,9 @@
+v7.0.4
+=======
+
+* fix #727: correctly handle incomplete archivals from setuptools_scm_git_archival
+* fix #691: correctly handle specifying root in pyproject.toml
+
 v7.0.3
 =======
 * fix mercurial usage when pip primes a isolated environment
diff --git a/src/setuptools_scm/git.py b/src/setuptools_scm/git.py
index 47e2a9e..1aee95a 100644
--- a/src/setuptools_scm/git.py
+++ b/src/setuptools_scm/git.py
@@ -276,7 +276,8 @@ def search_parent(dirname: _t.PathT) -> GitWorkdir | None:
 
 def archival_to_version(
     data: dict[str, str], config: Configuration | None = None
-) -> ScmVersion:
+) -> ScmVersion | None:
+    node: str | None
     trace("data", data)
     archival_describe = data.get("describe-name", DESCRIBE_UNSUPPORTED)
     if DESCRIBE_UNSUPPORTED in archival_describe:
@@ -293,7 +294,11 @@ def archival_to_version(
     if versions:
         return meta(versions[0], config=config)
     else:
-        return meta("0.0", node=data.get("node"), config=config)
+        node = data.get("node")
+        if node is not None:
+            return meta("0.0", node=node, config=config)
+        else:
+            return None
 
 
 def parse_archival(


Test patch:
diff --git a/testing/test_git.py b/testing/test_git.py
index 6663527..674d904 100644
--- a/testing/test_git.py
+++ b/testing/test_git.py
@@ -529,9 +529,17 @@ def test_git_getdate_signed_commit(signed_commit_wd: WorkDir) -> None:
 def test_git_archival_to_version(expected: str, from_data: dict[str, str]) -> None:
     config = Configuration()
     version = archival_to_version(from_data, config=config)
+    assert version is not None
     assert (
         format_version(
             version, version_scheme="guess-next-dev", local_scheme="node-and-date"
         )
         == expected
     )
+
+
+@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/727")
+def test_git_archival_node_missing_no_version() -> None:
+    config = Configuration()
+    version = archival_to_version({}, config=config)
+    assert version is None