11#!/usr/bin/env python
22# -*- coding: utf-8 -*-
33
4- import os
54import sys
65import subprocess
76from functools import wraps
@@ -32,33 +31,7 @@ def confirm(console, prompt, default="n", auto=None):
3231 break
3332 return response == "y"
3433
35- def get_uv_from_venv ():
36- venv_path = os .getenv ("VIRTUAL_ENV" )
37- if not venv_path :
38- print ("VIRTUAL_ENV is not set." )
39- return None
40-
41- cfg_path = os .path .join (venv_path , "pyvenv.cfg" )
42- if not os .path .exists (cfg_path ):
43- print (f"pyvenv.cfg not found in { venv_path } " )
44- return None
45-
46- uv_value = None
47- with open (cfg_path , "r" , encoding = "utf-8" ) as f :
48- for line in f :
49- line = line .strip ()
50- if line .startswith ("uv =" ):
51- _ , uv_value = map (str .strip , line .split ("=" , 1 ))
52- break
53-
54- return uv_value
55-
56- def uv_install_packages (console , packages ):
57- uvv = get_uv_from_venv ()
58- if not uvv :
59- console .print ("[red]Not in uv venv, can't install packages" )
60- return False
61-
62- console .print (f"[green]Install packages: { ', ' .join (packages )} with uv { uvv } " )
63- cp = subprocess .run (['uv' , "add" ] + packages )
34+ def install_packages (console , packages ):
35+ console .print (f"[green]Install packages: { ', ' .join (packages )} with pip" )
36+ cp = subprocess .run ([sys .executable , "-m" , "pip" , "install" ] + packages )
6437 return cp .returncode == 0
0 commit comments