forked from microsoft/azure-quantum-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.ps1
37 lines (30 loc) · 1.19 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
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
<#
.SYNOPSIS
Bootstrap: set up a Python environment using Anaconda
#>
param(
[string[]] $PackageDirs
)
& (Join-Path $PSScriptRoot "build" "set-env.ps1");
Import-Module (Join-Path $PSScriptRoot "build" "conda-utils.psm1");
# Enable conda hook
Enable-Conda
# Get default value for PackageDirs by searching for environment.yml files
if ($null -eq $PackageDirs) {
$PackageDirs = Get-ChildItem -Path $PSScriptRoot -Recurse -Filter "environment.yml" | Select-Object -ExpandProperty Directory | Split-Path -Leaf
Write-Host "##[info]No PackageDir. Setting to default '$PackageDirs'"
}
foreach ($PackageDir in $PackageDirs) {
# Check if environment already exists
$EnvName = $PackageDir.replace("-", "")
$EnvExists = conda env list | Select-String -Pattern "$EnvName " | Measure-Object | Select-Object -Exp Count
# if it exists, skip creation
if ($EnvExists -eq "1") {
Write-Host "##[info]Skipping creating $EnvName; env already exists."
} else {
# if it doese not exist, create env
& (Join-Path $PSScriptRoot build create-env.ps1) -PackageDirs $PackageDir
}
}