Skip to content

Commit 2430729

Browse files
gh-118876: Ensure PC/layout sets ns.temp before using it (GH-118880)
Fixes an AttributeError that occurs when checking if ns.temp is an absolute path during building from source on Windows. (cherry picked from commit d8a82cc) Co-authored-by: I-Shen Leong <i-shenl@activestate.com>
1 parent ce3fdf7 commit 2430729

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

PC/layout/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,15 @@ def main():
575575
ns.build = ns.build or Path(sys.executable).parent
576576
ns.temp = ns.temp or Path(tempfile.mkdtemp())
577577
ns.doc_build = ns.doc_build or (ns.source / "Doc" / "build")
578+
if ns.copy and not ns.copy.is_absolute():
579+
ns.copy = (Path.cwd() / ns.copy).resolve()
580+
if not ns.temp:
581+
# Put temp on a Dev Drive for speed if we're copying to one.
582+
# If not, the regular temp dir will have to do.
583+
if ns.copy and getattr(os.path, "isdevdrive", lambda d: False)(ns.copy):
584+
ns.temp = ns.copy.with_name(ns.copy.name + "_temp")
585+
else:
586+
ns.temp = Path(tempfile.mkdtemp())
578587
if not ns.source.is_absolute():
579588
ns.source = (Path.cwd() / ns.source).resolve()
580589
if not ns.build.is_absolute():
@@ -588,8 +597,6 @@ def main():
588597
if not ns.arch:
589598
ns.arch = "amd64" if sys.maxsize > 2 ** 32 else "win32"
590599

591-
if ns.copy and not ns.copy.is_absolute():
592-
ns.copy = (Path.cwd() / ns.copy).resolve()
593600
if ns.zip and not ns.zip.is_absolute():
594601
ns.zip = (Path.cwd() / ns.zip).resolve()
595602
if ns.catalog and not ns.catalog.is_absolute():

0 commit comments

Comments
 (0)