In my projects I have several third-party Python packages which I need to build from source (because there are no .whl packages published for the versions+platforms I need). Currently these packages are built in the Dockerfiles which create my development containers and deployment containers. This has a few drawbacks:
- the third-party packages are rebuilt too often (even if the package itself has not changed it might be rebuilt, depending on the Docker layer cache). This increases build times.
- if the same package is used in multiple projects, the build instructions are sometimes duplicated (i.e. once in each project). Over time this can cause inconsistency between the builds, if changes are not applied in all places.
- the Dockerfiles become more difficult to maintain: rather than just installing all packages from a single requirements.txt or Pipfile, there are multiple installation steps; and it is not clear afterwards from which source/repository a package was installed.
I already have a company-wide repository for Python packages; so I could build and upload .whl files for the third-party Python packages, and then install them as usual.
Also, the third-party packages change rarely (maybe once every few months); so they don't need to be rebuilt often. OTOH this also means that the builds should be automated as much as possible (because noone here will get much practice in building these packages if this is only done rarely).
And sure, I could try to solve some of the mentioned drawbacks by using Docker features (like including Docker files in each other, using multi-stage builds, etc.). But I wonder: what is the "usual" solution for reliably building and maintaining my own binary packages of third-party dependencies?