diff --git a/moccasin/commands/install.py b/moccasin/commands/install.py index d7ba3e6..0900b76 100644 --- a/moccasin/commands/install.py +++ b/moccasin/commands/install.py @@ -23,6 +23,9 @@ from moccasin.constants.vars import PACKAGE_VERSION_FILE, REQUEST_HEADERS from moccasin.logging import logger +PYPI = "pypi" +GITHUB = "github" + class DependencyType(Enum): GITHUB = "github" @@ -47,9 +50,9 @@ def main(args: Namespace): pip_requirements.append(requirement) install_path: Path = config.get_base_dependencies_install_path() if len(pip_requirements) > 0: - _pip_installs(pip_requirements, install_path, args.quiet) + _pip_installs(pip_requirements, install_path.joinpath(PYPI), args.quiet) if len(github_requirements) > 0: - _github_installs(github_requirements, install_path, args.quiet) + _github_installs(github_requirements, install_path.joinpath(GITHUB), args.quiet) return 0 @@ -102,7 +105,7 @@ def _github_installs( logger.info(f"Using latest version for {org}/{repo}: {version}") org_install_path = base_install_path.joinpath(f"{org}") - org_install_path.mkdir(exist_ok=True) + org_install_path.mkdir(exist_ok=True, parents=True) repo_install_path = org_install_path.joinpath(f"{repo}") versions_install_path = base_install_path.joinpath(PACKAGE_VERSION_FILE) diff --git a/tests/integration/test_integration_install.py b/tests/integration/test_integration_install.py index a1be004..fd9a7a1 100644 --- a/tests/integration/test_integration_install.py +++ b/tests/integration/test_integration_install.py @@ -2,6 +2,7 @@ import subprocess from pathlib import Path +from moccasin.commands.install import GITHUB, PYPI from moccasin.config import Config from moccasin.constants.vars import DEPENDENCIES_FOLDER from tests.conftest import INSTALL_PROJECT_PATH @@ -28,7 +29,7 @@ def test_install_without_parameters_installs_packages_in_toml( assert f"+ {pip_package_name}=={version}" in result.stderr assert ( Path(INSTALL_PROJECT_PATH) - .joinpath(f"{DEPENDENCIES_FOLDER}/{pip_package_name}") + .joinpath(f"{DEPENDENCIES_FOLDER}/{PYPI}/{pip_package_name}") .exists() ) @@ -55,7 +56,7 @@ def test_double_install_snekmate(installation_cleanup_dependencies, mox_path): assert result_two.returncode == 0 assert ( Path(INSTALL_PROJECT_PATH) - .joinpath(f"{DEPENDENCIES_FOLDER}/{org_name}") + .joinpath(f"{DEPENDENCIES_FOLDER}/{GITHUB}/{org_name}") .exists() ) @@ -108,7 +109,7 @@ def test_can_install_with_version(installation_cleanup_dependencies, mox_path): assert f"{github_package_name}@{version}" in config.dependencies assert ( Path(INSTALL_PROJECT_PATH) - .joinpath(f"{DEPENDENCIES_FOLDER}/{org_name}") + .joinpath(f"{DEPENDENCIES_FOLDER}/{GITHUB}/{org_name}") .exists() ) @@ -138,6 +139,6 @@ def test_can_change_versions(installation_cleanup_dependencies, mox_path): assert f"{github_package_name}@{new_version}" in config.dependencies assert ( Path(INSTALL_PROJECT_PATH) - .joinpath(f"{DEPENDENCIES_FOLDER}/{org_name}") + .joinpath(f"{DEPENDENCIES_FOLDER}/{GITHUB}/{org_name}") .exists() )