I have some Python code, developed for Linux, from a repository that I would prefer not to change.
The code uses the subprocess
Python module to call a command line tool named colmap
.
To get this code working under Windows, I installed colmap
, added the bin
folder containing colmap.exe
to the PATH
as well as the parent folder which contains the file COLMAP.bat
. I then also had to change the Python code to run colmap.bat
instead of colmap
via subprocess.run
.
The latter step I would like to avoid, as it would make the Python code incompatible with Linux/Mac and I would like to avoid adding an OS check via platform.system()
.
Is there a way to add colmap.exe
to the PATH
, so that it can be called via colmap
by cmd.exe
?
Like I said, the bin
folder is already on the PATH
. I already unsuccessfully tried to create a shortcut to COLMAP.bat
with the name colmap
as well as renaming COLMAP.bat
to colmap
.
This is the content of the batch file:
set SCRIPT_PATH=%~dp0
set PATH=%SCRIPT_PATH%\lib;%PATH%
set QT_PLUGIN_PATH=%SCRIPT_PATH%\lib\plugins;%QT_PLUGIN_PATH%
set COMMAND=%1
set ARGUMENTS=
shift
:extract_argument_loop
if "%1"=="" goto after_extract_argument_loop
set ARGUMENTS=%ARGUMENTS% %1
shift
goto extract_argument_loop
:after_extract_argument_loop
if "%COMMAND%"=="" set COMMAND=gui
"%SCRIPT_PATH%\bin\colmap" %COMMAND% %ARGUMENTS%