Patchwork D12560: contrib: add a hint if the Windows dependency MSI is already installed

login
register
mail settings
Submitter phabricator
Date April 15, 2022, 3:37 p.m.
Message ID <differential-rev-PHID-DREV-6ibvan73s3lzyz5epq7t-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50908/
State New
Headers show

Comments

phabricator - April 15, 2022, 3:37 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In the past, I've gotten confused when the script failed on seemingly random
  python installs (and thus the py3.8 install was commented out from the last time
  this happened to me, which has been reverted here).  This particular error code
  means the package was already installed.  For python, it means the major and
  minor version are the same, but the micro version may differ.
  
  In practice, ignoring the python installation failure will cause the pip
  installation that happens next to fail, because python.exe for that version is
  somewhere else on the system.  This could probably be fixed by running py.exe
  with the major and minor version, but that is skipped during the install for
  some reason.  I didn't feel like over complicating this though, and at least
  there's a better hint when the problem occurs.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12560

AFFECTED FILES
  contrib/install-windows-dependencies.ps1

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/contrib/install-windows-dependencies.ps1 b/contrib/install-windows-dependencies.ps1
--- a/contrib/install-windows-dependencies.ps1
+++ b/contrib/install-windows-dependencies.ps1
@@ -90,7 +90,13 @@ 
     $p = Start-Process -FilePath $path -ArgumentList $arguments -Wait -PassThru -WindowStyle Hidden
 
     if ($p.ExitCode -ne 0) {
-        throw "process exited non-0: $($p.ExitCode)"
+        # If the MSI is already installed, ignore the error
+        if ($p.ExitCode -eq 1638) {
+            Write-Output "program already installed; continuing..."
+        }
+        else {
+            throw "process exited non-0: $($p.ExitCode)"
+        }
     }
 }
 
@@ -150,7 +156,7 @@ 
     Install-Python3 "Python 3.7 32-bit" ${prefix}\assets\python37-x86.exe ${prefix}\python37-x86 ${pip}
     Install-Python3 "Python 3.7 64-bit" ${prefix}\assets\python37-x64.exe ${prefix}\python37-x64 ${pip}
     Install-Python3 "Python 3.8 32-bit" ${prefix}\assets\python38-x86.exe ${prefix}\python38-x86 ${pip}
-#    Install-Python3 "Python 3.8 64-bit" ${prefix}\assets\python38-x64.exe ${prefix}\python38-x64 ${pip}
+    Install-Python3 "Python 3.8 64-bit" ${prefix}\assets\python38-x64.exe ${prefix}\python38-x64 ${pip}
     Install-Python3 "Python 3.9 32-bit" ${prefix}\assets\python39-x86.exe ${prefix}\python39-x86 ${pip}
     Install-Python3 "Python 3.9 64-bit" ${prefix}\assets\python39-x64.exe ${prefix}\python39-x64 ${pip}
     Install-Python3 "Python 3.10 32-bit" ${prefix}\assets\python310-x86.exe ${prefix}\python310-x86 ${pip}