-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller_python_-m.bat
More file actions
86 lines (72 loc) · 2.36 KB
/
Copy pathinstaller_python_-m.bat
File metadata and controls
86 lines (72 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@echo off
@REM installer_python_-m.bat
setlocal
@REM If you are missing pip, use this
@REM python -m ensurepip --upgrade
REM Prefer the Windows Python launcher because it resolves to the latest installed Python 3.x.
set "PYTHON_CMD=py -3"
set "GIS_WHEEL_INDEX=https://gisidx.github.io/gwi"
%PYTHON_CMD% --version >nul 2>&1
if errorlevel 1 (
echo Python launcher not found. Falling back to python in PATH.
set "PYTHON_CMD=python"
)
call %PYTHON_CMD% -c "import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)" >nul 2>&1
if errorlevel 1 (
echo Python 3 was not found. Install the latest Python 3 and try again.
pause
endlocal
goto :EOF
)
call %PYTHON_CMD% -m pip install --upgrade gdal-installer
if errorlevel 1 (
echo Failed to install gdal-installer.
pause
endlocal
goto :EOF
)
call %PYTHON_CMD% -m gdal_installer.cli
if errorlevel 1 (
echo Failed to install GDAL for %PYTHON_CMD%.
pause
endlocal
goto :EOF
)
REM Install compiled geospatial dependencies as wheels before installing ryan-functions.
REM If a new Python version does not have matching wheels yet, fail here instead of attempting a source build.
call %PYTHON_CMD% -m pip install --upgrade --extra-index-url "%GIS_WHEEL_INDEX%" --only-binary=:all: fiona rasterio
if errorlevel 1 (
echo Failed to install Fiona/Rasterio binary wheels for %PYTHON_CMD%.
echo The latest Python may be too new for the available geospatial wheels.
pause
endlocal
goto :EOF
)
REM Define the working path
set "PACKAGE_DIR=%~dp0dist"
echo Using Python command: %PYTHON_CMD%
echo %PACKAGE_DIR%
REM Find the latest version of the package (wheel format)
for /f "delims=" %%i in ('dir /b /o-n "%PACKAGE_DIR%\ryan_functions-*.whl"') do (
set "LATEST_PACKAGE=%%i"
goto found
)
:found
if "%LATEST_PACKAGE%"=="" (
echo No package found in the directory.
pause
endlocal
goto :EOF
)
echo Installing or updating "%LATEST_PACKAGE%"
REM Install or update the package using pip
call %PYTHON_CMD% -m pip install --upgrade --prefer-binary --extra-index-url "%GIS_WHEEL_INDEX%" --only-binary=fiona --only-binary=rasterio "%PACKAGE_DIR%\%LATEST_PACKAGE%"
REM Check if the installation was successful
if errorlevel 1 (
echo Installation failed. Please check the path and try again.
) else (
echo Installation completed successfully.
)
endlocal
pause
goto :EOF