Skip to content

Commit

Permalink
Merge pull request #1628 from coumbsek/feature/FixPathOpenCV
Browse files Browse the repository at this point in the history
mod:  Add post installation fix of OpenCV pathes instead of hot fixing
  • Loading branch information
pierotofy committed Apr 6, 2023
2 parents 7bf91d1 + 6c94338 commit 2361fce
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0
3.1.1
5 changes: 5 additions & 0 deletions innosetup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ 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
Source: "winpostinstall.bat"; DestDir: "{app}"; Flags: ignoreversion

[Dirs]
Name: "{commonappdata}\ODM"; Permissions: users-modify

[Icons]
Name: {group}\ODM Console; Filename: "{app}\console.bat"; WorkingDir: "{app}"
Expand All @@ -69,6 +73,7 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{

[Run]
Filename: "{tmp}\vc_redist.x64.exe"; StatusMsg: "Installing Visual C++ Redistributable Packages for Visual Studio 2019"; Parameters: "/quiet"; Check: VC2019RedistNeedsInstall ; Flags: waituntilterminated
Filename: "{app}\winpostinstall.bat"; StatusMsg: "Post Install"; Flags: waituntilterminated runhidden
Filename: "{app}\console.bat"; Description: {cm:LaunchProgram,ODM Console}; Flags: nowait postinstall skipifsilent

[Code]
Expand Down
7 changes: 6 additions & 1 deletion opendm/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
from opendm import log
import zipfile
import time
import sys

def get_model(namespace, url, version, name = "model.onnx"):
version = version.replace(".", "_")

base_dir = os.path.join(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")), "storage", "models")
base_dir = os.path.join(os.path.dirname(__file__), "..")
if sys.platform == 'win32':
base_dir = os.path.join(os.getenv('PROGRAMDATA'),"ODM")
base_dir = os.path.join(os.path.abspath(base_dir), "storage", "models")

namespace_dir = os.path.join(base_dir, namespace)
versioned_dir = os.path.join(namespace_dir, version)

Expand Down
9 changes: 1 addition & 8 deletions win32env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set GDAL_DRIVER_PATH=%GDALBASE%\gdalplugins
set OSFMBASE=%ODMBASE%SuperBuild\install\bin\opensfm\bin
set SBBIN=%ODMBASE%SuperBuild\install\bin
set PDAL_DRIVER_PATH=%ODMBASE%SuperBuild\install\bin
set PYTHONPYCACHEPREFIX=%PROGRAMDATA%\ODM\pycache

set PATH=%GDALBASE%;%SBBIN%;%OSFMBASE%
set PROJ_LIB=%GDALBASE%\data\proj
Expand All @@ -23,14 +24,6 @@ set VIRTUAL_ENV=%ODMBASE%venv
set PYTHONPATH=%VIRTUAL_ENV%
set PYENVCFG=%VIRTUAL_ENV%\pyvenv.cfg

rem Hot-patching pyvenv.cfg
echo home = %ODMBASE%venv\Scripts> "%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

if defined _OLD_VIRTUAL_PROMPT set PROMPT=%_OLD_VIRTUAL_PROMPT%
Expand Down
14 changes: 14 additions & 0 deletions winpostinstall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set ODMBASE=%~dp0
set VIRTUAL_ENV=%ODMBASE%venv
set PYENVCFG=%VIRTUAL_ENV%\pyvenv.cfg
set SBBIN=%ODMBASE%SuperBuild\install\bin

rem Hot-patching pyvenv.cfg
echo home = %ODMBASE%venv\Scripts> "%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

cls

0 comments on commit 2361fce

Please sign in to comment.