Skip to content

Commit

Permalink
ci: move from distutils to setuptools
Browse files Browse the repository at this point in the history
Since `distutils` is removed from the standard library in Python 3.12,
we need to switch to using the vendored version of `distutils` found in
`setuptools._distutils`.

Also, we make sure `setuptools` and friends are upgraded before patching
and separate this from the library installation.
  • Loading branch information
janden committed Dec 19, 2023
1 parent bf97a69 commit d5852bd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/python_build_win.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ Add-Content -Path make.inc -Value "FFLAGS+= -fallow-argument-mismatch -march=x86
Add-Content -Path make.inc -Value "CFLAGS+= -march=x86-64"
Add-Content -Path make.inc -Value "CXXFLAGS+= -march=x86-64"

Set-Variable libvcruntime140_a -Value ([IO.Path]::Combine((Split-Path -Path $PYTHON), "libs", 'libvcruntime140.a'))
Copy-Item -Path .\.github\workflows\libvcruntime140.a -Destination $libvcruntime140_a

python -m pip install --upgrade setuptools wheel numpy pip
if (-not $?) {throw "Failed pip install"}

# mingw gcc compiler pacth to work with python
Set-Variable cygwinccompiler_py -Value ([IO.Path]::Combine((Split-Path -Path $PYTHON), "Lib", 'distutils', 'cygwinccompiler.py'))
Set-Variable cygwinccompiler_py -Value ([IO.Path]::Combine((Split-Path -Path $PYTHON), "lib", "site-packages", "setuptools", "_distutils", "cygwinccompiler.py"))
Remove-Item -Path $cygwinccompiler_py -Force
Copy-Item -Path .\.github\workflows\cygwinccompiler.py -Destination $cygwinccompiler_py
Set-Variable libvcruntime140_a -Value ([IO.Path]::Combine((Split-Path -Path $PYTHON), "libs", 'libvcruntime140.a'))
Copy-Item -Path .\.github\workflows\libvcruntime140.a -Destination $libvcruntime140_a

# Setup the distutils.cfg file
Set-Variable distutils_cfg -Value ([IO.Path]::Combine((Split-Path -Path $PYTHON), "Lib", 'distutils', 'distutils.cfg'))
Set-Variable distutils_cfg -Value ([IO.Path]::Combine((Split-Path -Path $PYTHON), "lib", "site-packages", "setuptools", "_distutils", "distutils.cfg"))
Set-Content -Path $distutils_cfg -Value "[build]`r`ncompiler=mingw32`r`n[build_ext]`r`ncompiler=mingw32"
python -m pip install --upgrade setuptools wheel numpy pip
if (-not $?) {throw "Failed pip install"}

# call make
Set-Variable repo_root -Value ([IO.Path]::Combine($PSScriptRoot, '..', '..'))
Expand Down

0 comments on commit d5852bd

Please sign in to comment.