-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathdeploy_pip.ps1
More file actions
51 lines (43 loc) · 1.63 KB
/
deploy_pip.ps1
File metadata and controls
51 lines (43 loc) · 1.63 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
# Define the paths
$buildDir = "my_build"
$sourceDir = "ok"
$rootBuildDir = "build"
$originalLocation = Get-Location
try {
# Remove the build directory if it exists
if (Test-Path -Path $buildDir) {
Remove-Item -Path $buildDir -Recurse -Force
Write-Output "Removed existing directory: $buildDir"
}
# Create the build directory
New-Item -Path $buildDir -ItemType "Directory"
Write-Output "Created new directory: $buildDir"
# Copy the contents of the source directory to the build directory
Copy-Item -Path "$sourceDir" -Destination $buildDir -Recurse
Write-Output "Copied contents from $sourceDir to $buildDir"
# Copy additional files
Copy-Item -Path "setup.py" -Destination $buildDir -Recurse
Copy-Item -Path "get_pypi_latest_version.py" -Destination $buildDir -Recurse
Copy-Item -Path "MANIFEST.in" -Destination $buildDir -Recurse
Copy-Item -Path "README.md" -Destination $buildDir -Recurse
# Change directory to the build directory
Set-Location $buildDir
python setup.py sdist bdist_wheel
if ($LASTEXITCODE -ne 0) {
throw "python setup.py sdist bdist_wheel failed with exit code $LASTEXITCODE"
}
twine upload dist/*
if ($LASTEXITCODE -ne 0) {
throw "twine upload failed with exit code $LASTEXITCODE"
}
}
finally {
Set-Location $originalLocation
foreach ($dir in @($rootBuildDir, $buildDir)) {
$resolved = Resolve-Path -LiteralPath $dir -ErrorAction SilentlyContinue
if ($resolved) {
Remove-Item -LiteralPath $resolved.Path -Recurse -Force
Write-Output "Removed directory: $dir"
}
}
}