Skip to content

Commit

Permalink
chore: dont rely on upath installed
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Dec 15, 2024
1 parent 569fcc8 commit 08303a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/depkit/depmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ def install_script(self, script_path: str | os.PathLike[str]) -> None:
DependencyError: If script processing or installation fails
ScriptError: If script metadata is invalid
"""
from upath import UPath

path = UPath(script_path)
path = Path(script_path)

try:
# Read and validate script
Expand Down
18 changes: 8 additions & 10 deletions src/depkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import importlib.metadata
import logging
import os
from pathlib import Path
import shutil
import subprocess
import sys
Expand All @@ -16,6 +15,11 @@
from depkit.parser import parse_pep723_deps


try:
from upath import UPath as Path
except (ImportError, ModuleNotFoundError):
from pathlib import Path

if TYPE_CHECKING:
from collections.abc import Sequence
from os import PathLike
Expand All @@ -27,11 +31,9 @@

def verify_paths(paths: Sequence[str | PathLike[str]]) -> None:
"""Verify that paths exist and are accessible."""
from upath import UPath

for path in paths:
try:
path_obj = UPath(path)
path_obj = Path(path)
if not path_obj.exists():
msg = f"Path does not exist: {path}"
raise DependencyError(msg) # noqa: TRY301
Expand Down Expand Up @@ -85,10 +87,8 @@ def get_pip_command(*, prefer_uv: bool = False, is_uv: bool = False) -> Command:

def collect_file_dependencies(path: str | PathLike[str]) -> set[str]:
"""Collect dependencies from a Python file."""
from upath import UPath

try:
content = UPath(path).read_text(encoding="utf-8", errors="ignore")
content = Path(path).read_text(encoding="utf-8", errors="ignore")
return set(parse_pep723_deps(content))
except Exception as exc: # noqa: BLE001
logger.debug("Failed to parse dependencies from %s: %s", path, exc)
Expand All @@ -97,10 +97,8 @@ def collect_file_dependencies(path: str | PathLike[str]) -> set[str]:

def scan_directory_deps(directory: str | PathLike[str]) -> set[str]:
"""Recursively scan directory for PEP 723 dependencies."""
from upath import UPath

all_deps: set[str] = set()
dir_path = UPath(directory)
dir_path = Path(directory)

# Don't scan site-packages or other system directories
if "site-packages" in str(dir_path):
Expand Down

0 comments on commit 08303a6

Please sign in to comment.