-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from HARPLab/windows-installation-fix
Improving robustness of Windows build pipeline
- Loading branch information
Showing
11 changed files
with
931 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
@echo off | ||
setlocal | ||
|
||
rem BAT script that creates the client python api of LibCarla (carla.org). | ||
rem Run it through a cmd with the x64 Visual C++ Toolset enabled. | ||
|
||
set LOCAL_PATH=%~dp0 | ||
set FILE_N=-[%~n0]: | ||
|
||
rem Print batch params (debug purpose) | ||
echo %FILE_N% [Batch params]: %* | ||
|
||
rem ============================================================================ | ||
rem -- Parse arguments --------------------------------------------------------- | ||
rem ============================================================================ | ||
|
||
set DOC_STRING=Build and package CARLA Python API. | ||
set "USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--clean]" | ||
|
||
set REMOVE_INTERMEDIATE=false | ||
set BUILD_FOR_PYTHON2=false | ||
set BUILD_FOR_PYTHON3=false | ||
|
||
:arg-parse | ||
if not "%1"=="" ( | ||
if "%1"=="--rebuild" ( | ||
set REMOVE_INTERMEDIATE=true | ||
rem We don't provide support for py2 right now | ||
set BUILD_FOR_PYTHON2=false | ||
set BUILD_FOR_PYTHON3=true | ||
) | ||
|
||
if "%1"=="--py2" ( | ||
set BUILD_FOR_PYTHON2=true | ||
) | ||
|
||
if "%1"=="--py3" ( | ||
set BUILD_FOR_PYTHON3=true | ||
) | ||
|
||
|
||
if "%1"=="--clean" ( | ||
set REMOVE_INTERMEDIATE=true | ||
) | ||
|
||
if "%1"=="-h" ( | ||
echo %DOC_STRING% | ||
echo %USAGE_STRING% | ||
GOTO :eof | ||
) | ||
|
||
if "%1"=="--help" ( | ||
echo %DOC_STRING% | ||
echo %USAGE_STRING% | ||
GOTO :eof | ||
) | ||
|
||
shift | ||
goto :arg-parse | ||
) | ||
|
||
set PYTHON_LIB_PATH=%ROOT_PATH:/=\%PythonAPI\carla\ | ||
|
||
if %REMOVE_INTERMEDIATE% == false ( | ||
if %BUILD_FOR_PYTHON3% == false ( | ||
if %BUILD_FOR_PYTHON2% == false ( | ||
echo Nothing selected to be done. | ||
goto :eof | ||
) | ||
) | ||
) | ||
|
||
if %REMOVE_INTERMEDIATE% == true ( | ||
rem Remove directories | ||
for %%G in ( | ||
"%PYTHON_LIB_PATH%build", | ||
"%PYTHON_LIB_PATH%dist", | ||
"%PYTHON_LIB_PATH%source\carla.egg-info" | ||
) do ( | ||
if exist %%G ( | ||
echo %FILE_N% Cleaning %%G | ||
rmdir /s/q %%G | ||
) | ||
) | ||
if %BUILD_FOR_PYTHON3% == false ( | ||
if %BUILD_FOR_PYTHON2% == false ( | ||
goto good_exit | ||
) | ||
) | ||
) | ||
|
||
cd "%PYTHON_LIB_PATH%" | ||
rem if exist "%PYTHON_LIB_PATH%dist" goto already_installed | ||
|
||
rem ============================================================================ | ||
rem -- Check for py ------------------------------------------------------------ | ||
rem ============================================================================ | ||
|
||
rem prefer invoking 'python' (for externally installed, eg conda) over 'py' (built in to Windows) | ||
rem | ||
set PYTHON_EXEC=python | ||
|
||
where %PYTHON_EXEC%>nul | ||
if %errorlevel% neq 0 set PYTHON_EXEC=py -3 | ||
|
||
where %PYTHON_EXEC%>nul | ||
if %errorlevel% neq 0 goto error_py | ||
|
||
rem Build for Python 2 | ||
rem | ||
if %BUILD_FOR_PYTHON2%==true ( | ||
goto py2_not_supported | ||
) | ||
|
||
rem Build for Python 3 | ||
rem | ||
if %BUILD_FOR_PYTHON3%==true ( | ||
echo Building Python API for Python 3. | ||
%PYTHON_EXEC% setup.py bdist_egg bdist_wheel | ||
if %errorlevel% neq 0 goto error_build_wheel | ||
) | ||
|
||
goto success | ||
|
||
rem ============================================================================ | ||
rem -- Messages and Errors ----------------------------------------------------- | ||
rem ============================================================================ | ||
|
||
:success | ||
echo. | ||
if %BUILD_FOR_PYTHON3%==true echo %FILE_N% Carla lib for python has been successfully installed in "%PYTHON_LIB_PATH%dist"! | ||
goto good_exit | ||
|
||
:already_installed | ||
echo. | ||
echo %FILE_N% [ERROR] Already installed in "%PYTHON_LIB_PATH%dist" | ||
goto good_exit | ||
|
||
:py2_not_supported | ||
echo. | ||
echo %FILE_N% [ERROR] Python 2 is not currently suported in Windows. | ||
goto bad_exit | ||
|
||
:error_py | ||
echo. | ||
echo %FILE_N% [ERROR] An error ocurred while executing the py. | ||
echo %FILE_N% [ERROR] Possible causes: | ||
echo %FILE_N% [ERROR] - Make sure "py" is installed. | ||
echo %FILE_N% [ERROR] - py = python launcher. This utility is bundled with Python installation but not installed by default. | ||
echo %FILE_N% [ERROR] - Make sure it is available on your Windows "py". | ||
goto bad_exit | ||
|
||
:error_build_wheel | ||
echo. | ||
echo %FILE_N% [ERROR] An error occurred while building the wheel file. | ||
goto bad_exit | ||
|
||
:good_exit | ||
endlocal | ||
exit /b 0 | ||
|
||
:bad_exit | ||
endlocal | ||
exit /b %errorlevel% | ||
|
File renamed without changes.
Oops, something went wrong.