How to distribute sketches with libraries to Openframe?

What a wonderful project – and so needed by this community. Thank you for working on it.

From what I know about Contributions Manager, it periodically downloads sources.conf

https://raw.githubusercontent.com/processing/processing-docs/master/contrib_generate/sources.conf

…and then gets the relevant metadata by downloading all the listed text files. So, for example, this entry:

https://github.com/atduskgreg/opencv-processing/releases/download/latest/opencv_processing.txt

However, I don’t think it knows what the include statements are or which library they belong to until it actually installs the jars in the Java path. The import statement pattern is not in the metadata. Download url, weirdly, is ALSO not in the metadata file – by convention it is the same as the metadata url, but with “zip” instead of “txt”, so you can derive the location of every download from just the sources.conf file:

https://github.com/atduskgreg/opencv-processing/releases/download/latest/opencv_processing.zip

So if you wanted to script that, you would need a lookup table, something like:

Unfortunately you would need to periodically update your lookup table if the available libraries and their urls changed in sources.conf upstream. But it would create an automagic effect – assuming that the download, unzip, and copy of a library to somewhere on the Java path doesn’t fail, of course!

Yes, sketches can contain their own libraries. In PDE, if you drag and drop a jar onto a sketch window then it is automatically copied into the /code subfolder. I believe that the sketch /code folder is in the Java path for processing-java automatically when it runs on a sketch–it has worked for me in the past.

However, some libraries can run large. quesycam is 77KB, but if you are doing a lot of work with opencv sketches, and installing it in each individual sketch, that’s 285 MB in each individual sketch. Combine that with the video library – which is 645 MB – and you could get into a situation where a user is adding a 1GB download to their Pi every time they add a single sketch. Probably not what you want, especially if these things are often on wifi.

A third option could be to pre-install / bundle a group of popular supported libraries and let anything else be handled by the /code directory. That could be a snapshot of everything in sources.conf (in Contribution Manager) or listed on the Processing libraries page at a given moment – and if you wanted to be even more comprehensive you could browse other third party libraries listed on Archive for Processing (which I run). Let me know if I can help.

1 Like