@@ -1017,6 +1017,51 @@ def install_python_uv(cloned_plugin: InstInfo):
10171017 return cloned_plugin
10181018
10191019
1020+ def install_python_uv_legacy (cloned_plugin : InstInfo ):
1021+ """Install a python plugin with uv that was created with a requirements.txt.
1022+ This requires creating a bare virtual environment with uv first."""
1023+ source = Path (cloned_plugin .source_loc ) / 'source' / cloned_plugin .name
1024+ cloned_plugin .venv = Path ('.venv' )
1025+ (Path (cloned_plugin .source_loc ) / 'pyproject.toml' ).\
1026+ symlink_to (source / 'pyproject.toml' )
1027+ (Path (cloned_plugin .source_loc ) / 'requirements.txt' ).\
1028+ symlink_to (source / 'requirements.txt' )
1029+
1030+ venv = run (['uv' , '-v' , 'venv' ], cwd = str (cloned_plugin .source_loc ),
1031+ stdout = PIPE , stderr = PIPE , text = True , check = False )
1032+ if venv .returncode != 0 :
1033+ for line in venv .stderr .splitlines ():
1034+ log .debug (line )
1035+ log .error ('Failed to create virtual environment' )
1036+ raise InstallationFailure ('Failed to create virtual environment!' )
1037+ for line in venv .stdout .splitlines ():
1038+ log .debug (line )
1039+ for line in venv .stderr .splitlines ():
1040+ log .debug (line )
1041+ # Running this as a shell allows overriding any active virtual environment
1042+ # which would make uv skip installing packages already present in the
1043+ # current env.
1044+ call = ['. .venv/bin/activate; uv -v pip install -r requirements.txt' ]
1045+ uv = run (call , shell = True , cwd = str (cloned_plugin .source_loc ),
1046+ stdout = PIPE , stderr = PIPE , text = True , check = False )
1047+ if uv .returncode != 0 :
1048+ for line in uv .stderr .splitlines ():
1049+ log .debug (line )
1050+ log .error ('Failed to install virtual environment' )
1051+ raise InstallationFailure ('Failed to create virtual environment!' )
1052+ for line in uv .stdout .splitlines ():
1053+ log .debug (line )
1054+ for line in uv .stderr .splitlines ():
1055+ log .debug (line )
1056+
1057+ # Delete entrypoint symlink so that a venv wrapper can take it's place
1058+ (Path (cloned_plugin .source_loc ) / cloned_plugin .entry ).unlink ()
1059+
1060+ create_wrapper (cloned_plugin )
1061+ log .info ('dependencies installed successfully' )
1062+ return cloned_plugin
1063+
1064+
10201065python3venv = Installer ('python3venv' , exe = 'python3' ,
10211066 manager = 'pip' , entry = '{name}.py' )
10221067python3venv .add_entrypoint ('{name}' )
@@ -1043,6 +1088,10 @@ pythonuv = Installer('pythonuv', exe='python3', manager='uv', entry="{name}.py")
10431088pythonuv .add_dependency_file ('uv.lock' )
10441089pythonuv .dependency_call = install_python_uv
10451090
1091+ pythonuvlegacy = Installer ('pythonuvlegacy' , exe = 'python3' , manager = 'uv' , entry = '{name}.py' )
1092+ pythonuvlegacy .add_dependency_file ('requirements.txt' )
1093+ pythonuvlegacy .dependency_call = install_python_uv_legacy
1094+
10461095# Nodejs plugin installer
10471096nodejs = Installer ('nodejs' , exe = 'node' ,
10481097 manager = 'npm' , entry = '{name}.js' )
@@ -1055,8 +1104,8 @@ rust_cargo = Installer('rust', manager='cargo', entry='Cargo.toml')
10551104rust_cargo .add_dependency_file ('Cargo.toml' )
10561105rust_cargo .dependency_call = cargo_installation
10571106
1058- INSTALLERS = [pythonuv , python3venv , poetryvenv , pyprojectViaPip , nodejs ,
1059- rust_cargo ]
1107+ INSTALLERS = [pythonuv , pythonuvlegacy , python3venv , poetryvenv ,
1108+ pyprojectViaPip , nodejs , rust_cargo ]
10601109
10611110
10621111def help_alias (targets : list ):
0 commit comments