Skip to content

Instantly share code, notes, and snippets.

@JeffJacobson
Created November 6, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffJacobson/ebc93510e0f6ff398f46ed91c0ae2e5a to your computer and use it in GitHub Desktop.
Save JeffJacobson/ebc93510e0f6ff398f46ed91c0ae2e5a to your computer and use it in GitHub Desktop.
Utility for generating an index for pip
<#
.SYNOPSIS
Creates an index HTML page listing Python packages in the current directory.
.DESCRIPTION
Creates an index HTML page listing Python packages in the current directory.
.EXAMPLE
PS C:\> .\New-Index.ps1
Creates the index file and saves it to index.html
.INPUTS
Inputs (if any)
.OUTPUTS
HTML markup with links to Python package files.
.NOTES
This will allow pip to install from this directory.
.EXAMPLE
pip install --find-links=G:\GIS_Branch\GIS_Dev\DevelopmentTeam\Packages\Python SomePackage --user
#>
$currentDir = Get-Location
$file = [System.IO.Path]::Combine($currentDir, "index.html")
Out-File $file -Encoding utf8 -InputObject "<html><body><ul>"
$paths = Get-ChildItem -Recurse -Include @("*.whl","*.tar.gz") | ForEach-Object { (Resolve-Path -Relative $_).Replace('\', '/') }
foreach ($p in $paths) {
Out-File $file -Append -Encoding utf8 -InputObject "<li><a href='$p'>$p</a></li>"
}
Out-File $file -Append -Encoding utf8 -InputObject "</ul></body></html>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment