From 4d880cc9ca9b9abba8face208a8d43042c727836 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Thu, 19 Sep 2024 17:15:29 +0800 Subject: [PATCH] fix: fallback version to 0.0.0 when empty FIx #3163 Signed-off-by: Frost Ming --- news/3163.bugfix.md | 1 + src/pdm/utils.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 news/3163.bugfix.md diff --git a/news/3163.bugfix.md b/news/3163.bugfix.md new file mode 100644 index 0000000000..250403e587 --- /dev/null +++ b/news/3163.bugfix.md @@ -0,0 +1 @@ +Fallback version to 0.0.0 when the version is not specified or empty. This can avoid crash when building such project. diff --git a/src/pdm/utils.py b/src/pdm/utils.py index 6b62d671f8..ef2ca2935e 100644 --- a/src/pdm/utils.py +++ b/src/pdm/utils.py @@ -350,7 +350,7 @@ def normalize_name(name: str, lowercase: bool = True) -> str: def comparable_version(version: str) -> Version: """Normalize a version to make it valid in a specifier.""" - parsed = parse_version(version) + parsed = parse_version(version or "0.0.0") if parsed.local is not None: # strip the local part parsed._version = parsed._version._replace(local=None)