How to install Python Library examples in a Debian Package

If you’re packaging Python Libraries into Debian, you’ll someday or the other encounter a lot of libraries using different files and folders such as tests and examples.

While tests are automatically handled by dh_python helper tools, examples are usually not and you’ll have to manually configure your setup to install python library examples, let me show you how.

For this, we need to create a new file inside the Debian folder called package.examples. Here, “package” refers to your package that will install the examples. Since we’re installing the examples of a python library, your file should be titled “python3-packagename.examples”.

Now all you have to do is just insert the directory of the examples folder into this file.

examples/*

That’s it. Now when you run sbuild or pbuilder again, it will automatically install the examples for you.