Skip to content

Commit 9305080

Browse files
committed
[SymForce] Use uv for requirements
Last I tried this, uv didn't support solving for python versions other than the running interpreter; now they do (except that dependencies that don't have wheels need to get built with an actual Python interpreter). I previously had a GitHub action to build requirements for all Python versions; it was super fast (<1m) and kinda convenient, it'd just make a PR. I think I like just having the requirements test do it now though, now that it's possible to do that way. Topic: sf-uv
1 parent ce4c37b commit 9305080

14 files changed

+1561
-146
lines changed

.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=$(python -c "import sys; print(sys.version_info.minor)")
127+
python -m pip install pip==24.0 setuptools==69.5.1
128+
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
@@ -34,7 +34,9 @@ jobs:
3434
python-version: "3.8"
3535

3636
- name: Install python dependencies
37-
run: pip install -r dev_requirements.txt
37+
run: |
38+
PY_MINOR_VERSION=$(python -c "import sys; print(sys.version_info.minor)")
39+
python -m pip install -r requirements_dev_py3${PY_MINOR_VERSION}.txt
3840
3941
- name: Run cmake build
4042
run: |

.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

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ module = [
199199
"argh.*",
200200
"clang_format",
201201
"graphviz.*",
202-
"matplotlib.*",
203202
"mpl_toolkits.*",
204203
"numba.*",
205204
"ruff.*",
@@ -215,3 +214,12 @@ ignore_missing_imports = true
215214
[[tool.mypy.overrides]]
216215
module = "lcmtypes"
217216
follow_imports = "silent"
217+
218+
# matplotlib has some overly restrictive / wrong annotations, on animation.FuncAnimation. It also
219+
# requires annotating Axes3d to get proper typing
220+
[[tool.mypy.overrides]]
221+
module = "matplotlib.*"
222+
follow_imports = "skip"
223+
follow_imports_for_stubs = true
224+
# the py3.8 version of matplotlib has no type stubs, so we fully ignore it
225+
ignore_missing_imports = true

requirements_build.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This file was autogenerated by uv via the following command:
2+
# python test/symforce_requirements_test.py --update
3+
clang-format
4+
# via symforce (pyproject.toml)
5+
cmake
6+
# via symforce (pyproject.toml)
7+
cython
8+
# via symforce (pyproject.toml)
9+
graphviz
10+
# via symforce (pyproject.toml)
11+
jinja2
12+
# via symforce (pyproject.toml)
13+
numpy
14+
# via symforce (pyproject.toml)
15+
pip
16+
# via symforce (pyproject.toml)
17+
ruff
18+
# via symforce (pyproject.toml)
19+
scipy
20+
# via symforce (pyproject.toml)
21+
setuptools
22+
# via symforce (pyproject.toml)
23+
setuptools-scm
24+
# via symforce (pyproject.toml)
25+
file:./third_party/skymarshal
26+
# via symforce (pyproject.toml)
27+
file:./gen/python
28+
# via symforce (pyproject.toml)
29+
sympy
30+
# via symforce (pyproject.toml)
31+
wheel
32+
# via symforce (pyproject.toml)

0 commit comments

Comments
 (0)