Skip to content

Commit d131092

Browse files
committed
Update build.yaml and install.sh for improved Python version handling and pip installation
1 parent a436695 commit d131092

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version_ubuntu-latest: ["3.10", 3.11]
10+
python-version: ["3.10", "3.11", "3.12"]
1111

1212
steps:
1313
- uses: actions/[email protected]
1414

15-
- name: Set up Python ${{ matrix.python-version_ubuntu-latest }}
15+
- name: Set up Python ${{ matrix.python-version }}
1616
uses: actions/[email protected]
1717
with:
18-
python-version: ${{ matrix.python-version_ubuntu-latest }}
18+
python-version: ${{ matrix.python-version }}
1919

2020
- name: Install dependencies
2121
run: python -m pip install --upgrade pip setuptools wheel
@@ -54,7 +54,7 @@ jobs:
5454
run: pip install pre-commit
5555

5656
- name: pre-commit cache
57-
uses: actions/cache@v3.3.2
57+
uses: actions/cache@v4
5858
with:
5959
path: ~/.cache/pre-commit
6060
key: "${{ hashFiles('.pre-commit-config.yaml') }}"

install.sh

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -euo pipefail
23

34
if [ ! -d venv ]; then
45
for p in "py -3.8" "py -3" "python3.8" "python3" "python"; do
@@ -10,11 +11,35 @@ if [ ! -d venv ]; then
1011
${pycmd:?Could not determine python executable} -m venv venv
1112
fi
1213

13-
if [ "$GIT_ACTION" = true ]; then
14-
venv/*/pip install -e .
15-
venv/*/pip install --find-links wheels -e .
16-
else
17-
venv/*/pip install -e src/ros2model
14+
shopt -s nullglob
15+
pip_candidates=(venv/bin/pip venv/*/pip)
16+
pip_cmd=""
17+
for candidate in "${pip_candidates[@]}"; do
18+
if [ -x "$candidate" ]; then
19+
pip_cmd="$candidate"
20+
break
21+
fi
22+
done
23+
shopt -u nullglob
24+
25+
if [ -z "$pip_cmd" ]; then
26+
echo "Could not locate pip inside the virtual environment." >&2
27+
exit 1
28+
fi
1829

19-
venv/*/pip install --find-links wheels -e src/ros2model
30+
extra_args=()
31+
if [ -d wheels ] && compgen -G "wheels/*" > /dev/null; then
32+
extra_args=(--find-links wheels)
33+
fi
34+
35+
if [ "${GIT_ACTION:-false}" = true ]; then
36+
"$pip_cmd" install -e .
37+
if [ "${#extra_args[@]}" -gt 0 ]; then
38+
"$pip_cmd" install "${extra_args[@]}" -e .
39+
fi
40+
else
41+
"$pip_cmd" install -e src/ros2model
42+
if [ "${#extra_args[@]}" -gt 0 ]; then
43+
"$pip_cmd" install "${extra_args[@]}" -e src/ros2model
44+
fi
2045
fi

0 commit comments

Comments
 (0)