Skip to content

No editable #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cmake/catkin-pip-base.req
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
# It is better here to pin packages to a verified version, especially since we are explointing a borderline usecase
# However this means we need a short maintenance cycle to not be outdated by python folks...

pip==8.1.2 # pip > 9.0 tries to remove system packages data, even if we specify /home/alexv/ROS/gopher_bootstrap/build/catkin_pip_env/bin/pip install -e /home/alexv/ROS/gopher_bootstrap/src/pyros --ignore-installed --no-dependencies --prefix /home/alexv/ROS/gopher_bootstrap/devel
# Issue : https://github.com/asmodehn/catkin_pip/issues/58
setuptools==33.1.1
pip==9.0.1
setuptools==34.2.0
10 changes: 2 additions & 8 deletions cmake/catkin-pip-package.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ function(catkin_pip_python_setup)
# Setting up variables for scripts configuration (in a function to keep it here)
set(CATKIN_PIP_PACKAGE_PATH ${package_path})

# sourcing envhooks to keep coherence between cmake run and shell run (especially for tests)
# DUPLICATED with catkin_pip_setup
#catkin_pip_runcmd(${CATKIN_PIP} install -e ${package_path} --no-dependencies --prefix "${CATKIN_DEVEL_PREFIX}")

# BEGIN : This is from catkin_python_setup
# we follow same process but with slightly different scripts
#
Expand Down Expand Up @@ -79,7 +75,7 @@ endfunction()
# TODO : we now create an actual cmake target -> rename to catkin_pip_target ?
function(catkin_pip_package package_name)

set(${PROJECT_NAME}_PIP_TARGET ${package_name} CACHE STRING "Make target generated to install this pip package as --editable for development")
set(${PROJECT_NAME}_PIP_TARGET ${package_name} CACHE STRING "Make target generated to install this pip package for development")

set (extra_macro_args ${ARGN})

Expand All @@ -95,14 +91,12 @@ function(catkin_pip_package package_name)
# Note : environment should already be setup at configure time for devel

# Then we can run the pip command
# Note when installing in editable mode (for development) we shouldnt care about already installed versions.
# Note when installing for development, we shouldn't care about already installed versions.
# However : https://github.com/asmodehn/catkin_pip/issues/58
if(CATKIN_PIP_NO_DEPS)
catkin_pip_install_devel_target(${package_name} ${package_path} --no-dependencies --ignore-installed)
#catkin_pip_runcmd(${CATKIN_PIP} install -e ${package_path} --no-dependencies --prefix "${CATKIN_DEVEL_PREFIX}" --ignore-installed)
else()
catkin_pip_install_devel_target(${package_name} ${package_path} --ignore-installed)
#catkin_pip_runcmd(${CATKIN_PIP} install -e ${package_path} --prefix "${CATKIN_DEVEL_PREFIX}" --ignore-installed)
endif()

if(NOT EXISTS ${package_path}/setup.py)
Expand Down
18 changes: 3 additions & 15 deletions cmake/catkin-pip-runcmd.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,16 @@ endfunction()

function(catkin_pip_install_devel_target package_name package_path)
set(CATKIN_PIP_INSTALL_DEVEL_OUTPUTS
# ${CATKIN_DEVEL_PREFIX}/${CATKIN_PIP_PYTHON_INSTALL_DIR}/easy-install.pth
# CAREFUL with multiple outputs : https://cmake.org/Bug/view.php?id=15116
${CATKIN_DEVEL_PREFIX}/${CATKIN_PIP_PYTHON_INSTALL_DIR}/${package_name}.egg-link
${CATKIN_DEVEL_PREFIX}/${CATKIN_PIP_PYTHON_INSTALL_DIR}/${package_name}
)

string(REPLACE ";" " " ARGN_STR "${ARGN}")

# note setlock because of https://github.com/pypa/pip/issues/2361
# TODO : change to use --target to allow installing duplicate packages with pip>=9.0.0 ... Ref https://github.com/pypa/pip/issues/4243


