Skip to content

Commit

Permalink
Merge branch 'main' into pr-template
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-cal committed Jan 11, 2024
2 parents b54b02c + ffbdabf commit a7d3dd0
Show file tree
Hide file tree
Showing 8 changed files with 327 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
echo "::group::Begin snap install"
echo "Installing snaps in the background while running apt and pip..."
sudo snap install --no-wait --classic pyright
sudo snap install --no-wait --classic pyright --revision 735 # version 1.1.344
sudo snap install --no-wait shellcheck
echo "::endgroup::"
echo "::group::apt-get update"
Expand Down
45 changes: 22 additions & 23 deletions requirements-devel.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
astroid==2.15.8
attrs==23.1.0
black==23.11.0
attrs==23.2.0
black==23.12.1
cachetools==5.3.2
catkin-pkg==1.0.0
certifi==2023.11.17
Expand All @@ -10,56 +10,56 @@ charset-normalizer==3.3.2
click==8.1.7
codespell==2.2.6
colorama==0.4.6
coverage==7.3.2
coverage==7.4.0
craft-archives==1.1.3
craft-cli==2.5.0
craft-grammar==1.1.1
craft-parts==1.26.0
craft-grammar==1.1.2
craft-parts==1.26.1
craft-providers==1.20.1
craft-store==2.5.0
craft-store==2.6.0
cryptography==41.0.7
Deprecated==1.2.14
dill==0.3.7
distlib==0.3.7
distro==1.8.0
distlib==0.3.8
distro==1.9.0
docutils==0.19
filelock==3.13.1
fixtures==4.1.0
gnupg==2.3.1
httplib2==0.22.0
hupper==1.12
idna==3.6
importlib-metadata==7.0.0
importlib-metadata==7.0.1
iniconfig==2.0.0
isort==5.12.0
isort==5.13.2
jaraco.classes==3.3.0
jeepney==0.8.0
jsonschema==2.5.1
keyring==24.3.0
launchpadlib==1.11.0
lazr.restfulclient==0.14.5
lazr.uri==1.0.6
lazy-object-proxy==1.9.0
lxml==4.9.3
macaroonbakery==1.3.1
lazy-object-proxy==1.10.0
lxml==5.0.0
macaroonbakery==1.3.4
mccabe==0.7.0
more-itertools==10.1.0
mypy==1.7.1
mypy==1.8.0
mypy-extensions==1.0.0
oauthlib==3.2.2
overrides==7.4.0
packaging==23.2
PasteDeploy==3.1.0
pathspec==0.11.2
pathspec==0.12.1
pbr==6.0.0
pexpect==4.9.0
plaster==1.1.2
plaster-pastedeploy==1.0.1
platformdirs==4.0.0
platformdirs==4.1.0
pluggy==1.3.0
progressbar==2.5
protobuf==3.20.3
psutil==5.9.6
psutil==5.9.7
ptyprocess==0.7.0
pycodestyle==2.11.1
pycparser==2.21
Expand All @@ -72,15 +72,15 @@ pyftpdlib==1.5.9
pygit2==1.13.3
pylint==2.17.7
pylint-fixme-info==1.0.3
pylint-pytest==1.1.6
pylint-pytest==1.1.7
pylxd==2.3.1
pymacaroons==0.13.0
PyNaCl==1.5.0
pyparsing==3.1.1
pyproject-api==1.6.1
pyramid==2.0.2
pyRFC3339==1.1
pytest==7.4.3
pytest==7.4.4
pytest-cov==4.1.0
pytest-mock==3.12.0
pytest-subprocess==1.5.0
Expand All @@ -93,7 +93,7 @@ raven==6.10.0
requests==2.31.0
requests-toolbelt==1.0.0
requests-unixsocket==0.3.0
ruff==0.1.6
ruff==0.1.11
SecretStorage==3.3.3
simplejson==3.19.2
six==1.16.0
Expand All @@ -115,10 +115,10 @@ types-simplejson==3.19.0.2
types-tabulate==0.9.0.3
types-toml==0.10.8.7
types-urllib3==1.26.25.14
typing_extensions==4.8.0
typing_extensions==4.9.0
urllib3==1.26.18
venusian==3.1.0
virtualenv==20.24.7
virtualenv==20.25.0
wadllib==1.3.6
WebOb==1.8.7
wrapt==1.16.0
Expand All @@ -128,5 +128,4 @@ zipp==3.17.0
zope.deprecation==5.0
zope.interface==6.1
python-apt @ https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/python-apt/2.4.0ubuntu1/python-apt_2.4.0ubuntu1.tar.xz; sys.platform == "linux"
setuptools<66
pyinstaller==5.13.1; sys.platform == "win32"
23 changes: 11 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
attrs==23.1.0
attrs==23.2.0
catkin-pkg==1.0.0
certifi==2023.11.17
cffi==1.16.0
Expand All @@ -7,36 +7,36 @@ charset-normalizer==3.3.2
click==8.1.7
craft-archives==1.1.3
craft-cli==2.5.0
craft-grammar==1.1.1
craft-parts==1.26.0
craft-grammar==1.1.2
craft-parts==1.26.1
craft-providers==1.20.1
craft-store==2.5.0
craft-store==2.6.0
cryptography==41.0.7
Deprecated==1.2.14
distro==1.8.0
distro==1.9.0
docutils==0.19
gnupg==2.3.1
httplib2==0.22.0
idna==3.6
importlib-metadata==7.0.0
importlib-metadata==7.0.1
jaraco.classes==3.3.0
jeepney==0.8.0
jsonschema==2.5.1
keyring==24.3.0
launchpadlib==1.11.0
lazr.restfulclient==0.14.5
lazr.uri==1.0.6
lxml==4.9.3
macaroonbakery==1.3.1
lxml==5.0.0
macaroonbakery==1.3.4
more-itertools==10.1.0
mypy-extensions==1.0.0
oauthlib==3.2.2
overrides==7.4.0
packaging==23.2
platformdirs==4.0.0
platformdirs==4.1.0
progressbar==2.5
protobuf==3.20.3
psutil==5.9.6
psutil==5.9.7
pycparser==2.21
pydantic==1.10.13
pydantic-yaml==0.11.2
Expand Down Expand Up @@ -65,11 +65,10 @@ tinydb==4.8.0
toml==0.10.2
types-Deprecated==1.2.9.3
types-PyYAML==6.0.12.12
typing_extensions==4.8.0
typing_extensions==4.9.0
urllib3==1.26.18
wadllib==1.3.6
wrapt==1.16.0
ws4py==0.5.1
zipp==3.17.0
python-apt @ https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/python-apt/2.4.0ubuntu1/python-apt_2.4.0ubuntu1.tar.xz; sys.platform == "linux"
setuptools<66
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def recursive_data_files(directory, install_directory):
"pydocstyle",
"pyftpdlib",
"pyinstaller; sys_platform == 'win32'",
"pylint",
"pylint<3",
"pylint-fixme-info",
"pylint-pytest",
"pyramid",
Expand Down
11 changes: 10 additions & 1 deletion snapcraft/parts/plugins/colcon_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,16 @@ def _get_build_commands(self) -> List[str]:
if options.colcon_packages:
build_command.extend(["--packages-select", *options.colcon_packages])

