@@ -1017,6 +1017,51 @@ def install_python_uv(cloned_plugin: InstInfo):
1017
1017
return cloned_plugin
1018
1018
1019
1019
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
+
1020
1065
python3venv = Installer ('python3venv' , exe = 'python3' ,
1021
1066
manager = 'pip' , entry = '{name}.py' )
1022
1067
python3venv .add_entrypoint ('{name}' )
@@ -1043,6 +1088,10 @@ pythonuv = Installer('pythonuv', exe='python3', manager='uv', entry="{name}.py")
1043
1088
pythonuv .add_dependency_file ('uv.lock' )
1044
1089
pythonuv .dependency_call = install_python_uv
1045
1090
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
+
1046
1095
# Nodejs plugin installer
1047
1096
nodejs = Installer ('nodejs' , exe = 'node' ,
1048
1097
manager = 'npm' , entry = '{name}.js' )
@@ -1055,8 +1104,8 @@ rust_cargo = Installer('rust', manager='cargo', entry='Cargo.toml')
1055
1104
rust_cargo .add_dependency_file ('Cargo.toml' )
1056
1105
rust_cargo .dependency_call = cargo_installation
1057
1106
1058
- INSTALLERS = [pythonuv , python3venv , poetryvenv , pyprojectViaPip , nodejs ,
1059
- rust_cargo ]
1107
+ INSTALLERS = [pythonuv , pythonuvlegacy , python3venv , poetryvenv ,
1108
+ pyprojectViaPip , nodejs , rust_cargo ]
1060
1109
1061
1110
1062
1111
def help_alias (targets : list ):
0 commit comments