Skip to content

Commit

Permalink
Merge pull request #92 from HARPLab/windows-installation-fix
Browse files Browse the repository at this point in the history
Improving robustness of Windows build pipeline
  • Loading branch information
GustavoSilvera committed Mar 19, 2023
2 parents 984d756 + c2db63c commit 70a15b5
Show file tree
Hide file tree
Showing 11 changed files with 931 additions and 20 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## DReyeVR 0.1.2 (for Carla 0.9.13)
- Update documentation to refer to CarlaUnreal UE4 fork rather than HarpLab fork
- Apply patches for installation of zlib (broken link) and xerces (broken link & `-Dtranscoder=windows` flag) and PythonAPI
- Fix crash on BeginPlay when EgoVehicle blueprint is already present in map (before world start)
- Prefer building PythonAPI with `python` rather than Windows built-in `py -3` (good if using conda) but fallback if `python` is not available

## DReyeVR 0.1.1 (for Carla 0.9.13)
- Update documentation, add developer-centric in-depth documentation
- Adding missing includes for TrafficSign RoadInfoSignal in SignComponent
Expand All @@ -20,4 +26,4 @@
- Improved vehicle dash with blinking turn signal and fixed bugs with inconsistent gear indicator.
- Fixed bugs and inconsistencies with replayer media control and special actions such as toggling reverse/turn signals in replay.
- Enabled cooking for `Town06` and `Town07` in package/shipping mode.
- Updated documentation and config file
- Updated documentation and config file
4 changes: 2 additions & 2 deletions DReyeVR/EgoVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ FVector AEgoVehicle::GetCameraOffset() const
}
FVector AEgoVehicle::GetCameraPosn() const
{
return GetCamera()->GetComponentLocation();
return GetCamera() ? GetCamera()->GetComponentLocation() : FVector::ZeroVector;
}
FVector AEgoVehicle::GetNextCameraPosn(const float DeltaSeconds) const
{
Expand All @@ -356,7 +356,7 @@ FVector AEgoVehicle::GetNextCameraPosn(const float DeltaSeconds) const
}
FRotator AEgoVehicle::GetCameraRot() const
{
return GetCamera()->GetComponentRotation();
return GetCamera() ? GetCamera()->GetComponentRotation() : FRotator::ZeroRotator;
}
const class AEgoSensor *AEgoVehicle::GetSensor() const
{
Expand Down
21 changes: 5 additions & 16 deletions Docs/Install.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,7 @@ make check CARLA=../carla
```bat
conda activate carla13
```
2. When trying to `make PythonAPI` you'll need to apply [this fix](https://github.com/carla-simulator/carla/issues/2881#issuecomment-699452386) (Replace `py` with `python` in `BuildPythonAPI.bat`)
```bat
...
rem previously called "py -3 setup.py ..." --> replace with just "python setup.py ..."
if %BUILD_FOR_PYTHON3%==true (
echo Building Python API for Python 3.
python setup.py bdist_egg bdist_wheel
if %errorlevel% neq 0 goto error_build_wheel
)
```
- This is because Carla (by default) installs the PythonAPI to the native Python client that comes pre-installed with every Windows machine. This goes 100% against compartmentalizing python environments so we have to patch this file to proceed.
3. Add carla to "path" to locate the PythonAPI and ScenarioRunner. But since Anaconda [does not use the traditional `PYTHONPATH`](https://stackoverflow.com/questions/37006114/anaconda-permanently-include-external-packages-like-in-pythonpath) you'll need to:
2. Add carla to "path" to locate the PythonAPI and ScenarioRunner. But since Anaconda [does not use the traditional `PYTHONPATH`](https://stackoverflow.com/questions/37006114/anaconda-permanently-include-external-packages-like-in-pythonpath) you'll need to:
- 3.1. Create a file `carla.pth` in `\PATH\TO\ANACONDA\envs\carla\Lib\site-packages\`
- 3.2. Insert the following content into `carla.pth`:
```bat
Expand All @@ -313,22 +302,22 @@ make check CARLA=../carla
C:\PATH\TO\CARLA\PythonAPI\examples
C:\PATH\TO\SCENARIO_RUNNER\
```
4. Install the specific carla wheel (`whl`) to Anaconda
3. Install the specific carla wheel (`whl`) to Anaconda
```bash
conda activate carla
conda activate carla13
pip install --no-deps --force-reinstall PATH\TO\CARLA\PythonAPI\carla\dist\carla-0.9.13-cp37-cp37m-win_amd64.whl

# if applicable (and you installed Scenario runner)
cd %SCENARIO_RUNNER_ROOT%
pip install -r requirements.txt # install all SR dependencies
```
5. Finally, there are some problems with `shapely` (SR dependency) and Conda. Luckily the solution is simple:
4. Finally, you might run into problems with `shapely` (scenario-runner dependency) and Conda. Luckily the solution is simple:
- Copy the files:
- `PATH\TO\ANACONDA\envs\carla13\Lib\site-packages\shapely\DLLs\geos.dll`
- `PATH\TO\ANACONDA\envs\carla13\Lib\site-packages\shapely\DLLs\geos_c.dll`
- To destination:
- `PATH\TO\ANACONDA\envs\carla13\Library\bin\`
6. Now finally, you should be able to verify all PythonAPI actions work as expected via:
5. Now finally, you should be able to verify all PythonAPI actions work as expected via:
```bat
conda activate carla13
python
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Paths/DReyeVR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Content,Unreal/CarlaUE4/
LibCarla,/
PythonAPI,/
Carla,Unreal/CarlaUE4/Plugins/Carla/Source/
Tools/BuildTools/*.sh,Util/BuildTools/
Util,/
Scripts/Other/.gitignore,/
Shaders/*.uasset,Unreal/CarlaUE4/Plugins/Carla/Content/PostProcessingMaterials/
File renamed without changes.
165 changes: 165 additions & 0 deletions Util/BuildTools/BuildPythonAPI.bat
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.
Loading

0 comments on commit 70a15b5

Please sign in to comment.