Skip to content

Commit dcdd89d

Browse files
authored
import: lazily import dns and git to make iocage faster (#98)
profiling work
1 parent 3c0568e commit dcdd89d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

iocage_lib/ioc_create.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
import iocage_lib.ioc_start
3939
import iocage_lib.ioc_stop
4040
import iocage_lib.ioc_exceptions
41-
import dns.resolver
42-
import dns.exception
4341
import shutil
4442

4543
from iocage_lib.cache import cache
@@ -763,6 +761,8 @@ def create_install_packages(self, jail_uuid, location,
763761
_callback=self.callback,
764762
silent=False)
765763

764+
import dns.resolver
765+
import dns.exception
766766
try:
767767
dns.resolver.query(repo)
768768
except dns.resolver.NoNameservers:

iocage_lib/ioc_plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import json
3030
import logging
3131
import os
32-
import git
3332
import pathlib
3433
import re
3534
import shutil
@@ -1519,6 +1518,7 @@ def __fetch_release__(self, release):
15191518
@staticmethod
15201519
def _verify_git_repo(repo_url, destination):
15211520
verified = False
1521+
import git
15221522
with contextlib.suppress(
15231523
git.exc.InvalidGitRepositoryError,
15241524
git.exc.NoSuchPathError,
@@ -1534,6 +1534,7 @@ def _clone_repo(ref, repo_url, destination, depth=None, callback=None):
15341534
"""
15351535
This is to replicate the functionality of cloning/pulling a repo
15361536
"""
1537+
import git
15371538
with GIT_LOCK:
15381539
branch = ref
15391540
try:

0 commit comments

Comments
 (0)