forked from SociallyIneptWeeb/AICoverGen
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathurvc.ps1
146 lines (128 loc) · 4.24 KB
/
urvc.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Licensed under the MIT license
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
<#
.SYNOPSIS
The launcher for Ultimate RVC.
.DESCRIPTION
This script is the entry point for Ultimate RVC. It is responsible for installing dependencies,
updating the application, running the application, and providing a CLI.
.PARAMETER Command
The command to run. The available commands are:
install: Install dependencies and set up environment.
update: Update Ultimate RVC to the latest version.
uninstall: Uninstall dependencies and user generated data.
run: Start Ultimate RVC.
dev: Start Ultimate RVC in development mode.
cli: Start Ultimate RVC in CLI mode.
docs: Generate documentation using Typer.
uv: Run an arbitrary command using uv.
help: Print help.
.PARAMETER Arguments
The arguments and options to run the command with.
These are only used for the 'run', 'cli', 'docs' and 'uv' commands.
run:
options:
--help: Print help.
[more information available, use --help to see all]
cli:
options:
--help: Print help.
[more information available, use --help to see all]
docs:
arguments:
0: The module to generate documentation for.
1: The output directory for the documentation.
uv:
arguments:
0: The command to run.
[more information available, use --help to see all]
options:
--help: Print help.
[more information available, use --help to see all]
#>
param (
[Parameter(Position = 0, HelpMessage="The command to run.")]
[string]$Command,
[Parameter(ValueFromRemainingArguments = $true, `
HelpMessage="The arguments to pass to the command.")]
[string[]]$Arguments
)
$uvPath = "$(Get-location)\uv"
$venvPath="$uvPath\.venv"
$env:UV_UNMANAGED_INSTALL = $uvPath
$env:UV_PYTHON_INSTALL_DIR = "$uvPath\python"
$env:UV_PYTHON_BIN_DIR = "$uvPath\python\bin"
$env:VIRTUAL_ENV = $venvPath
$env:UV_PROJECT_ENVIRONMENT = $venvPath
$env:UV_TOOL_DIR = "$uvPath\tools"
$env:UV_TOOL_BIN_DIR = "$uvPath\tools\bin"
$env:GRADIO_NODE_PATH = "$venvPath\Lib\site-packages\nodejs_wheel\node.exe"
$env:PATH = "$uvPath;$env:PATH"
function Main {
param (
[string]$Command,
[string[]]$Arguments
)
switch ($Command) {
"install" {
Invoke-RestMethod https://astral.sh/uv/0.5.0/install.ps1 | Invoke-Expression
uv run ./src/ultimate_rvc/core/main.py
}
"update" {
git pull
}
"uninstall" {
$confirmationMsg = "Are you sure you want to uninstall?`n" `
+ "This will delete all dependencies and user generated data [Y/n]"
$confirmation = Read-Host -Prompt $confirmationMsg
if ($confirmation -in @("", "Y", "y")) {
git clean -dfX
Write-Host "Uninstallation complete."
} else {
Write-Host "Uninstallation canceled."
}
}
"run" {
Assert-Dependencies
uv run ./src/ultimate_rvc/web/main.py @Arguments
}
"dev" {
Assert-Dependencies
uv run gradio ./src/ultimate_rvc/web/main.py --demo-name app
}
"cli" {
Assert-Dependencies
uv run ./src/ultimate_rvc/cli/main.py @Arguments
}
"docs" {
Assert-Dependencies
if ($Arguments.Length -lt 2) {
Write-Host "The 'docs' command requires at least two arguments."
Exit 1
}
uv run python -m typer $Arguments[0] utils docs --output $Arguments[1]
}
"uv" {
Assert-Dependencies
uv @Arguments
}
"help" {
Get-Help $PSCommandPath -Detailed
}
default {
$errorMsg = "Invalid command.`n" `
+ "To see a list of valid commands, use the 'help' command."
Write-Host $errorMsg
Exit 1
}
}
}
function Assert-Dependencies {
if (-Not (Test-Path -Path $uvPath)) {
Write-Host "Dependencies not found. Please run './urvc install' first."
Exit 1
}
}
Main $Command $Arguments