I have solved that problem in much the same way. I use this Python program to call the Arduino IDE to compile and upload the program. It figures out the full path name to the .ino file and includes that in the .ino file before it calls the compiler. This is the sort of thing that is in my files
Serial.println(F("Source File /mnt/sdb1/SGT-Docs/ModelRailways/RadioControl/Dubl00BPRC/ComputerControl/ArduinoCode/LocoMaster.ino"));
I use Geany to edit my program code and the Python program can be called directly from it.
...R