From 98b2ab4a122eb7169a9f2e406f533a7717b191c8 Mon Sep 17 00:00:00 2001 From: Mengwei Liu Date: Fri, 7 Mar 2025 12:25:25 -0800 Subject: [PATCH] mkdir when destination directory doesn't exist Fixes #8980 Make sure we mkdir if destination directory doesn't exist. I have no idea why it doesn't work before ghstack-source-id: 745e02d5e147f67927a86ccb25a4330e2aceeccd Pull Request resolved: https://github.com/pytorch/executorch/pull/9055 --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5645708a4ca..28251cdf0df 100644 --- a/setup.py +++ b/setup.py @@ -463,7 +463,8 @@ def build_extension(self, ext: _BaseExtension) -> None: dst_file: Path = ext.dst_path(self) # Ensure that the destination directory exists. - self.mkpath(os.fspath(dst_file.parent)) + if not dst_file.parent.exists(): + self.mkpath(os.fspath(dst_file.parent)) # Copy the file. self.copy_file(os.fspath(src_file), os.fspath(dst_file))