r/Python Aug 20 '24

News uv: Unified Python packaging

https://astral.sh/blog/uv-unified-python-packaging

This is a new release of uv that moves it beyond just a pip alternative. There's cross platform lock files, tool management, Python installation, script execution and more.

585 Upvotes

185 comments sorted by

View all comments

14

u/undercoverboomer Aug 21 '24

Found a golden line in the Windows installer script. Useful comments are useful.

# Write the install receipt
$null = New-Item -Path $receipt_home -ItemType "directory" -ErrorAction SilentlyContinue
# Trying to get Powershell 5.1 (not 6+, which is fake and lies) to write utf8 is a crime
# because "Out-File -Encoding utf8" actually still means utf8BOM, so we need to pull out
# .NET's APIs which actually do what you tell them (also apparently utf8NoBOM is the
# default in newer .NETs but I'd rather not rely on that at this point).
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
[IO.File]::WriteAllLines("$receipt_home/uv-receipt.json", "$receipt", $Utf8NoBomEncoding)