Issues with Compilation of Python Code using Cython for the roborio

Recently I’ve been trying to optimize a bit of python code for swerve using Cython. Ive ran into issues with compiling my files, likely as a result of pulling the python C header files from my installation of python on my desktop. (The compiler seemed to take issue with references to 64 bit integers in pythons header files, which makes sense given that the rio is 32bit) Does anyone know how I could reference the header files for python on the roborio, ideally without compiling on the rio?

If this task would be easier in linux, I have no problem with that (though a windows solution would be preferable as I don’t currently have a machine with a dev environment setup in linux).

This is the exact command I ran:

FRC-gcc -I "D:\Miniconda3\envs\FRC_2022\include" -I "C:\Users\Public\wpilib\2022\roborio\arm-frc2022-linux-gnueabi\usr\include" -I "C:\Users\Public\wpilib\2022\roborio\arm-frc2022-linux-gnueabi\usr\include\sys" -o math.so math.c 2> "log.txt"

Ive attached a log file containing the specific error my compilation attempt threw below.

log.txt (135.7 KB)

So I managed to get my files to compile, I basically just had to use robotpy/roborio-cross-ubuntu docker image and compile in that environment (it actually worked without my even having to do things manually, just a basic setup.py script following cythons docs (though i suspect cythonize might also work, if so will likely be my main method going forward). Though I wont be able to test if the generated .so file works on a rio until tomorrow.

The roborio-wheels repo compiles a bunch of wheels for the roborio using the cross docker image. https://github.com/robotpy/roborio-wheels/blob/2022/.github/workflows/wheels.yml is the set of commands that we use – note that there’s a build python and a cross python. To build for the rio you have to use the cross python.

Ok thanks. Im pretty sure that was the environment I eventually got a build to work under. The resultant file was math.cpython-310-arm-linux-gnueabi.so (which seems correct) so hopefully tomorrow I can test on the rio.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.