if options.colcon_cmake_args:
# compile in release only if user did not set the build type in cmake-args
if not any("-DCMAKE_BUILD_TYPE=" in s for s in options.colcon_cmake_args):
build_command.extend(
[
"--cmake-args",
"-DCMAKE_BUILD_TYPE=Release",
*options.colcon_cmake_args,
]
)
elif len(options.colcon_cmake_args) > 0:
build_command.extend(["--cmake-args", *options.colcon_cmake_args])

if options.colcon_ament_cmake_args:
Expand Down
7 changes: 6 additions & 1 deletion snapcraft_legacy/plugins/v2/colcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ def _get_build_commands(self) -> List[str]:
if self.options.colcon_packages:
build_command.extend(["--packages-select", *self.options.colcon_packages])

if self.options.colcon_cmake_args:
# compile in release only if user did not set the build type in cmake-args
if not any("-DCMAKE_BUILD_TYPE=" in s for s in self.options.colcon_cmake_args):
build_command.extend(["--cmake-args", "-DCMAKE_BUILD_TYPE=Release",
*self.options.colcon_cmake_args
])
elif len(self.options.colcon_cmake_args)>0:
build_command.extend(["--cmake-args", *self.options.colcon_cmake_args])

if self.options.colcon_ament_cmake_args:
Expand Down
135 changes: 134 additions & 1 deletion tests/legacy/unit/plugins/v2/test_colcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class Options:
"colcon build "
'--base-paths "${SNAPCRAFT_PART_SRC_WORK}" --build-base "${SNAPCRAFT_PART_BUILD}" '
'--merge-install --install-base "${SNAPCRAFT_PART_INSTALL}"/opt/ros/snap '
"--cmake-args -DCMAKE_BUILD_TYPE=Release "
'--parallel-workers "${SNAPCRAFT_PARALLEL_BUILD_COUNT}"',
"## Post build command",
'if [ -f "${SNAPCRAFT_PART_INSTALL}"/opt/ros/snap/COLCON_IGNORE ]; then',
Expand Down Expand Up @@ -310,7 +311,139 @@ class Options:
'--base-paths "${SNAPCRAFT_PART_SRC_WORK}" --build-base "${SNAPCRAFT_PART_BUILD}" '
'--merge-install --install-base "${SNAPCRAFT_PART_INSTALL}"/opt/ros/snap '
"--packages-ignore ipackage1 ipackage2... --packages-select package1 "
"package2... --cmake-args cmake args... "
"package2... --cmake-args -DCMAKE_BUILD_TYPE=Release cmake args... "
"--ament-cmake-args ament args... --catkin-cmake-args catkin "
'args... --parallel-workers "${SNAPCRAFT_PARALLEL_BUILD_COUNT}"',
"## Post build command",
'if [ -f "${SNAPCRAFT_PART_INSTALL}"/opt/ros/snap/COLCON_IGNORE ]; then',
'rm "${SNAPCRAFT_PART_INSTALL}"/opt/ros/snap/COLCON_IGNORE',
"fi",
"env -i LANG=C.UTF-8 LC_ALL=C.UTF-8 PATH=/bin:/test SNAP=TESTSNAP "
"SNAP_ARCH=TESTARCH SNAP_NAME=TESTSNAPNAME SNAP_VERSION=TESTV1 "
"http_proxy=http://foo https_proxy=https://bar "
"/test/python3 -I /test/_ros.py "
'stage-runtime-dependencies --part-src "${SNAPCRAFT_PART_SRC_WORK}" --part-install "${SNAPCRAFT_PART_INSTALL}" '
'--ros-version "${ROS_VERSION}" --ros-distro "${ROS_DISTRO}" --target-arch "${SNAPCRAFT_TARGET_ARCH}"',
]


