I have Windows OS (Operating System) and I am trying to install libpostal library https://github.com/openvenues/libpostal
I noticed that there a lot of steps required to correctly install libpostal. I want to take care of all installation steps using a .bat script and then try to run an example address.
I already post question here run .bat files for python libraries , now I try to use suggestions to improve script:
@echo off
REM Check if MSYS2 and MinGW are installed
where msys2 2>nul >nul
if %errorlevel% equ 0 (
echo MSYS2 is already installed. Use --force to reinstall.
) else (
REM Install MSYS2 and MinGW
choco install msys2
refreshenv
)
REM Check if MSYS2 packages are updated
pacman -Qu 2>nul >nul
if %errorlevel% equ 0 (
echo MSYS2 packages are already updated. Use --force to reinstall.
) else (
REM Update MSYS2 packages
pacman -Syu
)
REM Check if build dependencies are installed
pacman -Q autoconf automake curl git make libtool gcc mingw-w64-x86_64-gcc 2>nul >nul
if %errorlevel% equ 0 (
echo Build dependencies are already installed. Use --force to reinstall.
) else (
REM Install build dependencies
pacman -S autoconf automake curl git make libtool gcc mingw-w64-x86_64-gcc
)
REM Check if libpostal is cloned
if exist libpostal (
echo libpostal repository is already cloned. Use --force to reinstall.
) else (
REM Clone libpostal repository
git clone https://github.com/openvenues/libpostal
)
cd libpostal
REM Check if libpostal is built and installed
if exist C:/Program Files/libpostal/bin/libpostal.dll (
echo libpostal is already built and installed. Use --force to reinstall.
) else (
REM Build and install libpostal
cp -rf windows/* ./
./bootstrap.sh
./configure --datadir=C:/libpostal
make -j4
make install
)
REM Check if libpostal is added to PATH environment variable
setx /m PATH "%PATH%;C:\Program Files\libpostal\bin" 2>nul >nul
if %errorlevel% equ 0 (
echo libpostal is already added to PATH environment variable. Use --force to reinstall.
) else (
REM Add libpostal to PATH environment variable
setx PATH "%PATH%;C:\Program Files\libpostal\bin"
)
REM Test libpostal installation
libpostal "100 S Broad St, Philadelphia, PA"
pause
Here is the log:
I think there might be problems because I already tried to install some of these programs (example MSYS2) in the past... this is why I try and write code to skip installation and updates if already exists.
I am stuck - how to proceed?