Files
uv/python/uv/__main__.py
Zanie Blue 2586f655bb Rename to uv (#1302)
First, replace all usages in files in-place. I used my editor for this.
If someone wants to add a one-liner that'd be fun.

Then, update directory and file names:

```
# Run twice for nested directories
find . -type d -print0 | xargs -0 rename s/puffin/uv/g
find . -type d -print0 | xargs -0 rename s/puffin/uv/g

# Update files
find . -type f -print0 | xargs -0 rename s/puffin/uv/g
```

Then add all the files again

```
# Add all the files again
git add crates
git add python/uv

# This one needs a force-add
git add -f crates/uv-trampoline
```
2024-02-15 11:19:46 -06:00

40 lines
1023 B
Python

import os
import sys
import sysconfig
def find_uv_bin() -> str:
"""Return the uv binary path."""
uv_exe = "uv" + sysconfig.get_config_var("EXE")
path = os.path.join(sysconfig.get_path("scripts"), uv_exe)
if os.path.isfile(path):
return path
if sys.version_info >= (3, 10):
user_scheme = sysconfig.get_preferred_scheme("user")
elif os.name == "nt":
user_scheme = "nt_user"
elif sys.platform == "darwin" and sys._framework:
user_scheme = "osx_framework_user"
else:
user_scheme = "posix_user"
path = os.path.join(sysconfig.get_path("scripts", scheme=user_scheme), uv_exe)
if os.path.isfile(path):
return path
raise FileNotFoundError(path)
if __name__ == "__main__":
uv = os.fsdecode(find_uv_bin())
if sys.platform == "win32":
import subprocess
completed_process = subprocess.run([uv, *sys.argv[1:]])
sys.exit(completed_process.returncode)
else:
os.execvp(uv, [uv, *sys.argv[1:]])