Better location for setting Python dataset directory in CMake

release/4.3a0
Varun Agrawal 2020-08-31 10:10:54 -04:00
parent 3674b9c65f
commit ac3e564293
2 changed files with 11 additions and 8 deletions

View File

@ -428,14 +428,6 @@ add_subdirectory(CppUnitLite)
if(GTSAM_BUILD_PYTHON) if(GTSAM_BUILD_PYTHON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/wrap/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/wrap/cmake")
add_subdirectory(python) add_subdirectory(python)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Common directory which always has write access
# This is because the exact location of the Python installation may vary
# depending on various factors such as python version and use of virtual envs.
set(GTSAM_PYTHON_DATASET_DIR "/tmp/gtsam_example_data")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(GTSAM_PYTHON_DATASET_DIR "$ENV{LOCALAPPDATA}/gtsam_example_data")
endif()
endif() endif()
# Build GTSAM library # Build GTSAM library

View File

@ -4,6 +4,17 @@ if (NOT GTSAM_BUILD_PYTHON)
return() return()
endif() endif()
# Common directory for storing data stored with the package.
# This is because the exact location of the Python installation may vary
# depending on various factors such as python version and use of virtual envs.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Easy directory with write access.
set(GTSAM_PYTHON_DATASET_DIR "/tmp/gtsam_example_data")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# %LocalAppData% directory in Windows.
set(GTSAM_PYTHON_DATASET_DIR "$ENV{LOCALAPPDATA}/gtsam_example_data")
endif()
# Generate setup.py. # Generate setup.py.
file(READ "${PROJECT_SOURCE_DIR}/README.md" README_CONTENTS) file(READ "${PROJECT_SOURCE_DIR}/README.md" README_CONTENTS)
configure_file(${PROJECT_SOURCE_DIR}/python/setup.py.in configure_file(${PROJECT_SOURCE_DIR}/python/setup.py.in