Skip to content

Commit

Permalink
wip: transition to uv
Browse files Browse the repository at this point in the history
* this gives a huge performance improvement on installing and setting up
  an environment.
  • Loading branch information
utnapischtim committed Sep 24, 2024
1 parent 7a095c3 commit 5505d91
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions invenio_cli/commands/packages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020-2021 CERN.
# Copyright (C) 2022 Graz University of Technology.
# Copyright (C) 2022-2024 Graz University of Technology.
#
# Invenio-Cli is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -23,8 +23,7 @@ def install_packages(packages, log_file=None):
It is a class method since it does not require any configuration.
"""
prefix = ["pipenv", "run"]
cmd = prefix + ["pip", "install"]
cmd = ["uv", "pip", "install"]
for package in packages:
cmd.extend(["-e", package])

Expand All @@ -45,6 +44,7 @@ def outdated_packages():
It is a class method since it does not require any configuration.
"""
raise RuntimeError("not yet ported to uv")
cmd = ["pipenv", "update", "--outdated"]

steps = [
Expand All @@ -63,7 +63,7 @@ def update_packages():
It is a class method since it does not require any configuration.
"""
cmd = ["pipenv", "update"]
cmd = ["uv", "sync", "--upgrade"]

steps = [
CommandStep(
Expand All @@ -81,6 +81,7 @@ def update_package_new_version(package, version):
It is a class method since it does not require any configuration.
"""
raise RuntimeError("not yet ported to uv")
prefix = ["pipenv"]
app = prefix + ["install", package + version]

Expand All @@ -96,13 +97,8 @@ def update_package_new_version(package, version):

@staticmethod
def install_locked_dependencies(pre, dev):
"""Install dependencies from Pipfile.lock using sync."""
# NOTE: sync has no interactive process feedback
cmd = ["pipenv", "sync"]
if pre:
cmd += ["--pre"]
if dev:
cmd += ["--dev"]
"""Install dependencies from requirements.txt using install."""
cmd = ["uv", "sync"]

steps = [
CommandStep(
Expand All @@ -118,11 +114,7 @@ def install_locked_dependencies(pre, dev):
@staticmethod
def lock(pre, dev):
"""Steps to lock Python dependencies."""
cmd = ["pipenv", "lock"]
if pre:
cmd += ["--pre"]
if dev:
cmd += ["--dev"]
cmd = ["uv", "lock"]

steps = [
CommandStep(
Expand All @@ -137,7 +129,7 @@ def lock(pre, dev):
@staticmethod
def is_locked():
"""Checks if the dependencies have been locked."""
locked = "Pipfile.lock" in listdir(".")
locked = "uv.lock" in listdir(".")
if not locked:
return ProcessResponse(
error="Dependencies were not locked. "
Expand Down

0 comments on commit 5505d91

Please sign in to comment.