Created
November 6, 2017 21:40
-
-
Save JeffJacobson/ebc93510e0f6ff398f46ed91c0ae2e5a to your computer and use it in GitHub Desktop.
Utility for generating an index for pip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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