contrib/install-windows-dependencies.ps1
author Pierre-Yves David <pierre-yves.david@octobus.net>
Fri, 16 Apr 2021 02:14:21 +0200
changeset 47188 353718f741a8
parent 46353 a6c5ec6b4728
child 47198 e768294a7182
permissions -rw-r--r--
bookmark: use `list_paths` to access path definition The content of the `[paths]` config section is receiving transformation that make it hard to recognise whats the actual name, and the next changeset will make it worse. So we use the official API for this instead. Differential Revision: https://phab.mercurial-scm.org/D10448
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
44740
fdf783da84bd contrib: update to latest Python 2.7, 3.7, and 3.8
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43314
diff changeset
    25
$PYTHON27_x64_URL = "https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi"
fdf783da84bd contrib: update to latest Python 2.7, 3.7, and 3.8
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43314
diff changeset
    26
$PYTHON27_x64_SHA256 = "b74a3afa1e0bf2a6fc566a7b70d15c9bfabba3756fb077797d16fffa27800c05"
fdf783da84bd contrib: update to latest Python 2.7, 3.7, and 3.8
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43314
diff changeset
    27
$PYTHON27_X86_URL = "https://www.python.org/ftp/python/2.7.18/python-2.7.18.msi"
fdf783da84bd contrib: update to latest Python 2.7, 3.7, and 3.8
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43314
diff changeset
    28
$PYTHON27_X86_SHA256 = "d901802e90026e9bad76b8a81f8dd7e43c7d7e8269d9281c9e9df7a9c40480a9"
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    29
45642
56281b75264a contrib: install latest versions of Python
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44760
diff changeset
    30
$PYTHON37_x86_URL = "https://www.python.org/ftp/python/3.7.9/python-3.7.9.exe"
56281b75264a contrib: install latest versions of Python
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44760
diff changeset
    31
$PYTHON37_x86_SHA256 = "769bb7c74ad1df6d7d74071cc16a984ff6182e4016e11b8949b93db487977220"
56281b75264a contrib: install latest versions of Python
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44760
diff changeset
    32
$PYTHON37_X64_URL = "https://www.python.org/ftp/python/3.7.9/python-3.7.9-amd64.exe"
56281b75264a contrib: install latest versions of Python
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44760
diff changeset
    33
$PYTHON37_x64_SHA256 = "e69ed52afb5a722e5c56f6c21d594e85c17cb29f12f18bb69751cf1714e0f987"
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
45642
56281b75264a contrib: install latest versions of Python
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44760
diff changeset
    35
$PYTHON38_x86_URL = "https://www.python.org/ftp/python/3.8.6/python-3.8.6.exe"
56281b75264a contrib: install latest versions of Python
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44760
diff changeset
    36
$PYTHON38_x86_SHA256 = "287d5df01ff22ff09e6a487ae018603ee19eade71d462ec703850c96f1d5e8a0"
56281b75264a contrib: install latest versions of Python
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44760
diff changeset
    37
$PYTHON38_x64_URL = "https://www.python.org/ftp/python/3.8.6/python-3.8.6-amd64.exe"
56281b75264a contrib: install latest versions of Python
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44760
diff changeset
    38
$PYTHON38_x64_SHA256 = "328a257f189cb500606bb26ab0fbdd298ed0e05d8c36540a322a1744f489a0a0"
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    39
45690
7a907388a4a5 contrib: install Python 3.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45689
diff changeset
    40
$PYTHON39_x86_URL = "https://www.python.org/ftp/python/3.9.0/python-3.9.0.exe"
7a907388a4a5 contrib: install Python 3.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45689
diff changeset
    41
$PYTHON39_x86_SHA256 = "a4c65917f4225d1543959342f0615c813a4e9e7ff1137c4394ff6a5290ac1913"
7a907388a4a5 contrib: install Python 3.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45689
diff changeset
    42
$PYTHON39_x64_URL = "https://www.python.org/ftp/python/3.9.0/python-3.9.0-amd64.exe"
7a907388a4a5 contrib: install Python 3.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45689
diff changeset
    43
$PYTHON39_x64_SHA256 = "fd2e2c6612d43bb6b213b72fc53f07d73d99059fa72c96e44bde12e7815073ae"
7a907388a4a5 contrib: install Python 3.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45689
diff changeset
    44
43215
c157356c03f7 contrib: update to latest Windows package versions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42649
diff changeset
    45
