Skip to content

Instantly share code, notes, and snippets.

@lamchau
Created April 12, 2016 01:55
Show Gist options
  • Save lamchau/e6e02c2a88324d0fe0d969172585eeed to your computer and use it in GitHub Desktop.
Save lamchau/e6e02c2a88324d0fe0d969172585eeed to your computer and use it in GitHub Desktop.
$pip_file = "requirements.txt"
try {
pip freeze > $pip_file
# PowerShell creates UTF16 LE with Windows line endings so we must convert
# for pip to consume
# http://stackoverflow.com/questions/8852682/convert-file-from-windows-to-unix-through-powershell-or-batch
Get-ChildItem $pip_file | ForEach-Object {
$contents = [IO.File]::ReadAllText($_) -replace "`r`n?", "`n"
$utf8 = New-Object System.Text.UTF8Encoding $false
[IO.File]::WriteAllText($_, $contents, $utf8)
}
Write-Output "Created '$pip_file'"
} catch {
Remove-Item $pip_file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment