uvr 0.1.22__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uvr-0.1.22/.gitignore +24 -0
- uvr-0.1.22/PKG-INFO +132 -0
- uvr-0.1.22/README.md +110 -0
- uvr-0.1.22/pyproject.toml +41 -0
- uvr-0.1.22/src/uvr/__init__.py +1 -0
- uvr-0.1.22/src/uvr/uvr.py +99 -0
- uvr-0.1.22/tests/foo +7 -0
- uvr-0.1.22/tests/foo.py +14 -0
- uvr-0.1.22/tests/test_uvr.py +61 -0
- uvr-0.1.22/uv_scripts/install_github_uvr.sh +27 -0
- uvr-0.1.22/uv_scripts/install_local_uvr.sh +36 -0
- uvr-0.1.22/uv_scripts/run_tests.sh +21 -0
uvr-0.1.22/.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
# Python-generated files
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[oc]
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
wheels/
|
|
8
|
+
*.egg-info
|
|
9
|
+
|
|
10
|
+
.python-version
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv
|
|
14
|
+
|
|
15
|
+
# vscode
|
|
16
|
+
.vscode
|
|
17
|
+
|
|
18
|
+
# uv
|
|
19
|
+
uv.lock
|
|
20
|
+
|
|
21
|
+
# Coverage
|
|
22
|
+
.coverage
|
|
23
|
+
coverage.*
|
|
24
|
+
|
uvr-0.1.22/PKG-INFO
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: uvr
|
|
3
|
+
Version: 0.1.22
|
|
4
|
+
Summary: Simple script execution with uv - run Python scripts without explicit --project flag
|
|
5
|
+
Project-URL: Homepage, https://github.com/karnigen/uvr
|
|
6
|
+
Project-URL: Repository, https://github.com/karnigen/uvr.git
|
|
7
|
+
Project-URL: Issues, https://github.com/karnigen/uvr/issues
|
|
8
|
+
Author-email: karnigen <karnigen@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: python,runner,script,tool,uv
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Simple Script Execution with uvr
|
|
26
|
+
|
|
27
|
+
[`uv`](https://github.com/astral-sh/uv.git) is a fast, modern Python package installer and resolver, designed as a drop-in replacement for pip and pip-compile.
|
|
28
|
+
|
|
29
|
+
Unfortunately, [`uv`](https://github.com/astral-sh/uv.git)
|
|
30
|
+
prioritizes virtual environments within the current directory. This makes it cumbersome to execute scripts located elsewhere, requiring the use of the `--project` flag.
|
|
31
|
+
|
|
32
|
+
This script offers a streamlined workaround for running Python scripts via `uv`, allowing you to use `uvr [options] script.py` instead of `uv run [options] --project <script_path> script.py`."
|
|
33
|
+
|
|
34
|
+
Its primary value lies in its simplicity and immediate usability, providing a *quick fix* for a pressing pain point.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
To install `uvr`, use the following command:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
uv tool install --from git+https://github.com/karnigen/uvr uvr
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
To upgrade `uvr`, use the following command:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
uv tool upgrade uvr
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
Several ways to run your Python scripts with `uv`:
|
|
56
|
+
|
|
57
|
+
1. **Using `uv run --project <script_path> script.py`:**
|
|
58
|
+
|
|
59
|
+
* This command explicitly tells `uv` to run the specified Python script (`script.py`) within the context of the project located at `<script_path>`.
|
|
60
|
+
* This is useful when your script relies on dependencies defined within a specific project directory.
|
|
61
|
+
* Example:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
uv run [options] --project /path/to/project run_script.py [script_options]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
2. **Using `uvr script.py`:**
|
|
68
|
+
|
|
69
|
+
* This is a more direct way to execute your Python script (`run_script.py`) using `uvr`.
|
|
70
|
+
* `uvr` automatically determines the project directory based on the script path, effectively mimicking the `--project` flag's behavior.
|
|
71
|
+
* Example:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
uvr [options] [--] run_script.py [script_options]
|
|
75
|
+
```
|
|
76
|
+
* Always use `--` if the automatic script identification fails or could be ambiguous.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
3. **Shebang Usage:**
|
|
80
|
+
|
|
81
|
+
* Example:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
#!/usr/bin/env -S uvr [options] [--]
|
|
85
|
+
|
|
86
|
+
# Your Python code here...
|
|
87
|
+
```
|
|
88
|
+
* Always use `--` if the automatic script identification fails or could be ambiguous.
|
|
89
|
+
|
|
90
|
+
4. **Scripts without `.py` or `.pyw` extension:**
|
|
91
|
+
* Automatic `--script` option is added if not already present (`--script` or `--gui-script`) in options.
|
|
92
|
+
* Otherwise, `uv` might loop indefinitely.
|
|
93
|
+
|
|
94
|
+
* Example: For a `foo` script:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
#!/usr/bin/env -S uvr [options] [--]
|
|
98
|
+
# Your Python code here...
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This will be executed as `uv run [options] --script ...` if `[options]` do not already contain `--script` or `--gui-script`.
|
|
102
|
+
|
|
103
|
+
* Or, to be more explicit, you can include the `--script` flag directly in the shebang:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
#!/usr/bin/env -S uvr --script
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
* **Important Exception for Non-Files**: If the identified `script_path` (the argument immediately following options or `--`) does not point to an actual file on disk, `uvr` will not automatically add the `--script` or `--gui-script` option. This behavior ensures `uvr` can correctly pass through commands that are executables within the virtual environment (e.g., `uvr black .`, `uvr pytest`), rather than a Python script file.
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
5. **Debug usage:**
|
|
113
|
+
* Example:
|
|
114
|
+
```bash
|
|
115
|
+
uvr -v [options] [--] run_script.py [script_options]
|
|
116
|
+
uvr -vv [options] [--] run_script.py [script_options]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
## General Rule for Using the `--` Separator
|
|
121
|
+
The `--` argument functions as a standard command-line delimiter. It explicitly separates options intended for `uvr` (and its underlying `uv` process) from arguments specifically designated for the Python script being executed.
|
|
122
|
+
|
|
123
|
+
Arguments appearing before the `--` are processed by `uvr` (`uv`). Arguments appearing after the `--` are passed directly to the invoked Python script.
|
|
124
|
+
|
|
125
|
+
This explicit separation is crucial for:
|
|
126
|
+
|
|
127
|
+
* **Preventing Ambiguity**: `uvr` employs a basic heuristic to identify the script path (the first non-hyphenated argument). This can lead to misinterpretation if the script itself accepts options that resemble `uvr/uv` arguments.
|
|
128
|
+
|
|
129
|
+
* **Ensuring Precise Argument Passing**: By using `--`, users guarantee that all subsequent arguments are correctly delivered to their script, bypassing `uvr's` argument parsing logic.
|
|
130
|
+
|
|
131
|
+
**Recommendation**: Utilize the `--` separator whenever precise control over argument distribution between `uvr/uv` and the target script is required.
|
|
132
|
+
|
uvr-0.1.22/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# Simple Script Execution with uvr
|
|
4
|
+
|
|
5
|
+
[`uv`](https://github.com/astral-sh/uv.git) is a fast, modern Python package installer and resolver, designed as a drop-in replacement for pip and pip-compile.
|
|
6
|
+
|
|
7
|
+
Unfortunately, [`uv`](https://github.com/astral-sh/uv.git)
|
|
8
|
+
prioritizes virtual environments within the current directory. This makes it cumbersome to execute scripts located elsewhere, requiring the use of the `--project` flag.
|
|
9
|
+
|
|
10
|
+
This script offers a streamlined workaround for running Python scripts via `uv`, allowing you to use `uvr [options] script.py` instead of `uv run [options] --project <script_path> script.py`."
|
|
11
|
+
|
|
12
|
+
Its primary value lies in its simplicity and immediate usability, providing a *quick fix* for a pressing pain point.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
To install `uvr`, use the following command:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv tool install --from git+https://github.com/karnigen/uvr uvr
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To upgrade `uvr`, use the following command:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
uv tool upgrade uvr
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Several ways to run your Python scripts with `uv`:
|
|
34
|
+
|
|
35
|
+
1. **Using `uv run --project <script_path> script.py`:**
|
|
36
|
+
|
|
37
|
+
* This command explicitly tells `uv` to run the specified Python script (`script.py`) within the context of the project located at `<script_path>`.
|
|
38
|
+
* This is useful when your script relies on dependencies defined within a specific project directory.
|
|
39
|
+
* Example:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
uv run [options] --project /path/to/project run_script.py [script_options]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
2. **Using `uvr script.py`:**
|
|
46
|
+
|
|
47
|
+
* This is a more direct way to execute your Python script (`run_script.py`) using `uvr`.
|
|
48
|
+
* `uvr` automatically determines the project directory based on the script path, effectively mimicking the `--project` flag's behavior.
|
|
49
|
+
* Example:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uvr [options] [--] run_script.py [script_options]
|
|
53
|
+
```
|
|
54
|
+
* Always use `--` if the automatic script identification fails or could be ambiguous.
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
3. **Shebang Usage:**
|
|
58
|
+
|
|
59
|
+
* Example:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
#!/usr/bin/env -S uvr [options] [--]
|
|
63
|
+
|
|
64
|
+
# Your Python code here...
|
|
65
|
+
```
|
|
66
|
+
* Always use `--` if the automatic script identification fails or could be ambiguous.
|
|
67
|
+
|
|
68
|
+
4. **Scripts without `.py` or `.pyw` extension:**
|
|
69
|
+
* Automatic `--script` option is added if not already present (`--script` or `--gui-script`) in options.
|
|
70
|
+
* Otherwise, `uv` might loop indefinitely.
|
|
71
|
+
|
|
72
|
+
* Example: For a `foo` script:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
#!/usr/bin/env -S uvr [options] [--]
|
|
76
|
+
# Your Python code here...
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This will be executed as `uv run [options] --script ...` if `[options]` do not already contain `--script` or `--gui-script`.
|
|
80
|
+
|
|
81
|
+
* Or, to be more explicit, you can include the `--script` flag directly in the shebang:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
#!/usr/bin/env -S uvr --script
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
* **Important Exception for Non-Files**: If the identified `script_path` (the argument immediately following options or `--`) does not point to an actual file on disk, `uvr` will not automatically add the `--script` or `--gui-script` option. This behavior ensures `uvr` can correctly pass through commands that are executables within the virtual environment (e.g., `uvr black .`, `uvr pytest`), rather than a Python script file.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
5. **Debug usage:**
|
|
91
|
+
* Example:
|
|
92
|
+
```bash
|
|
93
|
+
uvr -v [options] [--] run_script.py [script_options]
|
|
94
|
+
uvr -vv [options] [--] run_script.py [script_options]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
## General Rule for Using the `--` Separator
|
|
99
|
+
The `--` argument functions as a standard command-line delimiter. It explicitly separates options intended for `uvr` (and its underlying `uv` process) from arguments specifically designated for the Python script being executed.
|
|
100
|
+
|
|
101
|
+
Arguments appearing before the `--` are processed by `uvr` (`uv`). Arguments appearing after the `--` are passed directly to the invoked Python script.
|
|
102
|
+
|
|
103
|
+
This explicit separation is crucial for:
|
|
104
|
+
|
|
105
|
+
* **Preventing Ambiguity**: `uvr` employs a basic heuristic to identify the script path (the first non-hyphenated argument). This can lead to misinterpretation if the script itself accepts options that resemble `uvr/uv` arguments.
|
|
106
|
+
|
|
107
|
+
* **Ensuring Precise Argument Passing**: By using `--`, users guarantee that all subsequent arguments are correctly delivered to their script, bypassing `uvr's` argument parsing logic.
|
|
108
|
+
|
|
109
|
+
**Recommendation**: Utilize the `--` separator whenever precise control over argument distribution between `uvr/uv` and the target script is required.
|
|
110
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "uvr"
|
|
3
|
+
version = "0.1.22"
|
|
4
|
+
description = "Simple script execution with uv - run Python scripts without explicit --project flag"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "karnigen", email = "karnigen@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
dependencies = []
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
keywords = ["uv", "script", "runner", "python", "tool"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.9",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Topic :: Software Development :: Build Tools",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/karnigen/uvr"
|
|
27
|
+
Repository = "https://github.com/karnigen/uvr.git"
|
|
28
|
+
Issues = "https://github.com/karnigen/uvr/issues"
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
uvr = "uvr:main"
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = ["hatchling"]
|
|
35
|
+
build-backend = "hatchling.build"
|
|
36
|
+
|
|
37
|
+
[dependency-groups]
|
|
38
|
+
dev = [
|
|
39
|
+
"pytest>=8.3.5",
|
|
40
|
+
"pytest-cov>=6.1.0",
|
|
41
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .uvr import *
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
# Option '--' is separator. When you use it, you're telling uvr to treat all arguments that come after it
|
|
8
|
+
# as destined exclusively for your Python script, not for uvr or uv.
|
|
9
|
+
def resolve_argv():
|
|
10
|
+
pre_opt = []
|
|
11
|
+
run_script = None
|
|
12
|
+
post_opt = []
|
|
13
|
+
|
|
14
|
+
# The '--' argument explicitly separates `uvr`/`uv` options (pre-options)
|
|
15
|
+
# from the script path and any arguments meant for the script (post-options).
|
|
16
|
+
# Example: uvr <pre_opt> -- <script_path> <post_opt>
|
|
17
|
+
# For instance, `uvr -a --b -- my_script.py --d` would pass `-a --b` to `uvr`/`uv`
|
|
18
|
+
# and `my_script.py --d` to the script.
|
|
19
|
+
|
|
20
|
+
if '--' in sys.argv:
|
|
21
|
+
idx = sys.argv.index('--')
|
|
22
|
+
pre_opt = sys.argv[1:idx]
|
|
23
|
+
|
|
24
|
+
else:
|
|
25
|
+
# Simple heuristic for pre-options:
|
|
26
|
+
# Identifies options (starting with '-') at the beginning of the arguments.
|
|
27
|
+
# The first argument found that doesn't start with '-' is assumed to be the script path.
|
|
28
|
+
# Example: uvr -a -b script_name --arg1 --arg2
|
|
29
|
+
# Here, pre_opt would be ['-a', '-b'], and 'script_name' is identified as the script.
|
|
30
|
+
|
|
31
|
+
idx = 0
|
|
32
|
+
for i in range(1, len(sys.argv)):
|
|
33
|
+
if sys.argv[i].startswith('-'):
|
|
34
|
+
idx = i
|
|
35
|
+
else:
|
|
36
|
+
break
|
|
37
|
+
pre_opt = sys.argv[1:idx + 1]
|
|
38
|
+
|
|
39
|
+
if idx + 1 >= len(sys.argv) or sys.argv[idx + 1].startswith('-'):
|
|
40
|
+
return pre_opt, run_script, post_opt
|
|
41
|
+
|
|
42
|
+
run_script = sys.argv[idx + 1]
|
|
43
|
+
post_opt = sys.argv[idx + 2:]
|
|
44
|
+
|
|
45
|
+
# prevent looping forever the same script not ending with .py or .pyw
|
|
46
|
+
if not (run_script.endswith('.py') or run_script.endswith('.pyw')):
|
|
47
|
+
if '--script' not in pre_opt and '--gui-script' not in pre_opt:
|
|
48
|
+
if os.path.isfile(run_script): # check if the script is a valid file
|
|
49
|
+
pre_opt.append('--script') # if it is a file, we assume it is a python script
|
|
50
|
+
|
|
51
|
+
return pre_opt, run_script, post_opt
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def main(): # pragma: no cover
|
|
55
|
+
if len(sys.argv) < 2:
|
|
56
|
+
print("Shebang usage: #!/usr/bin/env -S uvr [options] [--]")
|
|
57
|
+
print(
|
|
58
|
+
"Command line usage: uvr [options] [--] script.py [script options]"
|
|
59
|
+
)
|
|
60
|
+
print(
|
|
61
|
+
"Debug usage: uvr -v [options] [--] script.py [script options]"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
sys.exit(1)
|
|
65
|
+
|
|
66
|
+
pre_opt, run_script, post_opt = resolve_argv()
|
|
67
|
+
|
|
68
|
+
if '-v' in pre_opt or '-vv' in pre_opt:
|
|
69
|
+
print(f"DEBUG uvr {sys.argv=}", file=sys.stderr)
|
|
70
|
+
print(f"DEBUG uvr {pre_opt=} {run_script=} {post_opt=}", file=sys.stderr)
|
|
71
|
+
|
|
72
|
+
if '-vv' in pre_opt: # exit after debug output
|
|
73
|
+
sys.exit(0)
|
|
74
|
+
|
|
75
|
+
if run_script is None:
|
|
76
|
+
print("No script provided", file=sys.stderr)
|
|
77
|
+
sys.exit(1)
|
|
78
|
+
|
|
79
|
+
if not os.path.isfile(run_script): # fall back to uv run
|
|
80
|
+
prog_args = ['uv', 'run'] + pre_opt + [
|
|
81
|
+
run_script
|
|
82
|
+
] + post_opt # fall back to uv run
|
|
83
|
+
else:
|
|
84
|
+
run_script = os.path.realpath(run_script)
|
|
85
|
+
run_script_dir = os.path.dirname(run_script)
|
|
86
|
+
prog_args = ['uv', 'run'] + pre_opt + [
|
|
87
|
+
'--project', run_script_dir, run_script
|
|
88
|
+
] + post_opt
|
|
89
|
+
|
|
90
|
+
if '-v' in pre_opt:
|
|
91
|
+
print(f"DEBUG uv {prog_args=}", file=sys.stderr)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
subprocess.run(prog_args)
|
|
95
|
+
sys.exit(0)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__": # pragma: no cover
|
|
99
|
+
main()
|
uvr-0.1.22/tests/foo
ADDED
uvr-0.1.22/tests/foo.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from uvr import *
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_resolve_argv():
|
|
8
|
+
this_script = os.path.realpath(__file__)
|
|
9
|
+
this_script_dir = os.path.dirname(this_script)
|
|
10
|
+
|
|
11
|
+
# Test case 1: No arguments
|
|
12
|
+
sys.argv = ['uvr']
|
|
13
|
+
pre_opt, run_script, post_opt = resolve_argv()
|
|
14
|
+
assert pre_opt == []
|
|
15
|
+
assert run_script is None
|
|
16
|
+
assert post_opt == []
|
|
17
|
+
|
|
18
|
+
# Test case 2: Only pre-options
|
|
19
|
+
sys.argv = ['uvr', '-v', '--']
|
|
20
|
+
pre_opt, run_script, post_opt = resolve_argv()
|
|
21
|
+
assert pre_opt == ['-v']
|
|
22
|
+
assert run_script is None
|
|
23
|
+
assert post_opt == []
|
|
24
|
+
|
|
25
|
+
# Test case 3: Pre-options and script
|
|
26
|
+
sys.argv = ['uvr', '-v', 'foo.py', 'arg1', 'arg2']
|
|
27
|
+
pre_opt, run_script, post_opt = resolve_argv()
|
|
28
|
+
assert pre_opt == [
|
|
29
|
+
'-v',
|
|
30
|
+
]
|
|
31
|
+
assert run_script == 'foo.py'
|
|
32
|
+
assert post_opt == ['arg1', 'arg2']
|
|
33
|
+
|
|
34
|
+
# Test case 4: Only script
|
|
35
|
+
sys.argv = ['uvr', 'foo.py']
|
|
36
|
+
pre_opt, run_script, post_opt = resolve_argv()
|
|
37
|
+
assert pre_opt == []
|
|
38
|
+
assert run_script == 'foo.py'
|
|
39
|
+
assert post_opt == []
|
|
40
|
+
|
|
41
|
+
# Test case 5: Script with pre-options and post-options
|
|
42
|
+
sys.argv = ['uvr', '-v', '--script', 'foo.py', '--option1', '--option2']
|
|
43
|
+
pre_opt, run_script, post_opt = resolve_argv()
|
|
44
|
+
assert pre_opt == ['-v', '--script']
|
|
45
|
+
assert run_script == 'foo.py'
|
|
46
|
+
assert post_opt == ['--option1', '--option2']
|
|
47
|
+
|
|
48
|
+
# Test case 6: Script with pre-options and post-options
|
|
49
|
+
sys.argv = ['uvr', '--', 'foo.py', '--option1', '--option2']
|
|
50
|
+
pre_opt, run_script, post_opt = resolve_argv()
|
|
51
|
+
assert pre_opt == []
|
|
52
|
+
assert run_script == 'foo.py'
|
|
53
|
+
assert post_opt == ['--option1', '--option2']
|
|
54
|
+
|
|
55
|
+
# Test case 7: Not .py or .pyw extension
|
|
56
|
+
foo_full_path = os.path.join(this_script_dir, 'foo')
|
|
57
|
+
sys.argv = ['uvr', '--', foo_full_path, '--option1', '--option2']
|
|
58
|
+
pre_opt, run_script, post_opt = resolve_argv()
|
|
59
|
+
assert pre_opt == ['--script']
|
|
60
|
+
assert run_script == foo_full_path
|
|
61
|
+
assert post_opt == ['--option1', '--option2']
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# just
|
|
4
|
+
|
|
5
|
+
set -eo pipefail
|
|
6
|
+
|
|
7
|
+
# where to install uvr
|
|
8
|
+
# ~/.local/bin is a common place for user scripts
|
|
9
|
+
UVR_LOCAL_PATH=~/.local/bin
|
|
10
|
+
UVR_NAME=uvr
|
|
11
|
+
UVR_GIT_NAME=uvr-git
|
|
12
|
+
UVR_LOCAL_FULL_NAME=$UVR_LOCAL_PATH/$UVR_NAME
|
|
13
|
+
|
|
14
|
+
# if exists uvr-git, rename it to uvr
|
|
15
|
+
if [[ -L $UVR_LOCAL_PATH/$UVR_GIT_NAME ]]; then
|
|
16
|
+
|
|
17
|
+
mv $UVR_LOCAL_PATH/$UVR_GIT_NAME $UVR_LOCAL_PATH/$UVR_NAME # rename uvr-git to uvr
|
|
18
|
+
echo "Renamed $UVR_GIT_NAME to $UVR_NAME"
|
|
19
|
+
|
|
20
|
+
else
|
|
21
|
+
|
|
22
|
+
echo "No existing $UVR_GIT_NAME link found."
|
|
23
|
+
# uv uninstall uvr
|
|
24
|
+
# uv tool install --from git+https://github.com/karnigen/uvr uvr
|
|
25
|
+
|
|
26
|
+
fi
|
|
27
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# install local version of uvr in ~/.local/bin
|
|
4
|
+
|
|
5
|
+
set -eo pipefail
|
|
6
|
+
|
|
7
|
+
# where to install uvr
|
|
8
|
+
# ~/.local/bin is a common place for user scripts
|
|
9
|
+
UVR_LOCAL_PATH=~/.local/bin
|
|
10
|
+
UVR_NAME=uvr
|
|
11
|
+
UVR_GIT_NAME=uvr-git
|
|
12
|
+
UVR_LOCAL_FULL_NAME=$UVR_LOCAL_PATH/$UVR_NAME # .local/bin/uvr
|
|
13
|
+
|
|
14
|
+
# check if script is link use [[ ]]
|
|
15
|
+
if [[ -L $UVR_LOCAL_FULL_NAME ]]; then
|
|
16
|
+
LINK_TARGET=$(readlink -f $UVR_LOCAL_FULL_NAME) # get the target of the link: uvr -> ...
|
|
17
|
+
if [[ $LINK_TARGET == *".local/share"* ]]; then # this is uvr-git version
|
|
18
|
+
mv $UVR_LOCAL_FULL_NAME $UVR_LOCAL_PATH/$UVR_GIT_NAME # rename uvr to uvr-git
|
|
19
|
+
echo "Renamed $UVR_NAME to $UVR_GIT_NAME"
|
|
20
|
+
else # local version active
|
|
21
|
+
# rm $UVR_LOCAL_FULL_NAME
|
|
22
|
+
# echo "Removed existing link at $UVR_LOCAL_FULL_NAME"
|
|
23
|
+
echo "local version active: $LINK_TARGET"
|
|
24
|
+
exit 0
|
|
25
|
+
fi
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# git root directory
|
|
30
|
+
GIT_ROOT_DIR=$(git rev-parse --show-toplevel)
|
|
31
|
+
|
|
32
|
+
# if not installed create symbolic link to local uvr.py, and use force to overwrite existing link
|
|
33
|
+
ln -s -f $GIT_ROOT_DIR/src/uvr/uvr.py $UVR_LOCAL_FULL_NAME
|
|
34
|
+
|
|
35
|
+
echo "Installed $UVR_NAME to $UVR_LOCAL_FULL_NAME"
|
|
36
|
+
echo "Make sure $UVR_LOCAL_PATH is in your PATH"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
# uvr pytest
|
|
6
|
+
#uvr pytest --cov-report term-missing --cov-report html --cov-report xml --cov=uvr
|
|
7
|
+
|
|
8
|
+
GIT_ROOT_DIR=$(git rev-parse --show-toplevel)
|
|
9
|
+
cd $GIT_ROOT_DIR
|
|
10
|
+
echo "Current working directory: $(pwd)"
|
|
11
|
+
|
|
12
|
+
# uvr full path, maybe use type uvr to find it
|
|
13
|
+
UVR=$(type -p uvr)
|
|
14
|
+
echo "Using uvr at: $UVR"
|
|
15
|
+
if [[ -L $UVR ]]; then
|
|
16
|
+
UVR=$(readlink -f $UVR) # resolve symlink to the actual file
|
|
17
|
+
echo "Resolved uvr to: $UVR"
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
uvr pytest --cov=uvr --cov-report html:coverage --cov-report xml --cov-report term
|