Skip to content

Commit 62beabb

Browse files
Add requirements.txt file for Python dependencies (backport #40) (#43)
* Add requirements.txt file for Python dependencies (#40) Signed-off-by: Carlosespicur <carlosespicur@proton.me> (cherry picked from commit 0ca6886) # Conflicts: # .github/workflows/reusable-ci.yml # README.md * Resolve conflicts and remove empy version --------- Co-authored-by: Carlos Espinoza Curto <148376273+Carlosespicur@users.noreply.github.com>
1 parent 0745990 commit 62beabb

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

.github/actions/install_python_packages/action.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ description: 'Install specified Python packages in a virtual environment'
44
inputs:
55
packages:
66
description: 'A space-separated list of Python packages to install.'
7-
required: true
7+
required: false
8+
default: ''
9+
requirements-file:
10+
description: 'Path to a requirements.txt file listing Python packages to install.'
11+
required: false
12+
default: ''
813
python-version:
914
description: 'The Python version to use (e.g., 3.12).'
1015
required: true
@@ -36,5 +41,12 @@ runs:
3641

3742
- name: Install Python packages
3843
run: |
39-
pip install ${{ inputs.packages }}
44+
if [ -n "${{ inputs.requirements-file }}" ]; then
45+
pip install -r ${{ inputs.requirements-file }}
46+
fi
47+
48+
if [ -n "${{ inputs.packages }}" ]; then
49+
pip install ${{ inputs.packages }}
50+
fi
51+
4052
shell: bash

.github/workflows/reusable-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Install required python packages
4646
uses: ./.github/actions/install_python_packages
4747
with:
48-
packages: "catkin_pkg lark-parser empy colcon-common-extensions"
48+
requirements-file: "${{ github.workspace }}/requirements.txt"
4949
python-version: ${{ inputs.python-version }}
5050
use-sudo: "true"
5151

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ sudo apt install -y rsync pip git gcc-arm-none-eabi cmake
1818
This component needs `colcon` and other Python 3 packages in order to build micro-ROS packages:
1919

2020
```bash
21-
pip3 install catkin_pkg lark-parser empy colcon-common-extensions
21+
pip3 install -r requirements.txt
2222
```
2323

2424
## Usage

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
catkin_pkg
2+
lark-parser
3+
empy
4+
colcon-common-extensions

0 commit comments

Comments
 (0)