Skip to content

Commit 13dcbc8

Browse files
authored
Patch py2docfx CI release failure (#45242)
1 parent c611172 commit 13dcbc8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

eng/scripts/docs/Docs-Onboarding.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ function Validate-Python-DocMsPackages($PackageInfo, $PackageInfos, $PackageSour
153153
$pipFreezeOutput | ForEach-Object { Write-Host $_ }
154154
Write-Host "`n"
155155

156+
# Workaround: py2docfx creates internal venvs and runs `pip install --upgrade setuptools`
157+
# (unpinned). setuptools 81+ removed the --dry-run flag from setup.py, which py2docfx uses
158+
# to extract package metadata. Constrain setuptools<81 via PIP_CONSTRAINT so it propagates
159+
# into py2docfx's internal pip calls. This can be removed once py2docfx releases a stable
160+
# version with the fix (see dev build 0.1.23.dev2415137).
161+
$constraintFile = Join-Path ([System.IO.Path]::GetTempPath()) "pip-constraints.txt"
162+
"setuptools<81" | Out-File -Encoding utf8 $constraintFile
163+
$originalPipConstraint = $env:PIP_CONSTRAINT
164+
$env:PIP_CONSTRAINT = $constraintFile
165+
Write-Host "Set PIP_CONSTRAINT=$constraintFile (setuptools<81) to work around py2docfx/setuptools incompatibility"
166+
156167
$tempDirs = @()
157168
$allSucceeded = $true
158169
try {
@@ -205,6 +216,15 @@ function Validate-Python-DocMsPackages($PackageInfo, $PackageInfos, $PackageSour
205216
{
206217
Remove-Item -Force -Recurse $tempDir | Out-Null
207218
}
219+
# Workaround: Restore original PIP_CONSTRAINT
220+
if ($originalPipConstraint) {
221+
$env:PIP_CONSTRAINT = $originalPipConstraint
222+
} else {
223+
Remove-Item Env:\PIP_CONSTRAINT -ErrorAction SilentlyContinue
224+
}
225+
if (Test-Path $constraintFile) {
226+
Remove-Item $constraintFile -ErrorAction SilentlyContinue
227+
}
208228
}
209229
return $allSucceeded
210230
}

0 commit comments

Comments
 (0)