Skip to content
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

Fix CI #762

Merged
merged 3 commits into from
Aug 15, 2023
Merged
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: 1 addition & 4 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ jobs:
fail-fast: false
matrix:
versions:
- dist: ubuntu-20.04
python: "3.8"
catkin: indigo-devel
- dist: ubuntu-20.04
python: "3.8"
catkin: noetic-devel
Expand Down Expand Up @@ -39,7 +36,7 @@ jobs:
python -m pip install --upgrade pip
pip install .
# Fix some sphinx versions until python 3.7 support is dropped
pip install --upgrade empy 'sphinx_rtd_theme<1.2.0' 'sphinxcontrib-spelling<8.0.0' pytest nose coverage flake8 mock isort
pip install --upgrade empy sphinx_rtd_theme sphinxcontrib-spelling pytest nose coverage flake8 mock isort
- name: Set up catkin
run: |
git clone https://github.com/ros/catkin.git -b ${{ matrix.versions.catkin }} /tmp/catkin_source
Expand Down
15 changes: 1 addition & 14 deletions catkin_tools/execution/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@

MAX_LOGFILE_HISTORY = 10

if type(u'') == str:
def _encode(string):
"""Encode a Python 3 str into bytes.
:type data: str
"""
return string.encode('utf-8')
else:
def _encode(string):
"""Encode a Python 2 str into bytes.
:type data: str
"""
return string.decode('utf-8').encode('utf-8')


class IOBufferContainer(object):

Expand Down Expand Up @@ -133,7 +120,7 @@ def _encode(data):
"""Encode a Python str into bytes.
:type data: str
"""
return _encode(data)
return data.encode('utf8')

@staticmethod
def _decode(data):
Expand Down
30 changes: 24 additions & 6 deletions catkin_tools/jobs/cmake/python.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# the CMake variable PYTHON_INSTALL_DIR has the same value as the Python function catkin.builder.get_python_install_dir()

set(PYTHON_VERSION "$ENV{ROS_PYTHON_VERSION}" CACHE STRING "Specify specific Python version to use ('major.minor' or 'major')")
find_package(PythonInterp ${PYTHON_VERSION} REQUIRED)
set(PYTHON_VERSION "$ENV{ROS_PYTHON_VERSION}" CACHE STRING "Specify specific Python version to use (2 or 3)")
if("${PYTHON_VERSION}" STREQUAL "")
message(STATUS "ROS_PYTHON_VERSION not set, using default")
endif()

find_package(Python${PYTHON_VERSION} COMPONENTS Interpreter)

if("${PYTHON_VERSION}" STREQUAL "3")
set(_MAJOR ${Python3_VERSION_MAJOR})
set(_MINOR ${Python3_VERSION_MINOR})
set(_EXECUTABLE ${Python3_EXECUTABLE})
elseif("${PYTHON_VERSION}" STREQUAL "2")
set(_MAJOR ${Python2_VERSION_MAJOR})
set(_MINOR ${Python2_VERSION_MINOR})
set(_EXECUTABLE ${Python2_EXECUTABLE})
else()
set(_MAJOR ${Python_VERSION_MAJOR})
set(_MINOR ${Python_VERSION_MINOR})
set(_EXECUTABLE ${Python_EXECUTABLE})
endif()

message(STATUS "Using PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
message(STATUS "Using PYTHON_EXECUTABLE: ${_EXECUTABLE}")

set(_PYTHON_PATH_VERSION_SUFFIX "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
set(_PYTHON_PATH_VERSION_SUFFIX "${_MAJOR}.${_MINOR}")

set(enable_setuptools_deb_layout OFF)
if(EXISTS "/etc/debian_version")
Expand All @@ -18,8 +36,8 @@ if(SETUPTOOLS_DEB_LAYOUT)
set(PYTHON_PACKAGES_DIR dist-packages)
set(SETUPTOOLS_ARG_EXTRA "--install-layout=deb")
# use major version only when installing 3.x with debian layout
if("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
set(_PYTHON_PATH_VERSION_SUFFIX "${PYTHON_VERSION_MAJOR}")
if("${_MAJOR}" STREQUAL "3")
set(_PYTHON_PATH_VERSION_SUFFIX "${_MAJOR}")
endif()
else()
message(STATUS "Using default Python package layout")
Expand Down
8 changes: 4 additions & 4 deletions tests/system/verbs/catkin_build/test_pythonpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_python2_devel():
ws_pythonpath = [p for p in pythonpaths if p.startswith(wf.workspace)][0]
assert ws_pythonpath
# it might be dist-packages (debian) or site-packages
assert re.match('^' + wf.workspace + '/devel/lib/python2\.\d/(site|dist)-packages$', ws_pythonpath)
assert re.match('^' + wf.workspace + r'/devel/lib/python2\.\d/(site|dist)-packages$', ws_pythonpath)


def test_python3_devel():
Expand All @@ -55,7 +55,7 @@ def test_python3_devel():
assert ws_pythonpath
# it might be python3/dist-packages (debian) or python3.x/site-packages
assert (ws_pythonpath == wf.workspace + '/devel/lib/python3/dist-packages' or
re.match('^' + wf.workspace + '/devel/lib/python3\.\d/site-packages$', ws_pythonpath))
re.match('^' + wf.workspace + r'/devel/lib/python3\.\d/site-packages$', ws_pythonpath))


def test_python2_install():
Expand All @@ -74,7 +74,7 @@ def test_python2_install():
ws_pythonpath = [p for p in pythonpaths if p.startswith(wf.workspace)][0]
assert ws_pythonpath
# it might be dist-packages (debian) or site-packages
assert re.match('^' + wf.workspace + '/install/lib/python2\.\d/(site|dist)-packages$', ws_pythonpath)
assert re.match('^' + wf.workspace + r'/install/lib/python2\.\d/(site|dist)-packages$', ws_pythonpath)


def test_python3_install():
Expand All @@ -92,4 +92,4 @@ def test_python3_install():
assert ws_pythonpath
# it might be python3/dist-packages (debian) or python3.x/site-packages
assert (ws_pythonpath == wf.workspace + '/install/lib/python3/dist-packages' or
re.match('^' + wf.workspace + '/install/lib/python3\.\d/site-packages$', ws_pythonpath))
re.match('^' + wf.workspace + r'/install/lib/python3\.\d/site-packages$', ws_pythonpath))