Skip to content

Commit

Permalink
pythongh-118876: Set ns.temp before invoking its is_absolute method
Browse files Browse the repository at this point in the history
Fixes an AttributeError that occurs when checking if ns.temp is an absolute path during building from source on Windows.
  • Loading branch information
i-shenl committed May 10, 2024
1 parent 46c8081 commit 903eab1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions PC/layout/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,13 @@ def main():
ns.source = ns.source or (Path(__file__).resolve().parent.parent.parent)
ns.build = ns.build or Path(sys.executable).parent
ns.doc_build = ns.doc_build or (ns.source / "Doc" / "build")
if ns.copy and not ns.copy.is_absolute():
ns.copy = (Path.cwd() / ns.copy).resolve()
if not ns.temp:
if ns.copy and getattr(os.path, "isdevdrive", lambda d: False)(ns.copy):
ns.temp = ns.copy.with_name(ns.copy.name + "_temp")
else:
ns.temp = Path(tempfile.mkdtemp())
if not ns.source.is_absolute():
ns.source = (Path.cwd() / ns.source).resolve()
if not ns.build.is_absolute():
Expand All @@ -617,21 +624,11 @@ def main():
else:
ns.arch = "amd64"

if ns.copy and not ns.copy.is_absolute():
ns.copy = (Path.cwd() / ns.copy).resolve()
if ns.zip and not ns.zip.is_absolute():
ns.zip = (Path.cwd() / ns.zip).resolve()
if ns.catalog and not ns.catalog.is_absolute():
ns.catalog = (Path.cwd() / ns.catalog).resolve()

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

configure_logger(ns)

log_info(
Expand Down

0 comments on commit 903eab1

Please sign in to comment.