Skip to content

Commit

Permalink
feat: made pip install and github installs in different target paths
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickAlphaC committed Oct 1, 2024
1 parent c81eac1 commit 82af5bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions moccasin/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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


Expand Down Expand Up @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions tests/integration/test_integration_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
)

Expand All @@ -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()
)

Expand Down Expand Up @@ -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()
)

Expand Down Expand Up @@ -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()
)

0 comments on commit 82af5bb

Please sign in to comment.