Skip to content

Commit

Permalink
windows: Fix various path issues
Browse files Browse the repository at this point in the history
PYTHONPATH needs to be separated by ';', not ':' now.  It used to work,
not sure what changed.

Make sure all the local PATH things come first.

Load DLL pathces with os.add_dll_directory() in reverse PATH order.
Testing shows that it searches the last added directory first, loading
in reverse order preserves the PATH order.

Signed-off-by: Corey Minyard <[email protected]>
  • Loading branch information
cminyard committed Jan 20, 2024
1 parent 0f69fe1 commit 728f520
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
8 changes: 6 additions & 2 deletions c++/swig/pygensio/tests/runtest.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ else
fi

if ${PYTHON_MODE}; then
export PYTHONPATH=${BUILDDIR}/tests:${BUILDDIR}/c++/swig/pygensio:${BUILDDIR}/c++/swig/pygensio/.libs:${SRCDIR}/c++/swig/pygensio/test:${BUILDDIR}/glib/c++/swig/pygensio:${BUILDDIR}/glib/c++/swig/pygensio/.libs:${BUILDDIR}/tcl/c++/swig/pygensio:${BUILDDIR}/tcl/c++/swig/pygensio/.libs:${TEST_BUILDDIR}
export PYTHONPATH="${BUILDDIR}/tests:${BUILDDIR}/c++/swig/pygensio:${BUILDDIR}/c++/swig/pygensio/.libs:${SRCDIR}/c++/swig/pygensio/test:${BUILDDIR}/glib/c++/swig/pygensio:${BUILDDIR}/glib/c++/swig/pygensio/.libs:${BUILDDIR}/tcl/c++/swig/pygensio:${BUILDDIR}/tcl/c++/swig/pygensio/.libs:${TEST_BUILDDIR}"
if [ ! -z "$MSYSTEM" ]; then
# PYTHONPATH is separated by ; on windows
export PYTHONPATH=`echo ${PYTHONPATH} | tr ':' ';'`
fi
TEST="${PYTHON} ${TEST}"
export GENSIO_MEMTRACK=abort
else
Expand All @@ -66,7 +70,7 @@ fi

# We need to put the DLL in PATH for MSYS on Windows
if [ ! -z "$MSYSTEM" ]; then
export PATH=${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:${BUILDDIR}/c++/lib/.libs:${BUILDDIR}/c++/swig/pygensio/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/glib/c++/swig/pygensio/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/tcl/c++/swig/pygensio/.libs:$PATH
export PATH="${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:${BUILDDIR}/c++/lib/.libs:${BUILDDIR}/c++/swig/pygensio/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/glib/c++/swig/pygensio/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/tcl/c++/swig/pygensio/.libs:$PATH"
else
export LD_LIBRARY_PATH=${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:${BUILDDIR}/c++/swig/pygensio/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/glib/c++/pygensio/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/tcl/c++/pygensio/.libs:${BUILDDIR}/c++/lib/.libs
fi
Expand Down
4 changes: 3 additions & 1 deletion c++/swig/pygensio/tests/testbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def fix_dll_path():
if not path:
return
paths = path.split(";")
for folder in paths:
# The patches added below are search last added first. So preserved
# the DLL order by putting them in backwards.
for folder in reversed(paths):
if os.path.exists(folder):
os.add_dll_directory(folder)

Expand Down
10 changes: 7 additions & 3 deletions tests/runtest.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ else
fi

if ${PYTHON_MODE}; then
export PYTHONPATH=${BUILDDIR}/swig/python:${BUILDDIR}/swig/python/.libs:${BUILDDIR}/glib/swig/python:${BUILDDIR}/glib/swig/python/.libs:${BUILDDIR}/tcl/swig/python:${BUILDDIR}/tcl/swig/python/.libs:${TEST_BUILDDIR}
export PYTHONPATH="${BUILDDIR}/swig/python:${BUILDDIR}/swig/python/.libs:${BUILDDIR}/glib/swig/python:${BUILDDIR}/glib/swig/python/.libs:${BUILDDIR}/tcl/swig/python:${BUILDDIR}/tcl/swig/python/.libs:${TEST_BUILDDIR}"
if [ ! -z "$MSYSTEM" ]; then
# PYTHONPATH is separated by ; on windows
export PYTHONPATH=`echo ${PYTHONPATH} | tr ':' ';'`
fi
TEST="${PYTHON} ${TEST}"
export GENSIO_MEMTRACK=abort
else
Expand All @@ -66,7 +70,7 @@ fi

# We need to put the DLL in PATH for MSYS on Windows
if [ ! -z "$MSYSTEM" ]; then
export PATH=${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:$PATH:${BUILDDIR}/glib/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/swig/python/.libs
export PATH="${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/swig/python/.libs:$PATH"
else
export LD_LIBRARY_PATH=${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/tcl/.libs:${BUILDDIR}/swig/python/.libs
fi
Expand All @@ -77,7 +81,7 @@ fi
if ${PRINT_MODE}; then
echo export PYTHONPATH="${PYTHONPATH}"
if [ ! -z "$MSYSTEM" ]; then
echo export PATH=${BUILDDIR}/lib:${BUILDDIR}/lib/.libs:\$PATH:${BUILDDIR}/swig/python/.libs:${BUILDDIR}/glib/.libs:${BUILDDIR}/tcl/.libs
echo export PATH="${PATH}"
else
echo export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"
fi
Expand Down
4 changes: 3 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def fix_dll_path():
if not path:
return
paths = path.split(";")
for folder in paths:
# The patches added below are search last added first. So preserved
# the DLL order by putting them in backwards.
for folder in reversed(paths):
if os.path.exists(folder):
os.add_dll_directory(folder)

Expand Down

0 comments on commit 728f520

Please sign in to comment.