The [attachfile](https://ctan.org/pkg/attachfile) package seems interesting. It can be used to include source code that can be extracted and used.