Skip to content

Commit

Permalink
Fix CI for macOS (#1689)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored Dec 31, 2022
1 parent b30d71e commit b623bb0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
9 changes: 5 additions & 4 deletions .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ fi
# Ref: https://unix.stackexchange.com/a/129401
if [ "$OSTYPE" = "linux-gnu" ]; then
num_available_threads=$(nproc)
elif [ "$OSTYPE" = "darwin" ]; then
elif [[ $OSTYPE = darwin* ]]; then
num_available_threads=$(sysctl -n hw.logicalcpu)
else
num_available_threads=1
echo "$OSTYPE is not supported to detect the number of logical CPU cores."
echo "[WARN] $OSTYPE is not supported to detect the number of logical CPU cores."
fi

if [ "$NUM_CORES" = "MAX" ]; then
Expand Down Expand Up @@ -128,6 +128,7 @@ echo ""
echo " [ SYSTEM INFO ]"
echo ""
echo " OS : $OS $VER ($(uname -m))"
echo " OSTYPE : $OSTYPE"
echo " Cores : $num_threads / $num_available_threads"
echo " Compiler: $COMPILER $($CXX --version | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/')"
echo " CMake : $(cmake --version | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/')"
Expand All @@ -138,8 +139,8 @@ echo "====================================="
mkdir build && cd build
if [ "$OSTYPE" = "linux-gnu" ]; then
install_prefix_option="-DCMAKE_INSTALL_PREFIX=/usr/"
elif [ "$OSTYPE" = "darwin" ]; then
install_prefix_option="-DCMAKE_INSTALL_PREFIX=/usr/local/"
elif [[ $OSTYPE = darwin* ]]; then
install_prefix_option="-DCMAKE_INSTALL_PREFIX=/usr/local/ -DCMAKE_INSTALL_RPATH=/usr/local/lib/"
fi

cmake .. \
Expand Down
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ brew 'tinyxml2'
brew 'urdfdom'

# dartpy dependencies
brew 'python3'
brew 'pybind11'
6 changes: 6 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ add_subdirectory(dartpy)
add_subdirectory(tests)
add_subdirectory(examples)
add_subdirectory(tutorials)

message(STATUS "")
message(STATUS "[ dartpy ]")
message(STATUS "- PYTHON_EXECUTABLE : ${PYTHON_EXECUTABLE}")
message(STATUS "- PYTHON_SITE_PACKAGES: ${PYTHON_SITE_PACKAGES}")
message(STATUS "- DARTPY_PYTEST_FOUND : ${DARTPY_PYTEST_FOUND}")
5 changes: 3 additions & 2 deletions python/dartpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ endif()

execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"from distutils.sysconfig import get_python_lib;\
print(get_python_lib(plat_specific=True, prefix=''))"
print(get_python_lib(plat_specific=True))"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT IS_ABSOLUTE PYTHON_SITE_PACKAGES)
if(NOT IS_ABSOLUTE ${PYTHON_SITE_PACKAGES})
set(PYTHON_SITE_PACKAGES "${CMAKE_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES}")
endif()
set(PYTHON_SITE_PACKAGES ${PYTHON_SITE_PACKAGES} PARENT_SCOPE)

file(GLOB_RECURSE dartpy_headers "*.h" "*.hpp")
file(GLOB_RECURSE dartpy_sources "*.cpp")
Expand Down
26 changes: 16 additions & 10 deletions python/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ if(pytest_not_found)
message(WARNING "Running the tests requires pytest. Please install it manually"
" (try: ${PYTHON_EXECUTABLE} -m pip install pytest)"
)
set(DARTPY_PYTEST_FOUND FALSE)
set(DARTPY_PYTEST_FOUND FALSE PARENT_SCOPE)
elseif(pytest_version VERSION_LESS 3.0)
message(WARNING "Running the tests requires pytest >= 3.0. Found: ${pytest_version}"
"Please update it (try: ${PYTHON_EXECUTABLE} -m pip install -U pytest)"
)
set(DARTPY_PYTEST_FOUND FALSE)
set(DARTPY_PYTEST_FOUND FALSE PARENT_SCOPE)
else()
set(DARTPY_PYTEST_FOUND TRUE)
set(DARTPY_PYTEST_FOUND TRUE PARENT_SCOPE)
endif()

set(dartpy_test_utils
Expand All @@ -26,13 +26,19 @@ set(dartpy_test_utils
file(GLOB_RECURSE dartpy_test_files "test_*.py")

# Add custom target to run the tests
add_custom_target(pytest
COMMAND ${CMAKE_COMMAND} -E echo "Running pytest by: PYTHONPATH=${DART_DARTPY_BUILD_DIR} ${PYTHON_EXECUTABLE} -m pytest [sources]"
COMMAND PYTHONPATH=${DART_DARTPY_BUILD_DIR} ${PYTHON_EXECUTABLE} -m pytest ${dartpy_test_files} -v
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
SOURCES ${dartpy_test_files} ${dartpy_test_utils}
DEPENDS dartpy
)
if(DARTPY_PYTEST_FOUND)
add_custom_target(pytest
COMMAND ${CMAKE_COMMAND} -E echo "Running pytest by: PYTHONPATH=${DART_DARTPY_BUILD_DIR} ${PYTHON_EXECUTABLE} -m pytest [sources]"
COMMAND PYTHONPATH=${DART_DARTPY_BUILD_DIR} ${PYTHON_EXECUTABLE} -m pytest ${dartpy_test_files} -v
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
SOURCES ${dartpy_test_files} ${dartpy_test_utils}
DEPENDS dartpy
)
else()
add_custom_target(pytest
COMMAND ${CMAKE_COMMAND} -E echo "Warning: Failed to run pytest because pytest is not found!"
)
endif()

#===============================================================================
# Usage:
Expand Down

0 comments on commit b623bb0

Please sign in to comment.