changeset 49957:ff4df0954742

setup: Ensure target directory exists with building rust extension When the rust extension is the first to be build, the target directory may not exist so the copy fails.
author Cédric Krier <ced@b2ck.com>
date Sat, 28 Jan 2023 20:08:57 +0100
parents 2282d8ac0fa9
children 96e526fe5fb0
files setup.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Thu Jan 26 00:23:07 2023 +0100
+++ b/setup.py	Sat Jan 28 20:08:57 2023 +0100
@@ -1454,11 +1454,13 @@
         target = [target_dir]
         target.extend(self.name.split('.'))
         target[-1] += DYLIB_SUFFIX
+        target = os.path.join(*target)
+        os.makedirs(os.path.dirname(target), exist_ok=True)
         shutil.copy2(
             os.path.join(
                 self.rusttargetdir, self.dylibname + self.rustdylibsuffix()
             ),
-            os.path.join(*target),
+            target,
         )