Skip to content

Commit 1207aa3

Browse files
committed
[SymForce] Use uv for requirements
For example: aaron-skydio#4 Topic: sf-uv
1 parent da8ea1a commit 1207aa3

14 files changed

Lines changed: 2099 additions & 73 deletions

.github/workflows/ci.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,11 @@ jobs:
121121
libgoogle-glog-dev \
122122
libeigen3-dev
123123
124-
# NOTE(aaron): Some packages do not have a version that supports py3.8..py3.12
125-
- name: Fix py3.12 versions
126-
if: ${{ matrix.python == '3.12' }}
127-
run: |
128-
sed -i 's|numba==0.58.1|numba~=0.59.0|g' dev_requirements.txt
129-
sed -i 's|llvmlite==0.41.1|llvmlite~=0.42.0|g' dev_requirements.txt
130-
sed -i 's|numpy==1.24.4|numpy~=1.26.0|g' dev_requirements.txt
131-
sed -i 's|scipy==1.10.1|scipy~=1.12.0|g' dev_requirements.txt
132-
sed -i 's|pandas==2.0.3|pandas~=2.2.0|g' dev_requirements.txt
133-
134124
- name: Install python dependencies
135-
run: pip install -r dev_requirements.txt
125+
run: |
126+
PY_MINOR_VERSION=$(${{ matrix.python }} -c "import sys; print(sys.version_info.minor)")
127+
${{ matrix.python }} -m pip install pip==24.0 setuptools==69.5.1
128+
${{ matrix.python }} -m pip install -r requirements_dev_py3${PY_MINOR_VERSION}.txt
136129
137130
- name: Run cmake build
138131
run: |
@@ -144,17 +137,11 @@ jobs:
144137
-D SYMFORCE_BUILD_BENCHMARKS=ON
145138
cmake --build build -j $(nproc)
146139
147-
# - lcmtypes need to be available for tests
148-
# - Exact contents of dev_requirements.txt depend on python version. Need to update file to
149-
# match current python version to avoid failure of corresponding gen test. symforce needs
150-
# to be on the PYTHONPATH to run gen test in this manner.
140+
# lcmtypes and symforce need to be available for tests
151141
- name: Run tests
152142
run: |
153143
pip install build/lcmtypes/python2.7
154144
export PYTHONPATH=$PYTHONPATH:$(pwd)
155-
python${{ matrix.python }} test/symforce_requirements_test.py --update
156-
echo "Modifications made to requirements:"
157-
git diff
158145
EXIT_CODE=0
159146
ctest --test-dir build -j $(nproc) || EXIT_CODE=$?
160147
if [ $EXIT_CODE -ne 0 ]; then

.github/workflows/docs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ jobs:
2323
pandoc
2424
2525
- name: Install python dependencies
26-
run: pip install -r dev_requirements.txt
26+
run: |
27+
PY_MINOR_VERSION=$(python -c "import sys; print(sys.version_info.minor)")
28+
python -m pip install -r requirements_dev_py3${PY_MINOR_VERSION}.txt
2729
2830
- name: Run cmake build
2931
run: |
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Solve Pip Requirements
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
upgrade:
7+
required: true
8+
type: boolean
9+
description: Run `uv compile` with the `--upgrade` flag
10+
default: false
11+
12+
jobs:
13+
solve:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
py_version: [8, 9, 10, 11, 12]
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.${{ matrix.py_version }}'
26+
27+
- run: |
28+
pip install uv
29+
uv pip compile --all-extras --output-file=/tmp/requirements_bootstrap.txt pyproject.toml
30+
uv venv
31+
source .venv/bin/activate
32+
uv pip install -r /tmp/requirements_bootstrap.txt
33+
34+
- run: PYTHONPATH=$(pwd) python test/symforce_requirements_test.py --update
35+
if: ${{ !github.event.inputs.upgrade }}
36+
37+
- run: PYTHONPATH=$(pwd) python test/symforce_requirements_test.py --update --piptools_upgrade
38+
if: ${{ github.event.inputs.upgrade }}
39+
40+
- uses: actions/upload-artifact@v4
41+
with:
42+
name: requirements_dev_py3${{ matrix.py_version }}
43+
path: requirements_dev_py3${{ matrix.py_version }}.txt
44+
45+
publish:
46+
runs-on: ubuntu-latest
47+
needs: solve
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- uses: actions/download-artifact@v4
52+
with:
53+
merge-multiple: true
54+
55+
- uses: peter-evans/create-pull-request@v6
56+
with:
57+
commit-message: Update Requirements
58+
title: Update Requirements
59+
body: ""

