Created
April 5, 2024 04:21
-
-
Save andgineer/5d09ed56852c9bcd36db4091476461e0 to your computer and use it in GitHub Desktop.
Register `invoke` tasks from all Python files in the directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from invoke import Collection | |
import importlib | |
tasks_dir = os.path.dirname(os.path.abspath(__file__)) | |
ns = Collection() | |
for filename in os.listdir(tasks_dir): | |
if filename.endswith(".py"): | |
module_name = os.path.splitext(filename)[0] | |
module = importlib.import_module(module_name) | |
ns.add_collection(Collection.from_module(module)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment