Watch the intro:
Long story short: not_gitmodules
is a lightweight, production-ready Python utility designed to simplify managing external modules in
your project.
- Simplicity: Minimalistic design—no unnecessary complexities.
- Production-Ready: Explicitly licensed for production use.
- Dependency-Free: Uses only Python's built-in tools.
- OS-Agnostic: Works seamlessly on Linux, MacOS and any other platforms where Python is available by default.
- not_gitmodules just like Gitmodules doesn't
automatically install the dependencies
/do not include the dependencies to your project dependency file (such as requirements.txt for Python or package.json for JavaScript)
of the submodule. - not_gitmodules doesn't
download the submodules mentioned in the not_gimodules.yaml file of the submodule
.
- Reason: it's practically inefficient, may lead to bugs and bottlenecks, and better to maintain manually.
How to handle?
- Move the containing of the dependency file to your project's dependency file and rerun the dependency installer.
2.1. Important note. not_gitmodules
keeps the view of keeping the project structure clean. All submodules amoung one project/micro-service need to go to one folder. It's recommended to use dependency injection in case of having nested not_gitmodules.
2.2. Move submodules to your not_gimodules.yaml
file and rerun install accordingly.
Choose one of the following methods to install not_gitmodules
:
git clone https://github.com/Armen-Jean-Andreasian/not_gitmodules.git
pip install not-gitmodules
Create a notgitmodules.yaml
file in your project's root directory.
# directory_name: url (ssh or https)
# Example:
utils:
file_manager: https://github.com/not-gitmodules/notgitmodules-file-manager-py
file_encryptor: https://github.com/not-gitmodules/notgitmodules-file-encryptor-py
services:
forsaken_mail: https://github.com/malaohu/forsaken-mail
sim_mail: https://github.com/Webador/SlmMail
You can use not_gitmodules
in two ways:
-
As a part of your project's code.
Just clone/download this repository and include it to your project.- Pros: No additional dependencies or overhead.
- Cons: No CLI usage; increases the project's file size.
-
As a Python Package (Recommended).
Install using pip
- Pros: This method allows you to leverage CLI commands for better flexibility, ease with Docker, keeps the project
lightweight
- Cons: Additional dependency
Not recommended option: clone/download this repository and run pip install .
git clone https://github.com/Armen-Jean-Andreasian/not_gitmodules.git
- If
notgitmodules.yaml
is located in the project root:
from not_gitmodules import initializer
initializer()
- If
notgitmodules.yaml
is located somewhere else. Or has a different name.
from not_gitmodules import initializer
initializer('custom/path/to/config.yaml') # Specify a custom path
This method allows you to leverage CLI commands for better flexibility.
pip install not_gitmodules
As this package is not used in code itself, it's easy to forget to add. So better to add in advance.
pip show not_gitmodules
Check the Version
and include it to requirements.txt
with ~=
assignment:
- Example:
not_gitmodules~=0.0
Flag (all of them are optional) | Description | Example |
---|---|---|
-y , --yaml-path |
Specify a custom path for the notgitmodules.yaml configuration file. By default, it looks for notgitmodules.yaml in the current working directory. Naming it notgitmodules is a matter of best practices; you can name it as you want. |
• not_gitmodules -y /path/to/custom_notgitmodules.yaml : Uses a custom YAML file located at /path/to/custom_notgitmodules.yaml |
-t , --threaded |
Enable threaded execution, where repositories are cloned in parallel (using threads). This flag is mutually exclusive with -s . This is the default behavior if neither -t nor -s is specified. |
• not_gitmodules -t : Clones repositories in parallel using threads • not_gitmodules --threaded : Same as -t , using long form |
-s , --sequential |
Enable sequential execution, where repositories are cloned one by one in the order they appear in the YAML file. This flag is mutually exclusive with -t . |
• not_gitmodules -s : Clones repositories one by one in order • not_gitmodules --sequential : Same as -s , using long form |
This will look for notgitmodules.yaml
in the project root and create a directory named my_gitmodules
in the root to
download the modules into, in parallel mode using threads.
not_gitmodules install
not_gitmodules install --yaml-path </path/to/notgitmodules.yaml> --threaded
or
not_gitmodules install -y </path/to/notgitmodules.yaml> -t
Usually with undefined amount of workers in ThereadPool
in parallel mode take more than 52% less time than in
parallel mode.
Double-check that you:
- Created a
notgitmodules.yaml
- Included
not_gitmodules
version torequirements.txt
Then:
- Create your
Dockerfile
. Example:
FROM python:3.10-slim
# Install git for not_gitmodules
RUN apt-get update && apt-get install -y git
WORKDIR /app
COPY . .
RUN pip install --no-cache-dir -r requirements.txt
# copy the notgitmodules.yaml file (default). Modify accordingly.
COPY notgitmodules.yaml .
# install modules using not_gitmodules
RUN not_gitmodules install -y notgitmodules.yaml -t
CMD ["python", "main.py"]
If cloning fails but you have access to the repository, provide the HTTPS repo URL instead of SSH
in notgitmodules.yaml
.
not_gitmodules
doesn't require for you to keep the folders with modules. You can safely .gitignore/delete them.- Do not use matching names for the repositories in
notgitmodules.yaml
file. In that case only the first repository will be downloaded and the second one - skipped.
This project is licensed under a Custom License. See the LICENSE file for full details.
Key points:
- You may use this project for commercial or personal purposes.
Armen-Jean Andreasian, 2024