def test_get_build_commands_with_cmake_debug(monkeypatch):
class Options:
colcon_ament_cmake_args = ["ament", "args..."]
colcon_catkin_cmake_args = ["catkin", "args..."]
colcon_cmake_args = ["-DCMAKE_BUILD_TYPE=Debug", "args..."]
colcon_packages = ["package1", "package2..."]
colcon_packages_ignore = ["ipackage1", "ipackage2..."]
ros_build_snaps = ["foo"]

plugin = colcon.ColconPlugin(part_name="my-part", options=Options())

monkeypatch.setattr(sys, "path", ["", "/test"])
monkeypatch.setattr(sys, "executable", "/test/python3")
monkeypatch.setattr(_ros, "__file__", "/test/_ros.py")
monkeypatch.setattr(
os,
"environ",
dict(
FOO="baR",
PATH="/bin:/test",
SNAP="TESTSNAP",
SNAP_ARCH="TESTARCH",
SNAP_NAME="TESTSNAPNAME",
SNAP_VERSION="TESTV1",
http_proxy="http://foo",
https_proxy="https://bar",
),
)

assert plugin.get_build_commands() == [
"if [ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then",
"sudo --preserve-env=http_proxy,https_proxy rosdep init; fi",
'rosdep update --include-eol-distros --rosdistro "${ROS_DISTRO}"',
'state="$(set +o); set -$-"',
"set +u",
"",
"## Sourcing ROS ws in build snaps",
'if [ -f "/snap/foo/current/opt/ros/${ROS_DISTRO}/local_setup.sh" ]; then',
'AMENT_CURRENT_PREFIX="/snap/foo/current/opt/ros/${ROS_DISTRO}" . "/snap/foo/current/opt/ros/${ROS_DISTRO}/local_setup.sh"',
"fi",
'if [ -f "/snap/foo/current/opt/ros/snap/local_setup.sh" ]; then',
'COLCON_CURRENT_PREFIX="/snap/foo/current/opt/ros/snap" . "/snap/foo/current/opt/ros/snap/local_setup.sh"',
"fi",
"",
"## Sourcing ROS ws in stage snaps",
'if [ -f "${SNAPCRAFT_PART_INSTALL}/opt/ros/${ROS_DISTRO}/local_setup.sh" ]; then',
'AMENT_CURRENT_PREFIX="${SNAPCRAFT_PART_INSTALL}/opt/ros/${ROS_DISTRO}" . "${SNAPCRAFT_PART_INSTALL}/opt/ros/${ROS_DISTRO}/local_setup.sh"',
"fi",
'if [ -f "${SNAPCRAFT_PART_INSTALL}/opt/ros/snap/local_setup.sh" ]; then',
'COLCON_CURRENT_PREFIX="${SNAPCRAFT_PART_INSTALL}/opt/ros/snap" . "${SNAPCRAFT_PART_INSTALL}/opt/ros/snap/local_setup.sh"',
"fi",
"",
"## Sourcing ROS ws in system",
'if [ -f "/opt/ros/${ROS_DISTRO}/local_setup.sh" ]; then',
'AMENT_CURRENT_PREFIX="/opt/ros/${ROS_DISTRO}" . "/opt/ros/${ROS_DISTRO}/local_setup.sh"',
"fi",
'if [ -f "/opt/ros/snap/local_setup.sh" ]; then',
'COLCON_CURRENT_PREFIX="/opt/ros/snap" . "/opt/ros/snap/local_setup.sh"',
"fi",
"",
'eval "${state}"',
'rm -f "${SNAPCRAFT_PART_INSTALL}/.installed_packages.txt"',
'rm -f "${SNAPCRAFT_PART_INSTALL}/.build_snaps.txt"',
"if [ -d /snap/foo/current/opt/ros ]; then",
"ROS_PACKAGE_PATH=/snap/foo/current/opt/ros rospack list-names | (xargs "
'rosdep resolve --rosdistro "${ROS_DISTRO}" || echo "") | awk '
'"/#apt/{getline;print;}" >> '
'"${SNAPCRAFT_PART_INSTALL}/.installed_packages.txt"',
"fi",
'if [ -d "/snap/foo/current/opt/ros/${ROS_DISTRO}/" ]; then',
'rosdep keys --rosdistro "${ROS_DISTRO}" --from-paths '
'"/snap/foo/current/opt/ros/${ROS_DISTRO}" --ignore-packages-from-source | '
'(xargs rosdep resolve --rosdistro "${ROS_DISTRO}" || echo "") | grep -v "#" '
'>> "${SNAPCRAFT_PART_INSTALL}"/.installed_packages.txt',
"fi",
'if [ -d "/snap/foo/current/opt/ros/snap/" ]; then',
'rosdep keys --rosdistro "${ROS_DISTRO}" --from-paths '
'"/snap/foo/current/opt/ros/snap" --ignore-packages-from-source | (xargs '
'rosdep resolve --rosdistro "${ROS_DISTRO}" || echo "") | grep -v "#" >> '
'"${SNAPCRAFT_PART_INSTALL}"/.installed_packages.txt',
"fi",
"",
'rosdep install --default-yes --ignore-packages-from-source --from-paths "${SNAPCRAFT_PART_SRC_WORK}"',
'state="$(set +o); set -$-"',
"set +u",
"",
"## Sourcing ROS ws in build snaps",
'if [ -f "/snap/foo/current/opt/ros/${ROS_DISTRO}/local_setup.sh" ]; then',
'AMENT_CURRENT_PREFIX="/snap/foo/current/opt/ros/${ROS_DISTRO}" . "/snap/foo/current/opt/ros/${ROS_DISTRO}/local_setup.sh"',
"fi",
'if [ -f "/snap/foo/current/opt/ros/snap/local_setup.sh" ]; then',
'COLCON_CURRENT_PREFIX="/snap/foo/current/opt/ros/snap" . "/snap/foo/current/opt/ros/snap/local_setup.sh"',
"fi",
"",
"## Sourcing ROS ws in stage snaps",
'if [ -f "${SNAPCRAFT_PART_INSTALL}/opt/ros/${ROS_DISTRO}/local_setup.sh" ]; then',
'AMENT_CURRENT_PREFIX="${SNAPCRAFT_PART_INSTALL}/opt/ros/${ROS_DISTRO}" . "${SNAPCRAFT_PART_INSTALL}/opt/ros/${ROS_DISTRO}/local_setup.sh"',
"fi",
'if [ -f "${SNAPCRAFT_PART_INSTALL}/opt/ros/snap/local_setup.sh" ]; then',
'COLCON_CURRENT_PREFIX="${SNAPCRAFT_PART_INSTALL}/opt/ros/snap" . "${SNAPCRAFT_PART_INSTALL}/opt/ros/snap/local_setup.sh"',
"fi",
"",
"## Sourcing ROS ws in system",
'if [ -f "/opt/ros/${ROS_DISTRO}/local_setup.sh" ]; then',
'AMENT_CURRENT_PREFIX="/opt/ros/${ROS_DISTRO}" . "/opt/ros/${ROS_DISTRO}/local_setup.sh"',
"fi",
'if [ -f "/opt/ros/snap/local_setup.sh" ]; then',
'COLCON_CURRENT_PREFIX="/opt/ros/snap" . "/opt/ros/snap/local_setup.sh"',
"fi",
"",
'eval "${state}"',
"## Build command",
"colcon build "
'--base-paths "${SNAPCRAFT_PART_SRC_WORK}" --build-base "${SNAPCRAFT_PART_BUILD}" '
'--merge-install --install-base "${SNAPCRAFT_PART_INSTALL}"/opt/ros/snap '
"--packages-ignore ipackage1 ipackage2... --packages-select package1 "
"package2... --cmake-args -DCMAKE_BUILD_TYPE=Debug args... "
"--ament-cmake-args ament args... --catkin-cmake-args catkin "
'args... --parallel-workers "${SNAPCRAFT_PARALLEL_BUILD_COUNT}"',
"## Post build command",
Expand Down

0 comments on commit a7d3dd0

Please sign in to comment.