A library for managing git repositories in a directory.
Project description
What's not_gitmodules?
Watch the intro:
Long story short: not_gitmodules is a lightweight, production-ready Python utility designed to simplify managing external modules in
your project.
Why not_gitmodules?
- 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.
Important note
- 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.
Installation and Usage
Installation
Choose one of the following methods to install not_gitmodules:
1. Clone the repository:
git clone https://github.com/Armen-Jean-Andreasian/not_gitmodules.git
2. Install via pip:
pip install not-gitmodules
Preparation and Usage Options
1. Preparation (IMPORTANT)
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
2. Usage Options
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 .
Usage
A. As Part of Your Project's Code
Command:
git clone https://github.com/Armen-Jean-Andreasian/not_gitmodules.git
Implementation:
- If
notgitmodules.yamlis located in the project root:
from not_gitmodules import initializer
initializer()
- If
notgitmodules.yamlis located somewhere else. Or has a different name.
from not_gitmodules import initializer
initializer('custom/path/to/config.yaml') # Specify a custom path
B. As a Python Package (Recommended)
This method allows you to leverage CLI commands for better flexibility.
1. Install the package
pip install not_gitmodules
2. Add it to requirements.txt
As this package is not used in code itself, it's easy to forget to add. So better to add in advance.
Run:
pip show not_gitmodules
Check the Version and include it to requirements.txt with ~= assignment:
- Example:
not_gitmodules~=0.0
3. Install the modules:
| 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 |
More command examples:
-
Default command:
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
-
Command pattern:
not_gitmodules install --yaml-path </path/to/notgitmodules.yaml> --threaded
or
not_gitmodules install -y </path/to/notgitmodules.yaml> -t
Comparison
Usually with undefined amount of workers in ThereadPool in parallel mode take more than 52% less time than in
parallel mode.
4. Dockerizing
Double-check that you:
- Created a
notgitmodules.yaml - Included
not_gitmodulesversion 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"]
Possible Issues with Private Repositories
If cloning fails but you have access to the repository, provide the HTTPS repo URL instead of SSH
in notgitmodules.yaml.
Worth to mention
not_gitmodulesdoesn'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.yamlfile. In that case only the first repository will be downloaded and the second one - skipped.
License
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.
Author
Armen-Jean Andreasian, 2024
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file not_gitmodules-0.4.4.tar.gz.
File metadata
- Download URL: not_gitmodules-0.4.4.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0221290c61c04cb6a5ccac20e09a33c183f4e186e62c4828a3e5cb38fc8ad9c
|
|
| MD5 |
a06bfc34c90137d1a1db671817d2bbdf
|
|
| BLAKE2b-256 |
ac1cd2b4350773f7f33627f79e09aadbfa59e2f2208cbedb44a3772e5a56362e
|
File details
Details for the file not_gitmodules-0.4.4-py3-none-any.whl.
File metadata
- Download URL: not_gitmodules-0.4.4-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b20c939bb371947a76027e9192c299072187ca1c9f8e28e4f938fe05075442f6
|
|
| MD5 |
0b05035ae346a60202c726dff9d97816
|
|
| BLAKE2b-256 |
073adec00020fe090dfaf746b38b6e69cf6af4071537df12bb7e41220299f5fe
|