diff --git a/MANIFEST.in b/MANIFEST.in index 4f66101..b4ccad5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,7 @@ include LICENSE include README.md -include dep_check/lib/find_dependencies.go -include dep_check/lib/goparse.c +include dep_check/infra/lib/find_dependencies.go +include dep_check/infra/lib/goparse.c recursive-include tests * recursive-exclude * __pycache__ diff --git a/dep_check/infra/go_parser.py b/dep_check/infra/go_parser.py index 9cd9402..5a3d472 100644 --- a/dep_check/infra/go_parser.py +++ b/dep_check/infra/go_parser.py @@ -1,17 +1,20 @@ import logging -from os import chdir +from os import chdir, environ, getcwd, path from subprocess import CalledProcessError, run from dep_check.dependency_finder import IParser from dep_check.models import Dependencies, Dependency, ModuleWildcard, SourceFile try: - from dep_check.lib import goparse + from .lib import goparse except ImportError: - chdir("dep_check/lib") + CURRENT_WD = getcwd() + + chdir("{}/lib".format(path.dirname(path.realpath(__file__)))) try: + environ["CGO_ENABLED"] = "1" run(["go", "build", "-buildmode=c-shared", "-o", "goparse.so"], check=True) - from dep_check.lib import goparse # pylint: disable=no-name-in-module + from .lib import goparse # pylint: disable=no-name-in-module except (CalledProcessError, FileNotFoundError): logging.warning( "Couldn't load GO library, you won't be able to use dep-check on GO projects." @@ -20,7 +23,7 @@ logging.warning( "Couldn't importy GO library, you won't be able to use dep-check on GO projects." ) - chdir("../..") + chdir(CURRENT_WD) class GoParser(IParser): diff --git a/dep_check/lib/find_dependencies.go b/dep_check/infra/lib/find_dependencies.go similarity index 100% rename from dep_check/lib/find_dependencies.go rename to dep_check/infra/lib/find_dependencies.go diff --git a/dep_check/lib/goparse.c b/dep_check/infra/lib/goparse.c similarity index 100% rename from dep_check/lib/goparse.c rename to dep_check/infra/lib/goparse.c diff --git a/dependency_config.yaml b/dependency_config.yaml index 2f326ec..1acbb81 100644 --- a/dependency_config.yaml +++ b/dependency_config.yaml @@ -15,7 +15,7 @@ dependency_rules: - dep_check.use_cases.interfaces dep_check.infra.go_parser: - - dep_check.lib.goparse + - dep_check.infra.lib.goparse dep_check.use_cases%: - dep_check.use_cases.app_configuration diff --git a/setup.cfg b/setup.cfg index 284b1a2..df5b5ac 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,5 +56,5 @@ line_length=88 multi_line_output=3 use_parentheses=True -[mypy-dep_check.lib] +[mypy-dep_check.infra.lib] ignore_missing_imports = True