.github/workflows/test_editable_pip_install.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,10 @@ jobs:
3434
pip==${{ matrix.pip_version }} \
3535
setuptools==${{ matrix.setuptools_version }}
3636
37-
# NOTE(aaron): Some packages do not have a version that supports py3.8..py3.12
38-
- name: Fix py3.12 versions
39-
if: ${{ matrix.os == 'ubuntu-24.04' }}
37+
- name: install requirements
4038
run: |
41-
sed -i 's|numba==0.58.1|numba~=0.59.0|g' dev_requirements.txt
42-
sed -i 's|llvmlite==0.41.1|llvmlite~=0.42.0|g' dev_requirements.txt
43-
sed -i 's|numpy==1.24.4|numpy~=1.26.0|g' dev_requirements.txt
44-
sed -i 's|scipy==1.10.1|scipy~=1.12.0|g' dev_requirements.txt
45-
sed -i 's|pandas==2.0.3|pandas~=2.2.0|g' dev_requirements.txt
46-
47-
- name: install dev_requirements.txt
48-
run: python -m pip install -r dev_requirements.txt
39+
PY_MINOR_VERSION=$(python -c "import sys; print(sys.version_info.minor)")
40+
python -m pip install -r requirements_dev_py3${PY_MINOR_VERSION}.txt
4941
5042
- name: editable install
5143
run: python -m pip install -v -e .

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# NOTE(aaron): This is the minimum version for policy range support, not sure if we need newer;
77
# certainly no newer than 3.15 required. This will use NEW policies up to CMake 3.25; this should
8-
# be the maximum tested CMake version, matching dev_requirements.txt
8+
# be the maximum tested CMake version, matching requirements_dev.txt
99
cmake_minimum_required(VERSION 3.19...3.25)
1010

1111
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27)

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ pip install -e .
567567

568568
You should then [verify your installation](#verify-your-installation).
569569

570-
___Note:___ `pip install .` will not install pinned versions of SymForce's dependencies, it'll install any compatible versions. It also won't install all packages required to run all of the SymForce tests and build all of the targets (e.g. building the docs or running the linters). If you want all packages required for that, you should `pip install .[dev]` instead (or one of the other groups of extra requirements in our `setup.py`). If you additionally want pinned versions of our dependencies, which are the exact versions guaranteed by CI to pass all of our tests, you can install them from `pip install -r dev_requirements.txt`.
570+
___Note:___ `pip install .` will not install pinned versions of SymForce's dependencies, it'll install any compatible versions. It also won't install all packages required to run all of the SymForce tests and build all of the targets (e.g. building the docs or running the linters). If you want all packages required for that, you should `pip install .[dev]` instead (or one of the other groups of extra requirements in our `setup.py`). If you additionally want pinned versions of our dependencies, which are the exact versions guaranteed by CI to pass all of our tests, you can install them from `pip install -r requirements_dev_py3<version>.txt`.
571571

572572
_Note: Editable installs as root with the system python on Ubuntu (and other Debian derivatives) are broken on `setuptools<64.0.0`. This is a [bug in Debian](https://ffy00.github.io/blog/02-python-debian-and-the-install-locations/), not something in SymForce that we can fix. If this is your situation, either use a virtual environment, upgrade setuptools to a version `>=64.0.0`, or use a different installation method._
573573

@@ -576,11 +576,13 @@ _Note: Editable installs as root with the system python on Ubuntu (and other Deb
576576
If you'll be modifying the C++ parts of SymForce, you should build with CMake directly instead - this method will not install
577577
SymForce into your Python environment, so you'll need to add it to your PYTHONPATH separately.
578578

579-
Install python requirements:
579+
Install dependencies required to build and run SymForce:
580580
```bash
581-
pip install -r dev_requirements.txt
581+
pip install -r requirements_build.txt
582582
```
583583

584+
___Note:___ `requirements_build` contains only packages required to build and run symforce, but not everything recommended to develop symforce, like to run the SymForce tests and linters. For that, install the full pinned requirements using `pip install -r requirements_dev_py3<version>.txt` for your Python version.
585+
584586
Build SymForce (requires C++14 or later):
585587
```bash
586588
mkdir build

0 commit comments

Comments
 (0)