Skip to content

Commit 77b8123

Browse files
authored
Merge pull request #1814 from borglab/stubs-fix
2 parents cf8a04d + 8d3bdc0 commit 77b8123

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

python/CMakeLists.txt

+12-14
Original file line numberDiff line numberDiff line change
@@ -265,24 +265,22 @@ endif()
265265
# Add custom target so we can install with `make python-install`
266266
# Note below we make sure to install with --user iff not in a virtualenv
267267
set(GTSAM_PYTHON_INSTALL_TARGET python-install)
268-
add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET}
268+
#TODO(Varun) Maybe move the long command to script?
269+
# https://stackoverflow.com/questions/49053544/how-do-i-run-a-python-script-every-time-in-a-cmake-build
270+
if (NOT WIN32) # WIN32=1 is target platform is Windows
271+
add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET}
272+
COMMAND stubgen -q -p gtsam && cp -a out/gtsam/ gtsam && ${PYTHON_EXECUTABLE} -c "import sys, subprocess; cmd = [sys.executable, '-m', 'pip', 'install']; has_venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix); cmd.append('--user' if not has_venv else ''); cmd.append('.'); subprocess.check_call([c for c in cmd if c])"
273+
DEPENDS ${GTSAM_PYTHON_DEPENDENCIES}
274+
WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY}
275+
VERBATIM)
276+
else()
277+
#TODO(Varun) Find equivalent cp on Windows
278+
add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET}
269279
COMMAND ${PYTHON_EXECUTABLE} -c "import sys, subprocess; cmd = [sys.executable, '-m', 'pip', 'install']; has_venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix); cmd.append('--user' if not has_venv else ''); cmd.append('.'); subprocess.check_call([c for c in cmd if c])"
270280
DEPENDS ${GTSAM_PYTHON_DEPENDENCIES}
271281
WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY}
272282
VERBATIM)
273-
274-
# if (NOT WIN32) # WIN32=1 is target platform is Windows
275-
# add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET}
276-
# COMMAND stubgen -q -p gtsam -o ./stubs && cp -a stubs/gtsam/ gtsam && ${PYTHON_EXECUTABLE} -m pip install --user .
277-
# DEPENDS ${GTSAM_PYTHON_DEPENDENCIES}
278-
# WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY})
279-
# else()
280-
# #TODO(Varun) Find equivalent cp on Windows
281-
# add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET}
282-
# COMMAND ${PYTHON_EXECUTABLE} -m pip install --user .
283-
# DEPENDS ${GTSAM_PYTHON_DEPENDENCIES}
284-
# WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY})
285-
# endif()
283+
endif()
286284

287285

288286
# Custom make command to run all GTSAM Python tests

0 commit comments

Comments
 (0)