set(CATKIN_PIP_CMD ${CATKIN_ENV})
set(CATKIN_PIP_CMD_ARGS_STR "setlock ${CATKIN_PIP_ENV}/catkin_pip.lock ${CATKIN_PIP} install -e ${package_path} --prefix ${CATKIN_DEVEL_PREFIX} ${ARGN_STR}")
# IF WE ARE PASSING EDITABLE PKG PATHS INTO PYTHONPATH we need to work around bug :
# PYTHONPATH breaks pip install --editable Ref : https://github.com/pypa/pip/issues/4261
# set(CATKIN_PIP_CMD_ARGS_STR "-c 'export PYTHONPATH=${CATKIN_DEVEL_PREFIX}/${CATKIN_PIP_PYTHON_INSTALL_DIR}:${CATKIN_PIP_ENV}/${CATKIN_PIP_PYTHON_INSTALL_DIR}\; ${CATKIN_PIP_CMD_ARGS_STR}'")
# set(CATKIN_PIP_CMD /bin/bash) # Ubuntu (Linux?) only # Also we are probably missing some other CATKIN_ENV setup...


set(CATKIN_PIP_CMD_ARGS_STR "${CATKIN_PIP} install ${package_path} --prefix ${CATKIN_DEVEL_PREFIX} ${ARGN_STR}")
separate_arguments(CATKIN_PIP_CMD_ARGS_LIST UNIX_COMMAND ${CATKIN_PIP_CMD_ARGS_STR})


# Note that catkin_env is called first. That is because we do not trust catkin_env return code and async behavior.
# However we have to assume it doesn't alter the environment in a way that breaks setlock.
# Hint : on ubuntu trusty, I noticed the lock file stay there after execution, however the mutex behavior works fine.
Expand All @@ -79,7 +67,7 @@ function(catkin_pip_install_devel_target package_name package_path)

COMMAND ${CATKIN_PIP_CMD} ${CATKIN_PIP_CMD_ARGS_LIST}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS "${package_path}" # file level dependency : package needs to be in the path
DEPENDS "${package_path}/setup.py" # file level dependency : package setup.py needs to exists
COMMENT "${CATKIN_PIP_CMD} ${CATKIN_PIP_CMD_ARGS_STR}"
VERBATIM
)
Expand Down
16 changes: 0 additions & 16 deletions cmake/env-hooks/42.site_packages.sh.develspace.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,10 @@ if [ -d "@CATKIN_DEVEL_PREFIX@/@CATKIN_PIP_PYTHON_INSTALL_DIR@" ]; then
PYTHONPATH=$("@CATKIN_PIP_SCRIPTS_PATH@/path_prepend.sh" "@CATKIN_DEVEL_PREFIX@/@CATKIN_PIP_PYTHON_INSTALL_DIR@" "${PYTHONPATH}" "@CATKIN_DEVEL_PREFIX@/@CATKIN_PYTHON_INSTALL_DIR@") || ${PYTHONPATH} # to be safe if path_prepend fails
fi

# NOT DOING THIS any longer : it half-works but somehow doesnt change behavior when using catkin cmake scripts : usual python way, editable links are after python path
# TO FIX IT : use pyros_setup
# # Prepending here our easy-install.pth content into PYTHONPATH, for overlayed workspace to get it before the workspace path
# # Somehow Python pth/.egg behavior doesnt work well with workspace overlays, based on PYTHONPATH.
# # However be aware of : https://github.com/pypa/pip/issues/3160
# # And : https://github.com/pypa/pip/issues/4261
# if [ -f "@CATKIN_DEVEL_PREFIX@/@CATKIN_PIP_PYTHON_INSTALL_DIR@/easy-install.pth" ]; then
# # Ref : http://stackoverflow.com/questions/4165135/how-to-use-while-read-bash-to-read-the-last-line-in-a-file-if-there-s-no-new
# while IFS='' read -r DEVEL_PKG_PATH || [ -n "$DEVEL_PKG_PATH" ]; do
# #echo "Inserting $DEVEL_PKG_PATH before "@CATKIN_DEVEL_PREFIX@/@CATKIN_PIP_PYTHON_INSTALL_DIR@" into PYTHONPATH"
# PYTHONPATH=$("@CATKIN_PIP_SCRIPTS_PATH@/path_prepend.sh" "$DEVEL_PKG_PATH" "${PYTHONPATH}" "@CATKIN_DEVEL_PREFIX@/@CATKIN_PIP_PYTHON_INSTALL_DIR@") || ${PYTHONPATH} # to be safe if path_prepend fails
# done <"@CATKIN_DEVEL_PREFIX@/@CATKIN_PIP_PYTHON_INSTALL_DIR@/easy-install.pth"
# fi


