Vendoring is usually as simple as doing the following for me:
-
pip install -r requirements.txt -t src/vendor. - Adding src/vendor to
sys.path, or maybe using a modified version of the snippet here where you don’t mess around withsys.modules/sys.path, and instead just use the object you get fromimportlib.util.module_from_specto avoid conflicts. (I usually just append/insert tosys.path, and have not tested my suggestion yet)
It becomes a real pain when C extensions are involved. For this case, I imagine a native solution from Anki’s side can get quite complicated and will be probably fragile.
See this for an example of how I recently went about bundling non-pure python dependencies for multiple platforms and Anki versions.