Skip to content

Commit

Permalink
use usercustomize.py in .local/lib/python*/site-packages to set custo…
Browse files Browse the repository at this point in the history
…m sys.path for both python2 and python3
  • Loading branch information
k-okada committed Oct 15, 2023
1 parent fd322d7 commit 2d6302a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
7 changes: 6 additions & 1 deletion jsk_unitree_robot/cross/build_ros1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ docker run -it --rm \
-e MAKEFLAGS=${MAKEFLAGS} \
-v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \
-v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \
-v ${PWD}/startup_scripts/usercustomize.py:/home/user/.local/lib/python2.7/site-packages/usercustomize.py:ro \
-v ${PWD}/startup_scripts/usercustomize.py:/home/user/.local/lib/python3.6/site-packages/usercustomize.py:ro \
-v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:rw \
-v ${PWD}/${SOURCE_ROOT}:/home/user/${SOURCE_ROOT}:rw \
${IMAGE_NAME}:${TARGET_MACHINE} \
Expand All @@ -74,4 +76,7 @@ docker run -it --rm \
-DEUSLISP_WITHOUT_DISPLAY=TRUE -DDISABLE_DOCUMENTATION=1 \
" 2>&1 | tee ${TARGET_MACHINE}_build_ros1.log

cp ${PWD}/startup_scripts/system_setup.bash ${HOST_INSTALL_ROOT}/
for file in system_setup.bash usercustomize.py; do
[ -d ${HOST_INSTALL_ROOT}/$file ] && rmdir ${HOST_INSTALL_ROOT}/$file
cp ${PWD}/startup_scripts/$file ${HOST_INSTALL_ROOT}/
done
2 changes: 2 additions & 0 deletions jsk_unitree_robot/cross/build_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ docker run -it --rm \
-v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:ro \
-v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \
-v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \
-v ${PWD}/startup_scripts/usercustomize.py:/home/user/.local/lib/python2.7/site-packages/usercustomize.py:ro \
-v ${PWD}/startup_scripts/usercustomize.py:/home/user/.local/lib/python3.6/site-packages/usercustomize.py:ro \
-v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \
-v ${PWD}/rosinstall_generator_unreleased.py:/home/user/rosinstall_generator_unreleased.py:ro \
${IMAGE_NAME}:${TARGET_MACHINE} \
Expand Down
6 changes: 6 additions & 0 deletions jsk_unitree_robot/cross/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ function copy_data () {
ssh-keygen -f "${HOME}/.ssh/known_hosts" -R "${hostname}" || echo "OK"
sshpass -p $PASS ssh -o StrictHostKeyChecking=no ${user}@${hostname} exit

if [[ "${TARGET_DIRECTORY}" == "System" ]]; then
sshpass -p 123 scp ${TARGET_MACHINE}_${TARGET_DIRECTORY}/usercustomize.py ${user}@${hostname}:/tmp/usercustomize.py
sshpass -p $PASS ssh -t ${user}@${hostname} "mkdir -p ~/.local/lib/python2.7/site-packages/; cp -f /tmp/usercustomize.py .local/lib/python2.7/site-packages/"
sshpass -p $PASS ssh -t ${user}@${hostname} "mkdir -p ~/.local/lib/python3.6/site-packages/; cp -f /tmp/usercustomize.py .local/lib/python3.6/site-packages/"
fi

# cehck disk space
echo "Copy ${TARGET_MACHINE}_${TARGET_DIRECTORY} ...."
echo "==="
Expand Down
2 changes: 2 additions & 0 deletions jsk_unitree_robot/cross/run_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ docker run -it --rm \
-v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:ro \
-v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \
-v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \
-v ${HOST_INSTALL_ROOT}/usercustomize.py:/home/user/.local/lib/python2.7/site-packages/usercustomize.py:ro \
-v ${HOST_INSTALL_ROOT}/usercustomize.py:/home/user/.local/lib/python3.6/site-packages/usercustomize.py:ro \
-v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \
${IMAGE_NAME}:${TARGET_MACHINE} \
bash -c "echo 'source /opt/jsk/User/user_setup.bash; env; cd /opt/jsk/User' > ~/.bashrc; exec \"\$0\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
export CMAKE_PREFIX_PATH="/opt/jsk/System/ros1_dependencies:${CMAKE_PREFIX_PATH}"
export PKG_CONFIG_PATH="/opt/jsk/System/ros1_dependencies/lib/pkgconfig:${PKG_CONFIG_PATH}"
export LD_LIBRARY_PATH="/opt/jsk/System/ros1_dependencies/lib:${LD_LIBRARY_PATH}"
export PYTHONPATH="/opt/jsk/System/ros1_dependencies/lib/python2.7/site-packages:${PYTHONPATH}"
export PATH="/opt/jsk/System/ros1_dependencies/bin:${PATH}"
# Python's sys.path is automatically set in ~/.local/lib/python2.7/usercustomize.py
# export PYTHONPATH="/opt/jsk/System/ros1_dependencies/lib/python2.7/site-packages:${PYTHONPATH}"

# GI : for gir1.2-gstreamer-1.0, which is installed by ros1_dependencies_build_scripts/0006-gstreamer
export GI_TYPELIB_PATH="/opt/jsk/System/ros1_dependencies/lib/girepository-1.0"

# Python
export LD_LIBRARY_PATH="/opt/jsk/System/Python/lib:${LD_LIBRARY_PATH}"
export PYTHONPATH="/opt/jsk/System/Python/lib/python2.7/site-packages:${PYTHONPATH}"
# Python's sys.path is automatically set in ~/.local/lib/python2.7/usercustomize.py
# export PYTHONPATH="/opt/jsk/System/Python/lib/python2.7/site-packages:${PYTHONPATH}"
export PATH="/opt/jsk/System/Python/bin:${PATH}"


0 comments on commit 2d6302a

Please sign in to comment.