forked from microsoft/azure-quantum-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.ps1
62 lines (50 loc) · 2.08 KB
/
bootstrap.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
<#
.SYNOPSIS
Bootstrap: set up a Python environment using Anaconda using the corresponding
environment.yml file. Install the specified package in the environment,
either from Source or from PyPI. Takes optional input arguments PackageName,
CondaEnvironmentSuffix and FromSource:
If no PackageName is specified, this script searches the root directory and runs
bootstrap for all packages.
The CondaEnvironmentSuffix is used to find an alternate environment yml, for
instance environment<CondaEnvironmentSuffix>.yml.
FromWheel determines if the package is installed from a wheel on PyPI (if True)
or from source using <pip install -e> (if False) and defaults to False.
#>
param(
[string] $PackageName,
[string] $CondaEnvironmentSuffix,
[bool] $FromWheel
)
if ($False -eq $FromWheel) {
$FromSource = $True;
} else {
$FromSource = $False;
}
Write-Host $FromSource;
# Set env vars
& (Join-Path $PSScriptRoot "build" "set-env.ps1");
# Import Conda utils
Import-Module (Join-Path $PSScriptRoot "build" "package-utils.psm1");
# Enable conda hook
Enable-Conda
# Create environment
New-CondaEnvironment -PackageName $PackageName -CondaEnvironmentSuffix $CondaEnvironmentSuffix
# Install package in environment
Install-PackageInEnv -PackageName $PackageName -CondaEnvironmentSuffix $CondaEnvironmentSuffix -FromSource $FromSource
# Try installing IQ# dotnet tool, IQ# kernel and the qsharp Python package
# Used for running tests between the Azure Quantum Python SDK and IQ# (Q#+QIR job submission)
if ([string]::IsNullOrEmpty($PackageName) -or ($PackageName -eq "azure-quantum")) {
try {
$EnvExists = conda env list | Select-String -Pattern "azurequantum " | Measure-Object | Select-Object -Exp Count
if ($EnvExists) {
conda activate azurequantum
& (Join-Path $PSScriptRoot "build" "install-iqsharp.ps1");
}
}
catch {
Write-Host "##[warning]Failed to install IQ#."
}
}