# PIP 19.2.3.
c157356c03f7 contrib: update to latest Windows package versions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42649
diff changeset
    46
$PIP_URL = "https://github.com/pypa/get-pip/raw/309a56c5fd94bd1134053a541cb4657a4e47e09d/get-pip.py"
c157356c03f7 contrib: update to latest Windows package versions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42649
diff changeset
    47
$PIP_SHA256 = "57e3643ff19f018f8a00dfaa6b7e4620e3c1a7a2171fd218425366ec006b3bfe"
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    48
43215
c157356c03f7 contrib: update to latest Windows package versions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42649
diff changeset
    49
$VIRTUALENV_URL = "https://files.pythonhosted.org/packages/66/f0/6867af06d2e2f511e4e1d7094ff663acdebc4f15d4a0cb0fed1007395124/virtualenv-16.7.5.tar.gz"
c157356c03f7 contrib: update to latest Windows package versions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42649
diff changeset
    50
$VIRTUALENV_SHA256 = "f78d81b62d3147396ac33fc9d77579ddc42cc2a98dd9ea38886f616b33bc7fb2"
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    51
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    52
$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
    53
$INNO_SETUP_SHA256 = "27D49E9BC769E9D1B214C153011978DB90DC01C2ACD1DDCD9ED7B3FE3B96B538"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    54
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    55
$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
    56
$MINGW_BIN_SHA256 = "2AB8EFD7C7D1FC8EAF8B2FA4DA4EEF8F3E47768284C021599BC7435839A046DF"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    57
43215
c157356c03f7 contrib: update to latest Windows package versions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42649
diff changeset
    58
$MERCURIAL_WHEEL_FILENAME = "mercurial-5.1.2-cp27-cp27m-win_amd64.whl"
c157356c03f7 contrib: update to latest Windows package versions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42649
diff changeset
    59
$MERCURIAL_WHEEL_URL = "https://files.pythonhosted.org/packages/6d/47/e031e47f7fe9b16e4e3383da47e2b0a7eae6e603996bc67a03ec4fa1b3f4/$MERCURIAL_WHEEL_FILENAME"
c157356c03f7 contrib: update to latest Windows package versions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42649
diff changeset
    60
$MERCURIAL_WHEEL_SHA256 = "1d18c7f6ca1456f0f62ee65c9a50c14cbba48ce6e924930cdb10537f5c9eaf5f"
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    61
44760
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
    62
$RUSTUP_INIT_URL = "https://static.rust-lang.org/rustup/archive/1.21.1/x86_64-pc-windows-gnu/rustup-init.exe"
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
    63
$RUSTUP_INIT_SHA256 = "d17df34ba974b9b19cf5c75883a95475aa22ddc364591d75d174090d55711c72"
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
    64
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    65
# 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
    66
$progressPreference = 'silentlyContinue'
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    67
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    68
function Secure-Download($url, $path, $sha256) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    69
    if (Test-Path -Path $path) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    70
        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
    71
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    72
        if ($hash.Hash -eq $sha256) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    73
            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
    74
            return
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    75
        }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    76
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    77
        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
    78
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    79
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    80
    Write-Output "downloading $url to $path"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    81
    Invoke-WebRequest -Uri $url -OutFile $path
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    82
    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
    83
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    84
    if ($hash.Hash -ne $sha256) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    85
        Remove-Item -Path $path
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    86
        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
    87
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    88
}
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
function Invoke-Process($path, $arguments) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
    $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
    92
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    93
    if ($p.ExitCode -ne 0) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    94
        throw "process exited non-0: $($p.ExitCode)"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    95
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    96
}
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
function Install-Python3($name, $installer, $dest, $pip) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    99
    Write-Output "installing $name"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   100
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   101
    # 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
   102
    # 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
   103
    # 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
   104
    # this mode.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   105
    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
   106
        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
   107
        $allusers = "1"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   108
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   109
    else {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   110
        $allusers = "0"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   111
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   112
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   113
    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
   114
    Invoke-Process ${dest}\python.exe $pip
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   115
}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   116
44760
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   117
function Install-Rust($prefix) {
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   118
    Write-Output "installing Rust"
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   119
    $Env:RUSTUP_HOME = "${prefix}\rustup"
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   120
    $Env:CARGO_HOME = "${prefix}\cargo"
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   121
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   122
    Invoke-Process "${prefix}\assets\rustup-init.exe" "-y --default-host x86_64-pc-windows-msvc"
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   123
    Invoke-Process "${prefix}\cargo\bin\rustup.exe" "target add i686-pc-windows-msvc"
45643
6a36e2d2011f contrib: install Rust 1.46.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45642
diff changeset
   124
    Invoke-Process "${prefix}\cargo\bin\rustup.exe" "install 1.46.0"
44760
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   125
    Invoke-Process "${prefix}\cargo\bin\rustup.exe" "component add clippy"
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   126
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   127
    # Install PyOxidizer for packaging.
46353
a6c5ec6b4728 contrib: update PyOxidizer to 0.10.3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45749
diff changeset
   128
    Invoke-Process "${prefix}\cargo\bin\cargo.exe" "install --version 0.10.3 pyoxidizer"
44760
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   129
}
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   130
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   131
function Install-Dependencies($prefix) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   132
    if (!(Test-Path -Path $prefix\assets)) {
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   133
        New-Item -Path $prefix\assets -ItemType Directory
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   134
    }
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   135
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   136
    $pip = "${prefix}\assets\get-pip.py"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   137
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   138
    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
   139
    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
   140
    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
   141
    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
   142
    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
   143
    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
   144
    Secure-Download $PYTHON38_x64_URL ${prefix}\assets\python38-x64.exe $PYTHON38_x64_SHA256
