Skip to content

Instantly share code, notes, and snippets.

@msarahan msarahan/gdal-activate.bat
Last active Feb 25, 2019

Embed
What would you like to do?
post-link scripts for Fonnesbeck env
@REM Store existing GDAL env vars and set to this conda env
@REM so other GDAL installs don't pollute the environment
@if defined GDAL_DATA (
set "_CONDA_SET_GDAL_DATA=%GDAL_DATA%"
)
@set "GDAL_DATA=%CONDA_PREFIX%\Library\share\gdal"
@if defined GDAL_DRIVER_PATH (
set "_CONDA_SET_GDAL_DRIVER_PATH=%GDAL_DRIVER_PATH%"
)
@REM Support plugins if the plugin directory exists
@REM i.e if it has been manually created by the user
@set "GDAL_DRIVER_PATH=%CONDA_PREFIX%\Library\lib\gdalplugins"
@if not exist %GDAL_DRIVER_PATH% (
set "GDAL_DRIVER_PATH="
)
@REM Store existing GeoTIFF env vars and set to this conda env
@REM so other GeoTIFF installs don't pollute the environment
@if defined GeoTIFF_DATA (
set "_CONDA_SET_GEOTIFF_CSV=%GEOTIFF_CSV%"
)
@set "GEOTIFF_CSV=%CONDA_PREFIX%\Library\share\epsg_csv"
:: Store existing env vars and set to this conda env
:: so other installs don't pollute the environment.
@if defined PROJ_LIB (
set "_CONDA_SET_PROJ_LIB=%PROJ_LIB%"
)
@set "PROJ_LIB=%CONDA_PREFIX%\Library\share"
:: Set env vars that tell distutils to use the compiler that we put on path
SET DISTUTILS_USE_SDK=1
:: This is probably not good. It is for the pre-UCRT msvccompiler.py *not* _msvccompiler.py
SET MSSdk=1
:: http://stackoverflow.com/a/26874379/1170370
SET platform=
IF /I [%PROCESSOR_ARCHITECTURE%]==[amd64] set "platform=true"
IF /I [%PROCESSOR_ARCHITEW6432%]==[amd64] set "platform=true"
if defined platform (
set "VSREGKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0"
) ELSE (
set "VSREGKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0"
)
for /f "skip=2 tokens=2,*" %%A in ('reg query "%VSREGKEY%" /v InstallDir') do SET "VSINSTALLDIR=%%B"
if "%VSINSTALLDIR%" == "" (
set "VSINSTALLDIR=%VS140COMNTOOLS%"
)
if "%VSINSTALLDIR%" == "" (
ECHO "Did not find VS in registry or in VS140COMNTOOLS env var - exiting"
exit 1
)
echo "Found VS2014 at %VSINSTALLDIR%"
SET "VS_VERSION=14.0"
SET "VS_MAJOR=14"
SET "VS_YEAR=2015"
set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out"
set "MSYS2_ENV_CONV_EXCL=CL"
:: For Python 3.5+, ensure that we link with the dynamic runtime. See
:: http://stevedower.id.au/blog/building-for-python-3-5-part-two/ for more info
set "PY_VCRUNTIME_REDIST=%PREFIX%\vcruntime140.dll"
:: ensure that we use the DLL part of the ucrt
set "CFLAGS=%CFLAGS% -MD -GL"
set "CXXFLAGS=%CXXFLAGS% -MD -GL"
set "LDFLAGS_SHARED=%LDFLAGS_SHARED% -LTCG ucrt.lib"
:: translate target platform
IF /I [%target_platform%]==[win-64] (
set "folder=x64"
) else (
set "folder=x86"
)
:: find the most recent Win SDK path and add it to PATH (so that rc.exe gets found)
for /f "tokens=*" %%I in ('dir "C:\Program Files (x86)\Windows Kits\*1*" /B /O:N') do for %%A in (%%~I) do if "%%A" == "8.1" set win=%%A
for /f "tokens=*" %%I in ('dir "C:\Program Files (x86)\Windows Kits\*1*" /B /O:N') do for %%A in (%%~I) do if "%%A" == "10" set win=%%A
setlocal enabledelayedexpansion
if "%win%" == "10" (
for /f "tokens=*" %%I in ('dir "C:\Program Files (x86)\Windows Kits\10\bin\10*" /B /O:N') do for %%A in (%%~I) do set last=%%A
set "sdk_bin_path=C:\Program Files (x86)\Windows Kits\10\bin\!last!\%folder%"
) else (
set "sdk_bin_path=C:\Program Files (x86)\Windows Kits\8.1\bin\%folder%"
)
endlocal & set "PATH=%PATH%;%sdk_bin_path%"
:: other things added by install_activate.bat at package build time
SET "CMAKE_GENERATOR=Visual Studio 14 2015 Win64"
CALL "%VSINSTALLDIR%..\..\VC\vcvarsall.bat" amd64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.