Skip to content

Instantly share code, notes, and snippets.

@lamchau
Created February 14, 2016 20:45
Show Gist options
  • Save lamchau/8c70dc2a0a0d24746dbd to your computer and use it in GitHub Desktop.
Save lamchau/8c70dc2a0a0d24746dbd 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