Skip to content

Commit

Permalink
Merge pull request #60 from efiop/master
Browse files Browse the repository at this point in the history
Miniconda-based Windows installer for standalone distribution of dvc
  • Loading branch information
dmpetrov authored May 5, 2017
2 parents 85d1790 + 9afee73 commit f13b4cb
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 233 deletions.
33 changes: 28 additions & 5 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
@echo OFF
rmdir /Q /S nuitka.build
set Miniconda_dir=C:\DVC
set Miniconda_bin=Miniconda3-latest-Windows-x86_64.exe
set Miniconda_url=https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe
set Src_dir=%cd%

rmdir /Q /S %Miniconda_dir%
del /Q /S %Miniconda_bin%
del /Q /S "dvc-*.exe"
@echo This will take a while. Go get yourself a cup of tee...
call nuitka --standalone --output-dir nuitka.build dvc.py
call "C:\Program Files (x86)\Inno Setup 5\iscc" innosetup/setup.iss
rmdir /Q /S nuitka.build

call powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('%Miniconda_url%','%Miniconda_bin%')

REM NOTE: This is extremely important, that we use same directory that we will install dvc into.
REM The reason is that dvc.exe will have hardcoded path to python interpreter and thus we need
REM to make sure that it is the same everywhere(C:\DVC).
call .\%Miniconda_bin% /InstallationType=JustMe /RegisterPython=0 /S /D=%Miniconda_dir%

copy innosetup\addSymLinkPermissions.ps1 %Miniconda_dir%\

pushd %Miniconda_dir%
call .\python -m pip install -r %Src_dir%\requirements.txt
popd

call %Miniconda_dir%\python setup.py sdist

pushd %Miniconda_dir%
call .\python -m pip install %Src_dir%\dist\dvc-0.8.1.tar.gz
popd

call "C:\Program Files (x86)\Inno Setup 5\iscc" innosetup\setup.iss
4 changes: 4 additions & 0 deletions dvc/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from dvc.main import main

if __name__ == '__main__':
main()
62 changes: 62 additions & 0 deletions innosetup/addSymLinkPermissions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function addSymLinkPermissions($accountToAdd){
Write-Host "Checking SymLink permissions.."
$sidstr = $null
try {
$ntprincipal = new-object System.Security.Principal.NTAccount "$accountToAdd"
$sid = $ntprincipal.Translate([System.Security.Principal.SecurityIdentifier])
$sidstr = $sid.Value.ToString()
} catch {
$sidstr = $null
}
Write-Host "Account: $($accountToAdd)" -ForegroundColor DarkCyan
if( [string]::IsNullOrEmpty($sidstr) ) {
Write-Host "Account not found!" -ForegroundColor Red
exit -1
}
Write-Host "Account SID: $($sidstr)" -ForegroundColor DarkCyan
$tmp = [System.IO.Path]::GetTempFileName()
Write-Host "Export current Local Security Policy" -ForegroundColor DarkCyan
secedit.exe /export /cfg "$($tmp)"
$c = Get-Content -Path $tmp
$currentSetting = ""
foreach($s in $c) {
if( $s -like "SECreateSymbolicLinkPrivilege*") {
$x = $s.split("=",[System.StringSplitOptions]::RemoveEmptyEntries)
$currentSetting = $x[1].Trim()
}
}
if( $currentSetting -notlike "*$($sidstr)*" ) {
Write-Host "Need to add permissions to SymLink" -ForegroundColor Yellow

Write-Host "Modify Setting ""Create SymLink""" -ForegroundColor DarkCyan

if( [string]::IsNullOrEmpty($currentSetting) ) {
$currentSetting = "*$($sidstr)"
} else {
$currentSetting = "*$($sidstr),$($currentSetting)"
}
Write-Host "$currentSetting"
$outfile = @"
[Unicode]
Unicode=yes
[Version]
signature="`$CHICAGO`$"
Revision=1
[Privilege Rights]
SECreateSymbolicLinkPrivilege = $($currentSetting)
"@
$tmp2 = [System.IO.Path]::GetTempFileName()
Write-Host "Import new settings to Local Security Policy" -ForegroundColor DarkCyan
$outfile | Set-Content -Path $tmp2 -Encoding Unicode -Force
Push-Location (Split-Path $tmp2)
try {
secedit.exe /configure /db "secedit.sdb" /cfg "$($tmp2)" /areas USER_RIGHTS
} finally {
Pop-Location
}
} else {
Write-Host "NO ACTIONS REQUIRED! Account already in ""Create SymLink""" -ForegroundColor DarkCyan
Write-Host "Account $accountToAdd already has permissions to SymLink" -ForegroundColor Green
return $true;
}
}
219 changes: 0 additions & 219 deletions innosetup/modpath.iss

This file was deleted.

Loading

0 comments on commit f13b4cb

Please sign in to comment.