-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage_plugin_win.ps1
More file actions
79 lines (63 loc) · 2.3 KB
/
Copy pathpackage_plugin_win.ps1
File metadata and controls
79 lines (63 loc) · 2.3 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
param(
[String]$wantedVer,
[Parameter(Mandatory = $true)]
[String]$plugin)
if ([string]::IsNullOrEmpty($plugin) -or [string]::IsNullOrWhitespace($plugin))
{
Write-Error "Pass the file name or package name of the plugin release to install, to this script";
}
Write-Host "Requested peek plugin is $plugin"
# Replace String with underscores
$pluginUnder = $plugin.Trim("/-(\d+(\.)).*/g") -replace '-', '_'
# Make Powershell stop if it has errors
$ErrorActionPreference = "Stop"
if (-Not [string]::IsNullOrEmpty($wantedVer))
{
Write-Host "Requested version is $wantedVer"
}
# Get the current location
$startDir = Get-Location
$baseDir = "$startDir\dist_win_$pluginUnder";
# Delete the existing dist dir if it exists
If (Test-Path $baseDir)
{
Remove-Item $baseDir -Force -Recurse;
}
# Create our new dist dir
New-Item $baseDir -ItemType directory;
# ------------------------------------------------------------------------------
# Download the peek platform and all it's dependencies
New-Item "$baseDir\py" -ItemType directory;
Copy-Item $plugin "$baseDir\py" -Force;
Set-Location "$baseDir\py";
Write-Host "Downloading and creating windows wheels";
pip wheel --no-cache $plugin;
# Make sure we've downloaded the right version
$peekPkgName = Get-ChildItem ".\" |
Where-Object { $_.Name.StartsWith("$pluginUnder-") } |
Select-Object -exp Name;
$peekPkgVer = $peekPkgName.Split('-')[1];
if (-Not [string]::IsNullOrEmpty($wantedVer) -and $peekPkgVer -ne $wantedVer)
{
Set-Location "$startDir";
Write-Error "We've downloaded version $peekPkgVer, but you wanted ver $wantedVer";
}
else
{
Write-Host "We've downloaded version $peekPkgVer";
}
# ------------------------------------------------------------------------------
# Set the location back to where we were.
Set-Location $startDir;
# Finally, version the directory
$releaseDir = "$( $baseDir )_$( $peekPkgVer )";
$relaseZip = "$( $releaseDir ).zip"
Move-Item $baseDir $releaseDir -Force;
# Create the zip file
Add-Type -Assembly System.IO.Compression.FileSystem;
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal;
[System.IO.Compression.ZipFile]::CreateFromDirectory(
$releaseDir, $relaseZip, $compressionLevel, $false)
# We're all done.
Write-Host "Successfully created release $peekPkgVer";
Write-Host "Located at $relaseZip";