Goal: Develop a python library that uses one of multiple interchangeable engine libraries. Only one of the engines is required at a time, but it is not possible to know in advance which one. Need an option to decide at install time which engine will be used. Example: Main library: Finds most efficient way to swim across a lake (made up example) Engine: Mathematical Optimizer that minimizes a trajectory (libraries A, B and C) Problems: Some not very popular engine libraries may be tedious to install, even though they are really good at their job Engines may have incompatible dependencies Naive solution: Use different git branches, where each branch uses only one engine. Works, but may be annoying to maintain Question: What is the standard way to do this? I recall that in C++ libraries used make flags to decide which engine to use, and manipulate the code using #ifdef clauses. Is there something similar in python, e.g. by manipulating pyproject.toml? If yes, how would one provide flags, and how would one adapt the python code. Continue reading...