# Exporting is required to make sure we get the new value in children processes (catkin_make, test runs, etc.)
export PYTHONPATH
export PATH


# resetting shell options (especially useful if sourced)
set +o nounset
set +o noglob
Expand Down
8 changes: 0 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ if (CATKIN_ENABLE_TESTING)
#########

# Testing one by one to make sure pyros_setup import doesnt influence test it shouldnt influence...
catkin_add_pytests(catkin_pip_pytest/test_easyinstallpth.py
--build-dir ${CMAKE_BINARY_DIR}
DEPENDENCIES
${mypippkg_PIP_TARGET} # from pipproject
${nameless_PIP_TARGET} # from pylibrary
${python_boilerplate_PIP_TARGET} # from pypackage
${cookiecutter_pypackage_minimal_PIP_TARGET} # from pypackage-minimal
)
catkin_add_pytests(catkin_pip_pytest/test_path.py
--build-dir ${CMAKE_BINARY_DIR}
DEPENDENCIES
Expand Down
22 changes: 0 additions & 22 deletions test/catkin_pip_pytest/test_easyinstallpth.py

This file was deleted.

29 changes: 0 additions & 29 deletions test/catkin_pip_pytest/test_syspath.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,32 +93,3 @@ def test_devel_dist_before_catkin_pip_site_in_sys_path(catkin_pip_env_dir, devel
catkin_pkgs=os.path.join(catkin_pip_env_dir, 'lib/python2.7/site-packages')
)


@pytest.mark.xfail(strict=True, reason="With usual python and catkin cmake scripts, editable links are added so sys.path after pythonpath.")
def test_sys_path_editable(git_working_tree, devel_space):
print(sys.path)

def pkg_path_in_sys_path(pkg_path, before=[]):
assert os.path.exists(pkg_path), "{pkg_path} does not exist".format(**locals())

# By default the egg-links path are added after the pythonpaths.
# We need opposite behavior for ROS python (due to how devel workspace and underlays work)
# This is handle by both catkin_pip for ROS usage and pyros_setup for python usage.

assert in_sys_path_ordered(*([pkg_path] + before)),\
"paths not appearing in sys.path in the expected order : {p}".format(p=([pkg_path] + before))

# Verifying the pip editable installed package location is in python path
for python_pkg in [
os.path.join('pipproject', 'mypippkg'),
os.path.join('pylibrary', 'python-nameless', 'src'),
os.path.join('pypackage', 'python_boilerplate'),
os.path.join('pypackage-minimal', 'cookiecutter_pypackage_minimal'),
]:

ss = os.path.join(git_working_tree, 'test', python_pkg)

pkg_path_in_sys_path(ss, [
os.path.join(devel_space, 'lib/python2.7/site-packages'),
# os.path.join(devel_space, 'lib/python2.7/dist-packages') # no dist-packages folder since all our examples are using catkin_pip
])
5 changes: 0 additions & 5 deletions test/catkin_pip_pytest/test_syspath_pyros.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,3 @@ def test_devel_site_before_catkin_pip_site_in_sys_path(pyros, catkin_pip_env_dir
def test_devel_dist_before_catkin_pip_site_in_sys_path(pyros, catkin_pip_env_dir, devel_space):
return test_syspath.test_devel_dist_before_catkin_pip_site_in_sys_path(catkin_pip_env_dir, devel_space)


# Using Pyros_setup is the only way to get this to work as expected.
# That is getting devel packages in sys.path before ROS workspaces from PYTHONPATH.
def test_sys_path_editable(pyros, git_working_tree, devel_space):
return test_syspath.test_sys_path_editable(git_working_tree, devel_space)