Member-only story
Use git submodules to install a private, custom python package in a docker image
This is a complex title but I swear it’s not difficult
Wow that title contains a lot of terms! Simply said this article offers you the best way to share your Python code privately and easily, even run it in a docker container! In the end you’ll be able to distribute private packages that run everywhere, are easily maintainable and updateable. Let’s code!
Preparation
You’ve created a Python script with all kinds of handy functions that you want to share with others. You have two choices on how to approach this:
- Package your code and distribute it publicly on PyPi as detailed in this article. This means that anyone is able to install the package by just calling
pip install yourpackage
just like pandas e.g. - Package your code and distribute it privately as detailed in this article. This means that only certain people are able to install the package, like coworkers in your company.
We are going for the second option, making sure that our code stays private. We’re going to build upon the article in the second option so make sure to read it first. After reading it you’ve got a Python package that you can pip install from your git repository.