45690
7a907388a4a5 contrib: install Python 3.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45689
diff changeset
   145
    Secure-Download $PYTHON39_x86_URL ${prefix}\assets\python39-x86.exe $PYTHON39_x86_SHA256
7a907388a4a5 contrib: install Python 3.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45689
diff changeset
   146
    Secure-Download $PYTHON39_x64_URL ${prefix}\assets\python39-x64.exe $PYTHON39_x64_SHA256
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   147
    Secure-Download $PIP_URL ${pip} $PIP_SHA256
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   148
    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
   149
    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
   150
    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
   151
    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
   152
    Secure-Download $MERCURIAL_WHEEL_URL ${prefix}\assets\${MERCURIAL_WHEEL_FILENAME} $MERCURIAL_WHEEL_SHA256
44760
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   153
    Secure-Download $RUSTUP_INIT_URL ${prefix}\assets\rustup-init.exe $RUSTUP_INIT_SHA256
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   154
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   155
    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
   156
    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
   157
    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
   158
    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
   159
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   160
    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
   161
    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
   162
    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
   163
    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
   164
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   165
    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
   166
    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
   167
    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
   168
    Install-Python3 "Python 3.8 64-bit" ${prefix}\assets\python38-x64.exe ${prefix}\python38-x64 ${pip}
45690
7a907388a4a5 contrib: install Python 3.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45689
diff changeset
   169
    Install-Python3 "Python 3.9 32-bit" ${prefix}\assets\python39-x86.exe ${prefix}\python39-x86 ${pip}
7a907388a4a5 contrib: install Python 3.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45689
diff changeset
   170
    Install-Python3 "Python 3.9 64-bit" ${prefix}\assets\python39-x64.exe ${prefix}\python39-x64 ${pip}
42023
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 "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
   173
    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
   174
44760
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   175
    Install-Rust ${prefix}
6a6c15cea1fa contrib: install PyOxidizer in Linux and Windows environments
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44740
diff changeset
   176
42023
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   177
    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
   178
    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
   179
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   180
    Write-Output "installing Inno Setup"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   181
    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
   182
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   183
    Write-Output "extracting MinGW base archive"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   184
    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
   185
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   186
    Write-Output "updating MinGW package catalogs"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   187
    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
   188
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   189
    Write-Output "installing MinGW packages"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   190
    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
   191
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   192
    # 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
   193
    # Mercurial install.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   194
    Write-Output "creating bootstrap virtualenv with Mercurial"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   195
    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
   196
    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
   197
}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   198
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   199
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
   200
    Write-Output "cloning $repo_url to $dest"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   201
    # 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
   202
    # --insecure.
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   203
    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
   204
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   205
    # 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
   206
    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
   207
}
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   208
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   209
$prefix = "c:\hgdev"
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   210
Install-Dependencies $prefix
bf87d34a675c contrib: PowerShell script to install development dependencies
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   211
Clone-Mercurial-Repo $prefix "https://www.mercurial-scm.org/repo/hg" $prefix\src