diff --git a/configure.py b/configure.py index 27df9d30..608b22a8 100644 --- a/configure.py +++ b/configure.py @@ -129,33 +129,42 @@ def clean(): safe_remove(os.path.join("SuperBuild", "install")) def dist(): + # Download VC++ runtime + vcredist_path = os.path.join("SuperBuild", "download", "vc_redist.x64.exe") + if not os.path.isfile(vcredist_path): + vcredist_url = "https://aka.ms/vs/16/release/vc_redist.x64.exe" + print("Downloading %s" % vcredist_url) + with urllib.request.urlopen(vcredist_url) as response, open(vcredist_path, 'wb') as out_file: + shutil.copyfileobj(response, out_file) + # Download portable python - is not os.path.isdir("python38"): + if not os.path.isdir("python38"): + pythonzip_path = os.path.join("SuperBuild", "download", "python38.zip") python_url = "https://github.com/OpenDroneMap/windows-deps/releases/download/2.5.0/python-3.8.1-embed-amd64-less-pth.zip" - if not os.path.exists("python38.zip"): + if not os.path.exists(pythonzip_path): print("Downloading %s" % python_url) - with urllib.request.urlopen(python_url) as response, open( "python38.zip", 'wb') as out_file: + with urllib.request.urlopen(python_url) as response, open( pythonzip_path, 'wb') as out_file: shutil.copyfileobj(response, out_file) os.mkdir("python38") - print("Extracting python38.zip --> python38/") - with zipfile.ZipFile("python38.zip") as z: + print("Extracting --> python38/") + with zipfile.ZipFile(pythonzip_path) as z: z.extractall("python38") - # Download innosetup if not os.path.isdir("innosetup"): + innosetupzip_path = os.path.join("SuperBuild", "download", "innosetup.zip") innosetup_url = "https://github.com/OpenDroneMap/windows-deps/releases/download/2.5.0/innosetup-portable-win32-6.0.5-3.zip" - if not os.path.exists("innosetup.zip"): + if not os.path.exists(innosetupzip_path): print("Downloading %s" % innosetup_url) - with urllib.request.urlopen(innosetup_url) as response, open( "innosetup.zip", 'wb') as out_file: + with urllib.request.urlopen(innosetup_url) as response, open(innosetupzip_path, 'wb') as out_file: shutil.copyfileobj(response, out_file) os.mkdir("innosetup") - print("Extracting innosetup.zip --> innosetup/") - with zipfile.ZipFile("innosetup.zip") as z: + print("Extracting --> innosetup/") + with zipfile.ZipFile(innosetupzip_path) as z: z.extractall("innosetup") # Run diff --git a/innosetup.iss b/innosetup.iss index 7945e707..6b2ca6e5 100644 --- a/innosetup.iss +++ b/innosetup.iss @@ -43,7 +43,7 @@ Source: "licenses\*"; DestDir: "{app}\licenses"; Flags: ignoreversion recursesub Source: "opendm\*"; DestDir: "{app}\opendm"; Excludes: "__pycache__"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "stages\*"; DestDir: "{app}\stages"; Excludes: "__pycache__"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "SuperBuild\install\bin\*"; DestDir: "{app}\SuperBuild\install\bin"; Excludes: "__pycache__"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "venv\*"; DestDir: "{app}\venv"; Excludes: "__pycache__"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "venv\*"; DestDir: "{app}\venv"; Excludes: "__pycache__,pyvenv.cfg"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "python38\*"; DestDir: "{app}\python38"; Excludes: "__pycache__"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "console.bat"; DestDir: "{app}"; Flags: ignoreversion Source: "VERSION"; DestDir: "{app}"; Flags: ignoreversion @@ -53,6 +53,7 @@ Source: "run.py"; DestDir: "{app}"; Flags: ignoreversion Source: "settings.yaml"; DestDir: "{app}"; Flags: ignoreversion Source: "win32env.bat"; DestDir: "{app}"; Flags: ignoreversion Source: "winrun.bat"; DestDir: "{app}"; Flags: ignoreversion +Source: "SuperBuild\download\vc_redist.x64.exe"; DestDir: {tmp}; Flags: dontcopy [Icons] Name: {group}\ODM Console; Filename: "{app}\console.bat"; WorkingDir: "{app}" @@ -62,4 +63,28 @@ Name: "{userdesktop}\ODM Console"; Filename: "{app}\console.bat"; WorkingDir: "{ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Run] -Filename: {app}\console; Description: {cm:LaunchProgram,ODM Console}; Flags: nowait postinstall skipifsilent \ No newline at end of file +Filename: "{tmp}\vc_redist.x64.exe"; StatusMsg: "Installing Visual C++ Redistributable Packages for Visual Studio 2019"; Parameters: "/quiet"; Check: VC2019RedistNeedsInstall ; Flags: waituntilterminated +Filename: "{app}\console.bat"; Description: {cm:LaunchProgram,ODM Console}; Flags: nowait postinstall skipifsilent + +[Code] +function VC2019RedistNeedsInstall: Boolean; +var + Version: String; +begin + if RegQueryStringValue(HKEY_LOCAL_MACHINE, + 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Version', Version) then + begin + // Is the installed version at least 14.14 ? + Log('VC Redist Version check : found ' + Version); + Result := (CompareStr(Version, 'v14.14.26429.03')<0); + end + else + begin + // Not even an old version installed + Result := True; + end; + if (Result) then + begin + ExtractTemporaryFile('vc_redist.x64.exe'); + end; +end; \ No newline at end of file diff --git a/win32env.bat b/win32env.bat index b6e402f0..d98f0200 100644 --- a/win32env.bat +++ b/win32env.bat @@ -11,12 +11,22 @@ if defined _OLD_CODEPAGE ( set ODMBASE=%~dp0 set GDALBASE=%ODMBASE%venv\Lib\site-packages\osgeo set OSFMBASE=%ODMBASE%SuperBuild\install\bin\opensfm\bin +set SBBIN=%ODMBASE%SuperBuild\install\bin -set PATH=%GDALBASE%;%ODMBASE%SuperBuild\install\bin;%OSFMBASE% +set PATH=%GDALBASE%;%SBBIN%;%OSFMBASE% set PROJ_LIB=%GDALBASE%\data\proj set VIRTUAL_ENV=%ODMBASE%venv set PYTHONPATH=%VIRTUAL_ENV% +set PYENVCFG=%VIRTUAL_ENV%\pyvenv.cfg + +rem Hot-patching pyvenv.cfg +echo home = %ODMBASE%\python38> %PYENVCFG% +echo include-system-site-packages = false>> %PYENVCFG% + +rem Hot-patching cv2 extension configs +echo BINARIES_PATHS = [r"%SBBIN%"] + BINARIES_PATHS> venv\Lib\site-packages\cv2\config.py +echo PYTHON_EXTENSIONS_PATHS = [r'%VIRTUAL_ENV%\lib\site-packages\cv2\python-3.8'] + PYTHON_EXTENSIONS_PATHS> venv\Lib\site-packages\cv2\config-3.8.py if not defined PROMPT set PROMPT=$P$G @@ -32,7 +42,7 @@ set PYTHONHOME= if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH% if not defined _OLD_VIRTUAL_PATH set _OLD_VIRTUAL_PATH=%PATH% -set PATH=%VIRTUAL_ENV%\Scripts;%VIRTUAL_ENV%\..;%PATH% +set PATH=%VIRTUAL_ENV%\Scripts;%PATH% :END if defined _OLD_CODEPAGE (