Skip to content

Commit 00fae94

Browse files
committed
Update
[ghstack-poisoned]
1 parent d008afd commit 00fae94

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

setup.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,10 +918,21 @@ def _write_cmake_version_file(self, dst_root: str) -> None:
918918
# 1.5.0+cpu)` is rejected by CMake as an invalid argument, so a consumer could
919919
# not name the version this file reports. Strip to the dotted numbers CMake
920920
# can compare, which is what a consumer asks for in practice.
921-
cmake_version = re.match(r"\d+(?:\.\d+)*", Version.string())
922-
contents = contents.replace(
923-
"@EXECUTORCH_VERSION@", cmake_version.group(0) if cmake_version else "0"
924-
)
921+
# Two variables with different jobs. CMake compares PACKAGE_VERSION, so it has to be the
922+
# numeric release and nothing else. EXECUTORCH_BUILD_VERSION is documented as the full
923+
# version, which is what a consumer pinning an exact build compares against, so filling it
924+
# from the numeric part would make that comparison pass against a different wheel.
925+
build_version = Version.string()
926+
cmake_version = re.match(r"\d+(?:\.\d+)*", build_version)
927+
if not cmake_version:
928+
# A version file claiming 0 would satisfy every version request, which is worse than
929+
# not building at all.
930+
raise RuntimeError(
931+
f"cannot derive a numeric CMake version from {build_version!r}; the version file "
932+
"would claim 0 and satisfy every version request"
933+
)
934+
contents = contents.replace("@EXECUTORCH_VERSION@", cmake_version.group(0))
935+
contents = contents.replace("@EXECUTORCH_BUILD_VERSION@", build_version)
925936
self.mkpath(os.path.dirname(destination))
926937
with open(destination, "w") as handle:
927938
handle.write(contents)

tools/cmake/executorch-wheel-config-version.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(PACKAGE_VERSION "@EXECUTORCH_VERSION@")
2121
# cannot pin a nightly or a specific build through it: passing the full string
2222
# to find_package is a hard argument error. This variable is what a consumer
2323
# compares when an exact build pairing is required.
24-
set(EXECUTORCH_BUILD_VERSION "@EXECUTORCH_VERSION@")
24+
set(EXECUTORCH_BUILD_VERSION "@EXECUTORCH_BUILD_VERSION@")
2525

2626
# Any version at least as new as the one requested is compatible. ExecuTorch has
2727
# no stable ABI promise across majors yet, so this is deliberately permissive;

0 commit comments

Comments
 (0)