Commit 3a38781c authored by bonnell's avatar bonnell

Fix cli on windows: modify how 'python setup' is called from cmake to account...

Fix cli on windows: modify how 'python setup' is called from cmake to account for windows path-separators and path-with-spaces issues. Ad GetVisItLibraryDirectory functions to correctly retireve the location on windows depending on if working from a public or development version

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@18197 18c085ea-50e0-402c-830e-de6fd14e8384
parent 76193559
......@@ -82,6 +82,11 @@
# Cyrus Harrison, Mon Apr 16 14:20:20 PDT 2012
# Fix problem with PYTHON_EXECUTABLE detection.
#
# Kathleen Biagas, Thu May 10 10:24:15 MST 2012
# Add windows-specific cases for PYTHON_ADD_DISTUTILS_SETUP, to correctly
# handle windows path and path-with-spaces issues. Don't change
# library output directory on widnows for PYTHON_ADD_HYBRID_MODULE.
#
#****************************************************************************/
INCLUDE(${VISIT_SOURCE_DIR}/CMake/ThirdPartyInstallLibrary.cmake)
......@@ -331,27 +336,56 @@ ENDFUNCTION(PYTHON_WRITE_MODULES_HEADER)
FUNCTION(PYTHON_ADD_DISTUTILS_SETUP target_name dest_dir setup_file)
MESSAGE(STATUS "Configuring python distutils setup: ${target_name}")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/build
COMMAND ${PYTHON_EXECUTABLE} ${setup_file} -v
build
--build-base=${CMAKE_CURRENT_BINARY_DIR}/build
install
--install-purelib=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${dest_dir}
DEPENDS ${setup_file} ${ARGN}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(${target_name} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/build)
# also use distutils for the install ...
INSTALL(CODE
IF(NOT WIN32)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/build
COMMAND ${PYTHON_EXECUTABLE} ${setup_file} -v
build
--build-base=${CMAKE_CURRENT_BINARY_DIR}/build
install
--install-purelib=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${dest_dir}
DEPENDS ${setup_file} ${ARGN}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(${target_name} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/build)
# also use distutils for the install ...
INSTALL(CODE
"
EXECUTE_PROCESS(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} ${setup_file} -v
build --build-base=${CMAKE_CURRENT_BINARY_DIR}/build_install
install --install-purelib=\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${VISIT_INSTALLED_VERSION_LIB}/${dest_dir}
OUTPUT_VARIABLE PY_DIST_UTILS_INSTALL_OUT)
COMMAND ${PYTHON_EXECUTABLE} ${setup_file} -v
build --build-base=${CMAKE_CURRENT_BINARY_DIR}/build_install
install --install-purelib=\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${VISIT_INSTALLED_VERSION_LIB}/${dest_dir}
OUTPUT_VARIABLE PY_DIST_UTILS_INSTALL_OUT)
MESSAGE(STATUS \"\${PY_DIST_UTILS_INSTALL_OUT}\")
")
ELSE(NOT WIN32)
FILE(TO_NATIVE_PATH ${VISIT_LIBRARY_DIR} VLD_NATIVE)
STRING(REPLACE "\\" "\\\\" VLD_ESC_PATH "${VLD_NATIVE}")
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR} CCBD_NATIVE)
STRING(REPLACE "\\" "\\\\" CCBD_ESC_PATH "${CCBD_NATIVE}")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/build
COMMAND ${PYTHON_EXECUTABLE} ${setup_file} -v
build
--build-base=${CMAKE_CURRENT_BINARY_DIR}/build
install
--install-purelib=${VLD_NATIVE}/${dest_dir}
DEPENDS ${setup_file} ${ARGN}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(${target_name} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/build)
# also use distutils for the install ...
FILE(TO_NATIVE_PATH ${VISIT_INSTALLED_VERSION_LIB} VIVL_NATIVE)
STRING(REPLACE "\\" "\\\\" VIVL_ESC_PATH "${VIVL_NATIVE}")
INSTALL(CODE
"
EXECUTE_PROCESS(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} ${setup_file} -v
build \"--build-base=${CCBD_ESC_PATH}\\\\build_install\"
install \"--install-purelib=${VIVL_ESC_PATH}\\\\${dest_dir}\")
MESSAGE(STATUS \"\${PY_DIST_UTILS_INSTALL_OUT}\")
")
ENDIF(NOT WIN32)
ENDFUNCTION(PYTHON_ADD_DISTUTILS_SETUP)
......@@ -363,8 +397,10 @@ FUNCTION(PYTHON_ADD_HYBRID_MODULE target_name dest_dir setup_file py_sources)
${setup_file}
${py_sources})
PYTHON_ADD_MODULE(${target_name} ${ARGN})
SET_TARGET_PROPERTIES(${target_name} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${dest_dir}/${target_name}/)
IF(NOT WIN32)
SET_TARGET_PROPERTIES(${target_name} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${dest_dir}/${target_name}/)
ENDIF(NOT WIN32)
ADD_DEPENDENCIES(${target_name} "${target_name}_py_setup")
VISIT_INSTALL_TARGETS_RELATIVE(${dest_dir}/${target_name} ${target_name})
......
......@@ -1768,7 +1768,9 @@ CONFIGURE_FILE(${VISIT_SOURCE_DIR}/common/misc/ConfigureInfo.C.in
# The normal plugin case. We redefine these when we build against an installed
# version of VisIt
SET(VISIT_INCLUDE_DIR ${VISIT_SOURCE_DIR} CACHE INTERNAL "Path to VisIt's includes")
SET(VISIT_LIBRARY_DIR ${VISIT_SOURCE_DIR}/lib CACHE INTENAL "Path to VisIt's libraries")
# VISIT_LIBRARY_DIR set previsouly, why change it now? And especially to point
# to source changing the name to _DIR2 to see if it munges anything.
SET(VISIT_LIBRARY_DIR2 ${VISIT_SOURCE_DIR}/lib CACHE INTERNAL "Path to VisIt's libraries")
IF(NOT WIN32)
SET(VISIT_PLUGIN_DIR ${VISIT_BINARY_DIR}/plugins CACHE INTERNAL "Path to VisIt's plugins")
ELSE(NOT WIN32)
......
......@@ -115,6 +115,9 @@ avtPythonFilterEnvironment::~avtPythonFilterEnvironment()
// Retrieve VISITARCHHOME via GetVisItArchitectureDirectory.
// Remove slash from end of paths passed to AddSystemPath.
//
// Kathleen Biagas, Fri May 4 14:08:12 PDT 2012
// Call GetVisItLibraryDirectory instead of GetVisItArchitectureDirectory.
//
// ****************************************************************************
bool
......@@ -125,8 +128,7 @@ avtPythonFilterEnvironment::Initialize()
return false;
// setup pyavt env:
// add system paths: $VISITARCHOME/lib & $VISITARCHOME/lib/site-packages
string varchdir = GetVisItArchitectureDirectory();
string vlibdir = varchdir + VISIT_SLASH_CHAR + "lib";
string vlibdir = GetVisItLibraryDirectory();
string vlibsp = vlibdir + VISIT_SLASH_CHAR + "site-packages";
if(!pyi->AddSystemPath(vlibdir))
......
......@@ -131,7 +131,8 @@ static const char usage[] =
/*
* Prototypes
*/
string GetVisItEnvironment(stringVector &, bool, bool);
string GetVisItEnvironment(stringVector &, bool, bool, bool &);
void SetVisItEnvironment(const stringVector &);
string AddPath(char *, const char *, const char*);
bool ReadKey(const char *key, char **keyval);
......@@ -275,6 +276,9 @@ static bool EndsWith(const char *s, const char *suffix)
* debugging for the launcher so we can see the command line and environment
* we're attempting to use.
*
* Kathleen Biagas, Fri May 4 14:05:27 PDT 2012
* If working from a dev build, pass "-dv" to components.
*
*****************************************************************************/
int
......@@ -506,7 +510,10 @@ VisItLauncherMain(int argc, char *argv[])
// Add some stuff to the environment.
//
stringVector visitEnv;
string visitpath = GetVisItEnvironment(visitEnv, useShortFileName, addPluginVars);
bool usingDev;
string visitpath = GetVisItEnvironment(visitEnv, useShortFileName, addPluginVars, usingDev);
if (usingDev)
componentArgs.push_back("-dv");
SetVisItEnvironment(visitEnv);
#ifdef VISIT_WINDOWS_APPLICATION
// Show the path and the environment we've created.
......@@ -873,17 +880,21 @@ ReadKey(const char *key, char **keyval)
* I made the routine return all of the environment strings in a stringVector
* instead of calling _putenv on all of them.
*
* Kathleen Biagas, Fri May 4 14:05:27 PDT 2012
* Return usingdev as an arg.
*
*****************************************************************************/
std::string
GetVisItEnvironment(stringVector &env, bool useShortFileName, bool addPluginVars)
GetVisItEnvironment(stringVector &env, bool useShortFileName, bool addPluginVars, bool &usingdev)
{
char *tmp, *visitpath = NULL;
char *visitdevdir = NULL;
char tmpdir[512];
bool haveVISITHOME = false;
bool usingdev = false;
usingdev = false;
bool freeVisItPath = true;
string config;
tmp = (char *)malloc(10000);
......@@ -949,6 +960,8 @@ GetVisItEnvironment(stringVector &env, bool useShortFileName, bool addPluginVars
strncpy(visitdevdir, visitpath, pos);
visitdevdir[pos] = '\0';
strncat(visitdevdir, "\\ThirdParty", 14);
if (len != pos)
config = vp.substr(pos+1);
}
}
......@@ -1084,8 +1097,18 @@ GetVisItEnvironment(stringVector &env, bool useShortFileName, bool addPluginVars
}
else
{
sprintf(tmp, "PYTHONPATH=%s\\..\\..\\lib;%s\\..\\..\\lib\\Python\\lib",
visitpath, visitpath);
string vp(visitpath);
size_t pos = vp.find_last_of("\\");
pos = vp.find_last_of("\\", pos-1);
string svp = vp.substr(0, pos);
if (config.length() > 0)
{
sprintf(tmp, "PYTHONPATH=%s\\lib\\%s;%s\\lib\\%s\\Python\\Lib", svp.c_str(), config.c_str(), svp.c_str(), config.c_str());
}
else
{
sprintf(tmp, "PYTHONPATH=%s\\lib;%s\\lib\\Python\\Lib", svp.c_str(), svp.c_str());
}
env.push_back(tmp);
}
......
......@@ -1262,3 +1262,49 @@ VersionGreaterThan(const std::string &v1, const std::string &v2)
{
return VersionToInt(v1) > VersionToInt(v2);
}
// ****************************************************************************
// Method: GetVisItLibraryDirectory
//
// Purpose:
// Gets the name of the directory where VisIt's current library is installed.
//
// Arguments:
// version : The version number for which we want the library dir.
//
// Returns: The library dir.
//
// Programmer: Kathleen Biagas
// Creation: May 4, 2012
//
// Modifications:
//
// ****************************************************************************
std::string
GetVisItLibraryDirectory()
{
return GetVisItLibraryDirectory(VISIT_VERSION);
}
std::string
GetVisItLibraryDirectory(const char *version)
{
std::string varchdir(GetVisItArchitectureDirectory(version));
#if defined(_WIN32)
if (isDevelopmentVersion)
{
size_t pos = varchdir.find_last_of("\\");
std::string config = varchdir.substr(pos+1);
pos = varchdir.find_last_of("\\", pos-1);
std::string libdir = varchdir.substr(0, pos) + VISIT_SLASH_CHAR +
"lib" + VISIT_SLASH_CHAR + config;
return libdir;
}
#endif
std::string libdir = varchdir + VISIT_SLASH_CHAR + "lib";
return libdir;
}
......@@ -54,6 +54,8 @@ bool MISC_API ReadInstallationInfo(std::string &distName,
std::string MISC_API GetVisItArchitectureDirectory();
std::string MISC_API GetVisItArchitectureDirectory(const char *version);
std::string MISC_API GetVisItLauncher();
std::string MISC_API GetVisItLibraryDirectory();
std::string MISC_API GetVisItLibraryDirectory(const char *version);
// User installation / data functions
std::string MISC_API GetUserVisItDirectory();
......
......@@ -363,15 +363,16 @@ QvisPythonFilterEditor::loadMenuEvent(QAction *action)
// Cyrus Harrison, Wed Apr 11 15:03:17 PDT 2012
// Update to reflect change loc of templates.
//
// Kathleen Biagas, Fri May 4 14:05:27 PDT 2012
// Call GetVisItLibraryDirectory instead of GetVisItArchitectureDirectory.
//
// ****************************************************************************
QString
QvisPythonFilterEditor::templateDirectory()
{
QString res(GetVisItArchitectureDirectory().c_str());
QString res(GetVisItLibraryDirectory().c_str());
res += QString(VISIT_SLASH_CHAR)
+ QString("lib")
+ QString(VISIT_SLASH_CHAR)
+ QString("site-packages")
+ QString(VISIT_SLASH_CHAR)
+ QString("pyavt")
......
......@@ -69,6 +69,9 @@
# Cyrus Harrison, Wed Jul 7 10:09:07 PDT 2010
# Remove any existing symlinks before attempting to create new ones.
#
# Kathleen Biagas, Thu May 10 10:58:39 MST 2012
# Change how python is handled on Windows to reflect recent changes.
#
#----------------------------------------------------------------------------
FOREACH(LIB ${MESA_LIB})
......@@ -105,9 +108,17 @@ IF (NOT WIN32)
${VISIT_PYTHON_DIR}
${CMAKE_CURRENT_BINARY_DIR}/python)
ELSE (NOT WIN32)
FILE(COPY ${VISIT_PYTHON_DIR}/Lib
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/python
PATTERN ".svn" EXCLUDE)
# because you don't need to choose your configuration up-front
# on windows, make this a custom target so they are copied to the
# correct lib/${CFG} directory
ADD_CUSTOM_TARGET(python_lib ALL)
ADD_CUSTOM_COMMAND(TARGET python_lib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${VISIT_PYTHON_DIR}/Lib
${VISIT_LIBRARY_DIR}/python/Lib
COMMENT "Copying ${VISIT_PYTHON_DIR}/Lib/ ${VISIT_LIBRARY_DIR}/python/Lib"
)
ENDIF (NOT WIN32)
IF(VISIT_PYTHON_FILTERS)
......@@ -117,27 +128,22 @@ IF(VISIT_PYTHON_FILTERS)
IF (NOT WIN32)
## MESSAGE("${VISIT_VTK_DIR}/lib/python${PYTHON_VERSION}/site-packages/*")
FILE(GLOB VTK_PYTHON_MODULE_ITEMS "${VISIT_VTK_DIR}/lib/python${PYTHON_VERSION}/site-packages/*")
ELSE (NOT WIN32)
FILE(GLOB VTK_PYTHON_MODULE_ITEMS "${VISIT_VTK_DIR}/lib/site-packages/*")
ENDIF (NOT WIN32)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_CURRENT_BINARY_DIR}/site-packages
RESULT_VARIABLE LIB_SITE_PKGS_MKDIR)
#
# make sure lib/site-packages exists before we try to
# symlink or copy the vtk python wrappers
#
IF(NOT "${LIB_SITE_PKGS_MKDIR}" STREQUAL "0")
MESSAGE(WARNING "Failed to create lib/site-packages/")
ENDIF(NOT "${LIB_SITE_PKGS_MKDIR}" STREQUAL "0")
#
# make sure lib/site-packages exists before we try to
# symlink or copy the vtk python wrappers
#
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_CURRENT_BINARY_DIR}/site-packages
RESULT_VARIABLE LIB_SITE_PKGS_MKDIR)
IF(NOT "${LIB_SITE_PKGS_MKDIR}" STREQUAL "0")
MESSAGE(WARNING "Failed to create lib/site-packages/")
ENDIF(NOT "${LIB_SITE_PKGS_MKDIR}" STREQUAL "0")
FOREACH(ITM ${VTK_PYTHON_MODULE_ITEMS})
GET_FILENAME_COMPONENT(ITM_ABS ${ITM} ABSOLUTE)
GET_FILENAME_COMPONENT(ITM_BASE ${ITM_ABS} NAME)
MESSAGE(STATUS "Symlinking ${ITM_ABS} to ${CMAKE_CURRENT_BINARY_DIR}/site-packages/${ITM_BASE}")
IF (NOT WIN32)
FOREACH(ITM ${VTK_PYTHON_MODULE_ITEMS})
GET_FILENAME_COMPONENT(ITM_ABS ${ITM} ABSOLUTE)
GET_FILENAME_COMPONENT(ITM_BASE ${ITM_ABS} NAME)
MESSAGE(STATUS "Symlinking ${ITM_ABS} to ${CMAKE_CURRENT_BINARY_DIR}/site-packages/${ITM_BASE}")
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E remove -f
${CMAKE_CURRENT_BINARY_DIR}/site-packages/${ITM_BASE}
RESULT_VARIABLE VTK_MODULE_SYM_RM)
......@@ -148,12 +154,23 @@ IF(VISIT_PYTHON_FILTERS)
IF(NOT "${VTK_MODULE_SYM_CREATE}" STREQUAL "0")
MESSAGE(WARNING "Failed to create VTK Python module symlink in lib/site-packages/ for ${ITM_ABS}")
ENDIF(NOT "${VTK_MODULE_SYM_CREATE}" STREQUAL "0")
ELSE (NOT WIN32)
FILE(COPY ${ITM_ABS}
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/site-packages
PATTERN ".svn" EXCLUDE)
ENDIF (NOT WIN32)
ENDFOREACH(ITM ${VTK_PYTHON_MODULE_ITEMS})
ENDFOREACH(ITM ${VTK_PYTHON_MODULE_ITEMS})
ELSE (NOT WIN32)
FILE(GLOB VTK_EGG_FILE "${VISIT_VTK_DIR}/lib/site-packages/*egg*")
# because you don't need to choose your configuration up-front
# on windows, make this a custom target so they are copied to the
# correct lib/${CFG} directory
ADD_CUSTOM_TARGET(vtk_python_modules ALL)
ADD_CUSTOM_COMMAND(TARGET vtk_python_modules POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${VISIT_VTK_DIR}/lib/site-packages/vtk
${VISIT_LIBRARY_DIR}/site-packages/vtk
COMMAND ${CMAKE_COMMAND} -E copy
${VTK_EGG_FILE}
${VISIT_LIBRARY_DIR}/site-packages
COMMENT "Copying ${VISIT_VTK_DIR}/lib/site-packages to ${VISIT_LIBRARY_DIR}/site-packages/vtk"
)
ENDIF (NOT WIN32)
ENDIF(VISIT_PYTHON_FILTERS)
......@@ -152,6 +152,9 @@ avtExtremeValueAnalysisFilter::Equivalent(const AttributeGroup *a)
// Dave Pugmire, Wed Apr 11 14:53:44 EDT 2012
// Name the output scalar coming out of avtRExtremesFilter
//
// Kathleen Biagas, Fri May 4 14:05:27 PDT 2012
// Call GetVisItLibraryDirectory instead of GetVisItArchitectureDirectory.
//
// ****************************************************************************
void
......@@ -166,8 +169,7 @@ avtExtremeValueAnalysisFilter::Execute()
else if (atts.GetComputeMaxes() == ExtremeValueAnalysisAttributes::YEARLY)
f->computeMaxes = avtRExtremesFilter::YEARLY;
//f->codeDir = atts.GetRCodeDir();
std::string varchdir = GetVisItArchitectureDirectory();
std::string vlibdir = varchdir + VISIT_SLASH_CHAR + "lib" + VISIT_SLASH_CHAR + "r_support";
std::string vlibdir = GetVisItLibraryDirectory() + VISIT_SLASH_CHAR + "r_support";
std::string vlibrdir = vlibdir + VISIT_SLASH_CHAR + "Rscripts" + VISIT_SLASH_CHAR;
f->codeDir = vlibrdir;
......
......@@ -54,6 +54,9 @@
# Cyrus Harrison, Tue Apr 24 23:12:25 MDT 2012
# Added visit_utils
#
# Kathleen Biagas, Fri May 4 14:05:27 PDT 2012
# Don't change LIBRARY_OUTPUT_DIRECTORY for visitmodule if on windows.
#
#****************************************************************************/
SET(COMMON_SOURCES
......@@ -258,8 +261,11 @@ ELSE(VISIT_STATIC)
${PYTHON_LIBRARIES}
)
SET_TARGET_PROPERTIES(visitmodule PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/site-packages/visit)
IF(NOT WIN32)
SET_TARGET_PROPERTIES(visitmodule PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/site-packages/visit)
ENDIF(NOT WIN32)
IF(NOT APPLE)
SET_TARGET_PROPERTIES(visitmodule PROPERTIES INSTALL_RPATH "$ORIGIN")
......
......@@ -180,6 +180,10 @@ extern "C" VISITCLI_API int Py_Main(int, char **);
// Cyrus Harrison, Thu Apr 12 17:33:16 PDT 2012
// Update to reflect changes made in visit python module revamp.
//
// Kathleen Biagas, Fri May 4 14:05:27 PDT 2012
// Use GetVisItLibraryDirectory to find lib location.
// SetIsDevelopmentVersion when -dv encountered.
//
// ****************************************************************************
int
......@@ -329,6 +333,10 @@ main(int argc, char *argv[])
{
pyside_gui = true;
}
else if(strcmp(argv[i], "-dv") == 0)
{
SetIsDevelopmentVersion(true);
}
else
{
// Pass the array along to the visitmodule.
......@@ -372,8 +380,8 @@ main(int argc, char *argv[])
PyRun_SimpleString((char*)"from os.path import join as pjoin");
// add lib to sys.path to pickup various dylibs.
std::string varchdir = GetVisItArchitectureDirectory();
std::string vlibdir = varchdir + VISIT_SLASH_CHAR + "lib";
std::string vlibdir = GetVisItLibraryDirectory();
std::ostringstream oss;
oss << "sys.path.append(pjoin('" << vlibdir <<"','site-packages'))";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment