Reputation: 21
I am looking to run a grpc service on a raspberry pico. This might sound outlandish to some people, specifically those who know what the problem I'm about to introduce is, but I think I could make it work with the right technical help. The problem, as some might know, is that the Pico only has 2mb of flash storage. After micropython is installed, it's only about a meg an a half. GRPC as a python dependency takes up 10 megabytes, and it's certainly not the only dependency I need. I need to cut down the size of GRPC so that only the necessary parts of it for server hosting remain, and possibly even further to only have the parts of server hosting I specifically need.
I tried cutting it down on my own, however that proves to be a harder task than I expect. Mostly it's because there is a lot that seems unnecessary, but I'm not sure if removing it causes issues. Some background on me: I have been developing in Python for 4 years. I am by no means a master, but I am far into the level of "intermediate". I will understand most things you ask, I just need someone with more experience making packages lightweight than I currently have. Normally, I'd make things lightweight by only importing what I need to use, however that is proving harder than it should be. Micropython does not use PyPi like python's pip does. It uses something called micropython-lib. There are many ways I can use that to import a package, but it would require a json package to look at. You can read more on it here: https://docs.micropython.org/en/latest/reference/packages.html So right now what I'm looking for is a way to slice grpc down to the smallest necessary size so I can use it as a dependency, or to find a new way to import it in Micropython so I only import the necessary stuff.
Upvotes: 2
Views: 800
Reputation: 91
gRPC python is wrapped on top of gRPC core, if you want to reduce the size of binary, you should consider using C++. Also, gRPC is developed as a whole library, it does provide many different APIs but under the hood they're depending on the same core functions so there won't be an easy way to only work with 'part of' gRPC python.
Upvotes: 0