Skip to content

Commit 00f7455

Browse files
authored
update the package namespaces for all packages in the artifact directory (Azure#37198)
* update the package namespaces for all packages in the artifact directory
1 parent 84734d8 commit 00f7455

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

eng/pipelines/templates/steps/build-extended-artifacts.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ steps:
8484
filePath: $(Build.SourcesDirectory)/eng/scripts/Save-Package-Namespaces-Property.ps1
8585
arguments: >
8686
-ArtifactStagingDirectory "$(Build.ArtifactStagingDirectory)"
87-
-ArtifactsList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json)
8887
pwsh: true
8988
workingDirectory: $(Pipeline.Workspace)
9089
displayName: Update package properties with namespaces

eng/scripts/Save-Package-Namespaces-Property.ps1

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,37 @@ The root directory of the staged artifacts. The PackageInfo files will be in the
1414
PackageInfo subdirectory. The whl files are going to be in the subdirectory which
1515
is the same as the artifact's name but artifact name in the file's name will have
1616
underscores instead of dashes.
17-
18-
.PARAMETER ArtifactsList
19-
The list of artifacts to gather namespaces for, this is only done for libraries that are
20-
producing docs.
21-
-ArtifactsList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json)
2217
#>
2318
[CmdletBinding()]
2419
Param (
2520
[Parameter(Mandatory = $True)]
26-
[string] $ArtifactStagingDirectory,
27-
[Parameter(Mandatory=$true)]
28-
[array] $ArtifactsList
21+
[string] $ArtifactStagingDirectory
2922
)
3023

3124
$ArtifactsList = $ArtifactsList | Where-Object -Not "skipPublishDocMs"
3225

3326
. (Join-Path $PSScriptRoot ".." common scripts common.ps1)
3427

35-
if (-not $ArtifactsList) {
36-
Write-Host "ArtifactsList is empty, nothing to process. This can happen if skipPublishDocMs is set to true for all libraries being built."
37-
exit 0
38-
}
39-
4028
Write-Host "ArtifactStagingDirectory=$ArtifactStagingDirectory"
4129
if (-not (Test-Path -Path $ArtifactStagingDirectory)) {
4230
LogError "ArtifactStagingDirectory '$ArtifactStagingDirectory' does not exist."
4331
exit 1
4432
}
4533

46-
Write-Host ""
47-
Write-Host "ArtifactsList:"
48-
$ArtifactsList | Format-Table -Property Name | Out-String | Write-Host
49-
5034
$packageInfoDirectory = Join-Path $ArtifactStagingDirectory "PackageInfo"
51-
5235
$foundError = $false
53-
# At this point the packageInfo files should have been already been created.
54-
# The only thing being done here is adding or updating namespaces for libraries
55-
# that will be producing docs.
56-
foreach($artifact in $ArtifactsList) {
36+
$artifacts = Get-ChildItem -Path $packageInfoDirectory -File -Filter "*.json"
37+
$artifacts | Format-Table -Property Name | Out-String | Write-Host
38+
39+
if (-not $artifacts) {
40+
Write-Host "Zero artifacts were discovered, nothing to process. This can happen if skipPublishDocMs is set to true for all libraries being built."
41+
exit 0
42+
}
43+
44+
# by this point, the PackageInfo folder will have a json file for each artifact
45+
# we simply need to read each file, get the appropriate metadata, and add the namespaces if necessary
46+
foreach($packageInfoFile in $artifacts) {
5747
# Get the version from the packageInfo file
58-
$packageInfoFile = Join-Path $packageInfoDirectory "$($artifact.Name).json"
5948
Write-Host "processing $($packageInfoFile.FullName)"
6049
$packageInfo = ConvertFrom-Json (Get-Content $packageInfoFile -Raw)
6150
$version = $packageInfo.Version
@@ -69,8 +58,7 @@ foreach($artifact in $ArtifactsList) {
6958
$WhlFile = Get-ChildItem -Path $WhlDir -File -Filter "$whlName-$version*.whl"
7059

7160
if (!(Test-Path $WhlFile -PathType Leaf)) {
72-
LogError "Whl file for, $($packageInfo.Name), was not found in $WhlDir. Please ensure that a .whl file is being produced for the library."
73-
$foundError = $true
61+
Write-Host "Whl file for, $($packageInfo.Name), was not found in $WhlDir. Unable to update package namespaces."
7462
continue
7563
}
7664
$namespaces = Get-NamespacesFromWhlFile $packageInfo.Name $version -PythonWhlFile $WhlFile

0 commit comments

Comments
 (0)