ggarg118
Posts: 15
Joined: Thu May 31, 2018 8:04 am

Cross Compilation Tool for Python

Mon Sep 03, 2018 5:42 pm

folks.. I am looking for some IDE that i can install on my PC and cross compile and debug code on RPI. Any Suggestions??

User avatar
liudr
Posts: 685
Joined: Sat Jun 01, 2013 12:11 am
Location: Central MN, USA
Contact: Website

Re: Cross Compilation Tool for Python

Wed Sep 05, 2018 4:37 am

As far as I know, Python code requires an interpreter to run. It doesn't compile into machine-specific code like C/C++. Cross compilation is only relevant to languages that compile into machine-specific code. You set up a compiler that turns source into machine-specific code that runs on an OS or CPU architecture different than the one the compiler runs on, such as compiler running on x86 generating machine code for arm, atmega, pic, etc.

So your question requires further clarification: what do you really want to do? Developing python project on PC and deploying code on RPI? Hardware-specific resources such as GPIOs, interface buses (SPI, I2C etc.) are not available on a PC so you can't develop code on PC that relies on RPI-only hardware.
Arduino data loggers, user interface, printed circuit board designer since 2009, RPI 3B 2B 2B Zero Jessie, assembly/C/C++/java/python programmer since the 80's

ggarg118
Posts: 15
Joined: Thu May 31, 2018 8:04 am

Re: Cross Compilation Tool for Python

Wed Sep 05, 2018 5:19 am

liudr wrote:
Wed Sep 05, 2018 4:37 am
So your question requires further clarification: what do you really want to do? Developing python project on PC and deploying code on RPI? Hardware-specific resources such as GPIOs, interface buses (SPI, I2C etc.) are not available on a PC so you can't develop code on PC that relies on RPI-only hardware.
The way you program your microcontroller, you write every where on your PC and then push to the remote hardware. I am looking for similar kind of Tool. Recently got to know about this feature in Visual Studio. But not sure how it works

Heater
Posts: 14430
Joined: Tue Jul 17, 2012 3:02 pm

Re: Cross Compilation Tool for Python

Wed Sep 05, 2018 6:15 am

Something I do quite often is to develop on the laptop or PC and then copy the working code to a Pi using git.

1) Develop the program on a PC or laptop and keep it in a git repository which gets pushed to github https://github.com/ or bitbucket https://bitbucket.org/ Both of which can be used for free for your personal open source projects.

2) When the program is in a runnable state and somewhat tested use git on the Pi to pull the code down from the github/bitbucket repository.

3) Perhaps some bugs get fixed when testing on the Pi. Just check them into git and push them up to github/bitbucket

4) Those changes can then be pulled to the PC/laptop and further work done on the program there.

Obviously when developing on the PC the Pi specific features are not there, GPIO etc. That's OK just make little "fake" modules that simulate those interfaces. They can be used for getting known test data into your program for testing and observing what comes out.
Memory in C++ is a leaky abstraction .

User avatar
liudr
Posts: 685
Joined: Sat Jun 01, 2013 12:11 am
Location: Central MN, USA
Contact: Website

Re: Cross Compilation Tool for Python

Wed Sep 05, 2018 2:29 pm

OK, so you want experience programming Arduino to translate into programming raspberry pi? The PC doesn't have rpi's hardware. Like Heater said, do some fake modules to accommodate the code. Rather, I suggest you to NOT use ANY RPI hardware if possible. Instead, connect an arduino to raspberry pi and let arduino do the hardware things. This way you can have the same arduino on your PC for project development and move it to rpi for tests and deployment. It depends on your objective. If you only want your project to run on rpi and no other SBC platforms such as Beagle Bone Black etc. and you can go ahead develop for rpi only. If there are chances of deploying your projects on other SBCs that might not have the same python modules or hardware arrangement as rpi, you're looking at developing several variations of your project, not a pretty thing.

Just curious, do you mind using VNC to connect to your rpi from PC to develop your project on rpi? That shouldn't be very sluggish if you're using your PC and rpi on the same home network. You can also use teamviewer for remote access.
Arduino data loggers, user interface, printed circuit board designer since 2009, RPI 3B 2B 2B Zero Jessie, assembly/C/C++/java/python programmer since the 80's

hippy
Posts: 6709
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Cross Compilation Tool for Python

Wed Sep 05, 2018 7:20 pm

I tend to develop on my PC then copy code to the Pi. In most cases that's fine but it can be a pain when interfacing with hardware on the Pi or using libraries and calling utilities which don't exist on a PC. Faking it doesn't always cut it.

I may be mistaken but I think it was the debugging part which the OP was most interested in having; being able to run code on the Pi and see what it's doing remotely, back at the desktop PC the code was developed on.

One can use SSH or Telnet with traditional "print" statement and log file debugging to figure out what's going on or wrongly but being able to put breakpoints and single-step Python code running on the Pi, look at what variables hold etc, back at the desktop, would be nice, would have made life much easier for me at times.

I don't know of anything which can do that but would be interested to hear what there is.

User avatar
Paeryn
Posts: 2805
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Cross Compilation Tool for Python

Wed Sep 05, 2018 8:39 pm

hippy wrote:
Wed Sep 05, 2018 7:20 pm
I may be mistaken but I think it was the debugging part which the OP was most interested in having; being able to run code on the Pi and see what it's doing remotely, back at the desktop PC the code was developed on.

One can use SSH or Telnet with traditional "print" statement and log file debugging to figure out what's going on or wrongly but being able to put breakpoints and single-step Python code running on the Pi, look at what variables hold etc, back at the desktop, would be nice, would have made life much easier for me at times.

I don't know of anything which can do that but would be interested to hear what there is.
Python comes with its own debugging module pdb which allows you do to all that. If you ssh in to the RPi from your PC then you have the remote debugging of your python program.
She who travels light — forgot something.

ggarg118
Posts: 15
Joined: Thu May 31, 2018 8:04 am

Re: Cross Compilation Tool for Python

Mon Sep 10, 2018 2:02 am

hippy wrote:
Wed Sep 05, 2018 7:20 pm

One can use SSH or Telnet with traditional "print" statement and log file debugging to figure out what's going on or wrongly but being able to put breakpoints and single-step Python code running on the Pi, look at what variables hold etc, back at the desktop, would be nice, would have made life much easier for me at times.

I don't know of anything which can do that but would be interested to hear what there is.
Recently come to know about Visual studio supporting such remote debugging on Pi hardware through ptvsd server running on linux machine. Although couldn't get into that till yet, but once got succeed will share here for sure

Return to “Python”