Skip to content

Commit

Permalink
passes uv-path to sync-function.
Browse files Browse the repository at this point in the history
  • Loading branch information
birkin committed Dec 19, 2024
1 parent 74c1e1c commit 76981ed
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions self_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,13 @@ def filter_initial_comments(lines: list[str]) -> list[str]:
return changes


def sync_dependencies(project_path: Path, backup_file: Path) -> None:
def sync_dependencies(project_path: Path, backup_file: Path, uv_path: Path) -> None:
"""
Referencing the virtual environment, syncs dependencies to the recent `--output` requirements.in file.
Exits the script if any command fails.
"""
log.debug('starting activate_and_sync_dependencies()')

uv_path: Path = get_uv_path(project_path)
log.debug(f'uv_path: ``{uv_path}``')
venv_bin_path: Path = project_path.parent / 'env' / 'bin'
log.debug(f'venv_bin_path: ``{venv_bin_path}``')
venv_path: Path = project_path.parent / 'env'
Expand Down Expand Up @@ -265,6 +263,7 @@ def infer_group(project_path: Path) -> str:
"""
Infers the group by examining existing files.
Returns the most common group.
Called by `update_permissions_and_mark_active()`.
"""
log.debug('starting infer_group()')
try:
Expand All @@ -279,20 +278,6 @@ def infer_group(project_path: Path) -> str:
raise Exception(message)


def get_uv_path(project_path: Path) -> Path:
"""
Infers the full path to `uv` directly from the virtual environment.
"""
log.debug('starting get_uv_path()')
uv_path: Path = project_path.parent / 'env/bin/uv'
log.debug(f'uv_path: {uv_path}')
if not uv_path.exists():
message = f'Error: `uv` command not found in virtual environment at {uv_path}.'
log.exception(message)
raise Exception(message)
return uv_path


## ------------------------------------------------------------------
## main manager function --------------------------------------------
## ------------------------------------------------------------------
Expand Down Expand Up @@ -326,7 +311,7 @@ def manage_update(project_path: str) -> None:
else:
## since it's different, update the venv --------------------
log.debug('differences found in dependencies; updating venv')
sync_dependencies(project_path, compiled_requirements)
sync_dependencies(project_path, compiled_requirements, uv_path)
log.debug('dependencies updated successfully.')
update_permissions_and_mark_active(project_path, compiled_requirements)
return
Expand Down

0 comments on commit 76981ed

Please sign in to comment.