I've read a lot of blog posts and questions on this site about the usage of git submodules and still have no idea how to better use them with python.
I mean, what is the easier way to manage dependencies if I have such a package:
├── mypkg
│ └── __init__.py
├── setup.py
└── submodules
├── subm1
└── subm2
Then, what if I need to use "mypkg" as a submodule for "top_level_pkg":
├── setup.py
├── submodules
│ └── mypkg
└── top_level_package
└── __init__.py
, I want to run pip install .
and have all resolved correctly (have each submodule installed to the VENV in correct order).
What I've tried:
Ideally, I imagine a separate setup.py file for each submodule with install_requires=['submodules/subm1', 'submodules/submn']
, but setuptools does not support it.
I'm not saying it's impossible, but very hard and very tricky. A safer way is to turn each submodule into an installable Python module (with it's own setup.py
) and install the submodules from Git.
This link describes how to install packages from Git with setup.py
: https://stackoverflow.com/a/32689886/2952185
Thankfully to Gijs Wobben and sinoroc I came up with solution that works for my case:
install_requires=['subm1 @ file://localhost/<CURENT_DIR>/path/to/subm1']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With