Skip to content

Commit 903eab1

Browse files
committed
gh-118876: Set ns.temp before invoking its is_absolute method
Fixes an AttributeError that occurs when checking if ns.temp is an absolute path during building from source on Windows.
1 parent 46c8081 commit 903eab1

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

PC/layout/main.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,13 @@ def main():
599599
ns.source = ns.source or (Path(__file__).resolve().parent.parent.parent)
600600
ns.build = ns.build or Path(sys.executable).parent
601601
ns.doc_build = ns.doc_build or (ns.source / "Doc" / "build")
602+
if ns.copy and not ns.copy.is_absolute():
603+
ns.copy = (Path.cwd() / ns.copy).resolve()
604+
if not ns.temp:
605+
if ns.copy and getattr(os.path, "isdevdrive", lambda d: False)(ns.copy):
606+
ns.temp = ns.copy.with_name(ns.copy.name + "_temp")
607+
else:
608+
ns.temp = Path(tempfile.mkdtemp())
602609
if not ns.source.is_absolute():
603610
ns.source = (Path.cwd() / ns.source).resolve()
604611
if not ns.build.is_absolute():
@@ -617,21 +624,11 @@ def main():
617624
else:
618625
ns.arch = "amd64"
619626

620-
if ns.copy and not ns.copy.is_absolute():
621-
ns.copy = (Path.cwd() / ns.copy).resolve()
622627
if ns.zip and not ns.zip.is_absolute():
623628
ns.zip = (Path.cwd() / ns.zip).resolve()
624629
if ns.catalog and not ns.catalog.is_absolute():
625630
ns.catalog = (Path.cwd() / ns.catalog).resolve()
626631

627-
if not ns.temp:
628-
# Put temp on a Dev Drive for speed if we're copying to one.
629-
# If not, the regular temp dir will have to do.
630-
if ns.copy and getattr(os.path, "isdevdrive", lambda d: False)(ns.copy):
631-
ns.temp = ns.copy.with_name(ns.copy.name + "_temp")
632-
else:
633-
ns.temp = Path(tempfile.mkdtemp())
634-
635632
configure_logger(ns)
636633

637634
log_info(

0 commit comments

Comments
 (0)