contrib/install-windows-dependencies.ps1
author Ian Moody <moz-ian@perix.co.uk>
Fri, 07 Jun 2019 20:19:55 +0100
changeset 42431 29528c4235a1
parent 42023 bf87d34a675c
child 42649 7fae3b0bd893
permissions -rw-r--r--
phabricator: add commenting to phabsend for new/updated Diffs Especially useful when sending updates to existing Revisions so one can specify the sort of changes e.g. "Address review comments" or "Rebase to tip" If the diff content hasn't changed then it only needs a metadata update which doesn't show in the Phabricator updates UI, so don't add a comment that will. Differential Revision: https://phab.mercurial-scm.org/D6496
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
# install-dependencies.ps1 - Install Windows dependencies for building Mercurial
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
#
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
#
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
# This script can be used to bootstrap a Mercurial build environment on
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
# Windows.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    10
#
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    11
# The script makes a lot of assumptions about how things should work.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
# For example, the install location of Python is hardcoded to c:\hgdev\*.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
#
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
# The script should be executed from a PowerShell with elevated privileges
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    15
# if you don't want to see a UAC prompt for various installers.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    16
#
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    17
# The script is tested on Windows 10 and Windows Server 2019 (in EC2).
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    18
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    19
$VS_BUILD_TOOLS_URL = "https://download.visualstudio.microsoft.com/download/pr/a1603c02-8a66-4b83-b821-811e3610a7c4/aa2db8bb39e0cbd23e9940d8951e0bc3/vs_buildtools.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    20
$VS_BUILD_TOOLS_SHA256 = "911E292B8E6E5F46CBC17003BDCD2D27A70E616E8D5E6E69D5D489A605CAA139"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    21
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    22
$VC9_PYTHON_URL = "https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    23
$VC9_PYTHON_SHA256 = "070474db76a2e625513a5835df4595df9324d820f9cc97eab2a596dcbc2f5cbf"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    24
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    25
$PYTHON27_x64_URL = "https://www.python.org/ftp/python/2.7.16/python-2.7.16.amd64.msi"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    26
$PYTHON27_x64_SHA256 = "7c0f45993019152d46041a7db4b947b919558fdb7a8f67bcd0535bc98d42b603"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    27
$PYTHON27_X86_URL = "https://www.python.org/ftp/python/2.7.16/python-2.7.16.msi"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    28
$PYTHON27_X86_SHA256 = "d57dc3e1ba490aee856c28b4915d09e3f49442461e46e481bc6b2d18207831d7"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    29
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    30
$PYTHON35_x86_URL = "https://www.python.org/ftp/python/3.5.4/python-3.5.4.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    31
$PYTHON35_x86_SHA256 = "F27C2D67FD9688E4970F3BFF799BB9D722A0D6C2C13B04848E1F7D620B524B0E"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    32
$PYTHON35_x64_URL = "https://www.python.org/ftp/python/3.5.4/python-3.5.4-amd64.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    33
$PYTHON35_x64_SHA256 = "9B7741CC32357573A77D2EE64987717E527628C38FD7EAF3E2AACA853D45A1EE"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    35
$PYTHON36_x86_URL = "https://www.python.org/ftp/python/3.6.8/python-3.6.8.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
$PYTHON36_x86_SHA256 = "89871D432BC06E4630D7B64CB1A8451E53C80E68DE29029976B12AAD7DBFA5A0"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    37
$PYTHON36_x64_URL = "https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    38
$PYTHON36_x64_SHA256 = "96088A58B7C43BC83B84E6B67F15E8706C614023DD64F9A5A14E81FF824ADADC"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    39
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    40
$PYTHON37_x86_URL = "https://www.python.org/ftp/python/3.7.2/python-3.7.2.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    41
$PYTHON37_x86_SHA256 = "8BACE330FB409E428B04EEEE083DD9CA7F6C754366D07E23B3853891D8F8C3D0"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    42
$PYTHON37_x64_URL = "https://www.python.org/ftp/python/3.7.2/python-3.7.2-amd64.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    43
$PYTHON37_x64_SHA256 = "0FE2A696F5A3E481FED795EF6896ED99157BCEF273EF3C4A96F2905CBDB3AA13"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    44
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    45
$PYTHON38_x86_URL = "https://www.python.org/ftp/python/3.8.0/python-3.8.0a2.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    46
$PYTHON38_x86_SHA256 = "013A7DDD317679FE51223DE627688CFCB2F0F1128FD25A987F846AEB476D3FEF"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    47
$PYTHON38_x64_URL = "https://www.python.org/ftp/python/3.8.0/python-3.8.0a2-amd64.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    48
$PYTHON38_X64_SHA256 = "560BC6D1A76BCD6D544AC650709F3892956890753CDCF9CE67E3D7302D76FB41"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    49
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    50
# PIP 19.0.3.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    51
$PIP_URL = "https://github.com/pypa/get-pip/raw/fee32c376da1ff6496a798986d7939cd51e1644f/get-pip.py"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    52
$PIP_SHA256 = "efe99298f3fbb1f56201ce6b81d2658067d2f7d7dfc2d412e0d3cacc9a397c61"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    53
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    54
$VIRTUALENV_URL = "https://files.pythonhosted.org/packages/37/db/89d6b043b22052109da35416abc3c397655e4bd3cff031446ba02b9654fa/virtualenv-16.4.3.tar.gz"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    55
$VIRTUALENV_SHA256 = "984d7e607b0a5d1329425dd8845bd971b957424b5ba664729fab51ab8c11bc39"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    56
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    57
$INNO_SETUP_URL = "http://files.jrsoftware.org/is/5/innosetup-5.6.1-unicode.exe"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    58
$INNO_SETUP_SHA256 = "27D49E9BC769E9D1B214C153011978DB90DC01C2ACD1DDCD9ED7B3FE3B96B538"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    59
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    60
$MINGW_BIN_URL = "https://osdn.net/frs/redir.php?m=constant&f=mingw%2F68260%2Fmingw-get-0.6.3-mingw32-pre-20170905-1-bin.zip"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    61
$MINGW_BIN_SHA256 = "2AB8EFD7C7D1FC8EAF8B2FA4DA4EEF8F3E47768284C021599BC7435839A046DF"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    62
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    63
$MERCURIAL_WHEEL_FILENAME = "mercurial-4.9-cp27-cp27m-win_amd64.whl"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    64
$MERCURIAL_WHEEL_URL = "https://files.pythonhosted.org/packages/fe/e8/b872d53dfbbf986bdc46af0b30f580b227fb59bddd2587152a55e205b0cc/$MERCURIAL_WHEEL_FILENAME"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    65
$MERCURIAL_WHEEL_SHA256 = "218cc2e7c3f1d535007febbb03351663897edf27df0e57d6842e3b686492b429"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    66
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    67
# Writing progress slows down downloads substantially. So disable it.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    68
$progressPreference = 'silentlyContinue'
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    69
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    70
function Secure-Download($url, $path, $sha256) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    71
    if (Test-Path -Path $path) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    72
        Get-FileHash -Path $path -Algorithm SHA256 -OutVariable hash
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    73
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    74
        if ($hash.Hash -eq $sha256) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    75
            Write-Output "SHA256 of $path verified as $sha256"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    76
            return
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    77
        }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    78
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    79
        Write-Output "hash mismatch on $path; downloading again"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    80
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    81
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    82
    Write-Output "downloading $url to $path"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    83
    Invoke-WebRequest -Uri $url -OutFile $path
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    84
    Get-FileHash -Path $path -Algorithm SHA256 -OutVariable hash
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    85
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    86
    if ($hash.Hash -ne $sha256) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    87
        Remove-Item -Path $path
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    88
        throw "hash mismatch when downloading $url; got $($hash.Hash), expected $sha256"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    89
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    90
}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    92
function Invoke-Process($path, $arguments) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    93
    $p = Start-Process -FilePath $path -ArgumentList $arguments -Wait -PassThru -WindowStyle Hidden
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    94
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    95
    if ($p.ExitCode -ne 0) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    96
        throw "process exited non-0: $($p.ExitCode)"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    97
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    98
}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    99
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   100
function Install-Python3($name, $installer, $dest, $pip) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   101
    Write-Output "installing $name"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   102
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   103
    # We hit this when running the script as part of Simple Systems Manager in
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   104
    # EC2. The Python 3 installer doesn't seem to like per-user installs
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   105
    # when running as the SYSTEM user. So enable global installs if executed in
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   106
    # this mode.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   107
    if ($env:USERPROFILE -eq "C:\Windows\system32\config\systemprofile") {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   108
        Write-Output "running with SYSTEM account; installing for all users"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   109
        $allusers = "1"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   110
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   111
    else {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   112
        $allusers = "0"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   113
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   114
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   115
    Invoke-Process $installer "/quiet TargetDir=${dest} InstallAllUsers=${allusers} AssociateFiles=0 CompileAll=0 PrependPath=0 Include_doc=0 Include_launcher=0 InstallLauncherAllUsers=0 Include_pip=0 Include_test=0"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   116
    Invoke-Process ${dest}\python.exe $pip
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   117
}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   118
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   119
function Install-Dependencies($prefix) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   120
    if (!(Test-Path -Path $prefix\assets)) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   121
        New-Item -Path $prefix\assets -ItemType Directory
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   122
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   123
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   124
    $pip = "${prefix}\assets\get-pip.py"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   125
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   126
    Secure-Download $VC9_PYTHON_URL ${prefix}\assets\VCForPython27.msi $VC9_PYTHON_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   127
    Secure-Download $PYTHON27_x86_URL ${prefix}\assets\python27-x86.msi $PYTHON27_x86_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   128
    Secure-Download $PYTHON27_x64_URL ${prefix}\assets\python27-x64.msi $PYTHON27_x64_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   129
    Secure-Download $PYTHON35_x86_URL ${prefix}\assets\python35-x86.exe $PYTHON35_x86_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   130
    Secure-Download $PYTHON35_x64_URL ${prefix}\assets\python35-x64.exe $PYTHON35_x64_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   131
    Secure-Download $PYTHON36_x86_URL ${prefix}\assets\python36-x86.exe $PYTHON36_x86_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   132
    Secure-Download $PYTHON36_x64_URL ${prefix}\assets\python36-x64.exe $PYTHON36_x64_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   133
    Secure-Download $PYTHON37_x86_URL ${prefix}\assets\python37-x86.exe $PYTHON37_x86_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   134
    Secure-Download $PYTHON37_x64_URL ${prefix}\assets\python37-x64.exe $PYTHON37_x64_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   135
    Secure-Download $PYTHON38_x86_URL ${prefix}\assets\python38-x86.exe $PYTHON38_x86_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   136
    Secure-Download $PYTHON38_x64_URL ${prefix}\assets\python38-x64.exe $PYTHON38_x64_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   137
    Secure-Download $PIP_URL ${pip} $PIP_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   138
    Secure-Download $VIRTUALENV_URL ${prefix}\assets\virtualenv.tar.gz $VIRTUALENV_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   139
    Secure-Download $VS_BUILD_TOOLS_URL ${prefix}\assets\vs_buildtools.exe $VS_BUILD_TOOLS_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   140
    Secure-Download $INNO_SETUP_URL ${prefix}\assets\InnoSetup.exe $INNO_SETUP_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   141
    Secure-Download $MINGW_BIN_URL ${prefix}\assets\mingw-get-bin.zip $MINGW_BIN_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   142
    Secure-Download $MERCURIAL_WHEEL_URL ${prefix}\assets\${MERCURIAL_WHEEL_FILENAME} $MERCURIAL_WHEEL_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   143
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   144
    Write-Output "installing Python 2.7 32-bit"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   145
    Invoke-Process msiexec.exe "/i ${prefix}\assets\python27-x86.msi /l* ${prefix}\assets\python27-x86.log /q TARGETDIR=${prefix}\python27-x86 ALLUSERS="
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   146
    Invoke-Process ${prefix}\python27-x86\python.exe ${prefix}\assets\get-pip.py
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   147
    Invoke-Process ${prefix}\python27-x86\Scripts\pip.exe "install ${prefix}\assets\virtualenv.tar.gz"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   148
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   149
    Write-Output "installing Python 2.7 64-bit"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   150
    Invoke-Process msiexec.exe "/i ${prefix}\assets\python27-x64.msi /l* ${prefix}\assets\python27-x64.log /q TARGETDIR=${prefix}\python27-x64 ALLUSERS="
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   151
    Invoke-Process ${prefix}\python27-x64\python.exe ${prefix}\assets\get-pip.py
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   152
    Invoke-Process ${prefix}\python27-x64\Scripts\pip.exe "install ${prefix}\assets\virtualenv.tar.gz"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   153
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   154
    Install-Python3 "Python 3.5 32-bit" ${prefix}\assets\python35-x86.exe ${prefix}\python35-x86 ${pip}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   155
    Install-Python3 "Python 3.5 64-bit" ${prefix}\assets\python35-x64.exe ${prefix}\python35-x64 ${pip}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   156
    Install-Python3 "Python 3.6 32-bit" ${prefix}\assets\python36-x86.exe ${prefix}\python36-x86 ${pip}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   157
    Install-Python3 "Python 3.6 64-bit" ${prefix}\assets\python36-x64.exe ${prefix}\python36-x64 ${pip}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   158
    Install-Python3 "Python 3.7 32-bit" ${prefix}\assets\python37-x86.exe ${prefix}\python37-x86 ${pip}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   159
    Install-Python3 "Python 3.7 64-bit" ${prefix}\assets\python37-x64.exe ${prefix}\python37-x64 ${pip}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   160
    Install-Python3 "Python 3.8 32-bit" ${prefix}\assets\python38-x86.exe ${prefix}\python38-x86 ${pip}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   161
    Install-Python3 "Python 3.8 64-bit" ${prefix}\assets\python38-x64.exe ${prefix}\python38-x64 ${pip}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   162
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   163
    Write-Output "installing Visual Studio 2017 Build Tools and SDKs"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   164
    Invoke-Process ${prefix}\assets\vs_buildtools.exe "--quiet --wait --norestart --nocache --channelUri https://aka.ms/vs/15/release/channel --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Component.Windows10SDK.17763 --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.Windows10SDK --add Microsoft.VisualStudio.Component.VC.140"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   165
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   166
    Write-Output "installing Visual C++ 9.0 for Python 2.7"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   167
    Invoke-Process msiexec.exe "/i ${prefix}\assets\VCForPython27.msi /l* ${prefix}\assets\VCForPython27.log /q"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   168
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   169
    Write-Output "installing Inno Setup"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   170
    Invoke-Process ${prefix}\assets\InnoSetup.exe "/SP- /VERYSILENT /SUPPRESSMSGBOXES"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   171
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   172
    Write-Output "extracting MinGW base archive"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   173
    Expand-Archive -Path ${prefix}\assets\mingw-get-bin.zip -DestinationPath "${prefix}\MinGW" -Force
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   174
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   175
    Write-Output "updating MinGW package catalogs"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   176
    Invoke-Process ${prefix}\MinGW\bin\mingw-get.exe "update"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   177
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   178
    Write-Output "installing MinGW packages"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   179
    Invoke-Process ${prefix}\MinGW\bin\mingw-get.exe "install msys-base msys-coreutils msys-diffutils msys-unzip"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   180
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   181
    # Construct a virtualenv useful for bootstrapping. It conveniently contains a
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   182
    # Mercurial install.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   183
    Write-Output "creating bootstrap virtualenv with Mercurial"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   184
    Invoke-Process "$prefix\python27-x64\Scripts\virtualenv.exe" "${prefix}\venv-bootstrap"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   185
    Invoke-Process "${prefix}\venv-bootstrap\Scripts\pip.exe" "install ${prefix}\assets\${MERCURIAL_WHEEL_FILENAME}"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   186
}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   187
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   188
function Clone-Mercurial-Repo($prefix, $repo_url, $dest) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   189
    Write-Output "cloning $repo_url to $dest"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   190
    # TODO Figure out why CA verification isn't working in EC2 and remove
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   191
    # --insecure.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   192
    Invoke-Process "${prefix}\venv-bootstrap\Scripts\hg.exe" "clone --insecure $repo_url $dest"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   193
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   194
    # Mark repo as non-publishing by default for convenience.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   195
    Add-Content -Path "$dest\.hg\hgrc" -Value "`n[phases]`npublish = false"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   196
}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   197
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   198
$prefix = "c:\hgdev"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   199
Install-Dependencies $prefix
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   200
Clone-Mercurial-Repo $prefix "https://www.mercurial-scm.org/repo/hg" $prefix\src