How to get current `uv pip install` `--python-platform`?
Jun 10, 9:17am

To get the current --python-platform value used by uv pip install, you can use the following approach:

1. Check uv Configuration

uv (a fast Python package installer) respects the target platform for pip installations. The --python-platform flag specifies the platform (e.g., linux_x86_64, macos_arm64, windows_amd64).

To see the default platform uv is using, run:

bash
uv pip install --help | grep -A 5 "python-platform"

This will show the default value in the help text.


2. Detect the Current Platform

If you want to detect the platform of the current system, you can use Python:

bash
python -c "import sys, platform; print(f'{platform.system().lower()}_{platform.machine().lower()}')"

This will output something like:

  • linux_x86_64
  • darwin_arm64 (macOS on Apple Silicon)
  • windows_amd64

3. Check uv's Resolved Platform

If you want to see what platform uv resolves for the current environment, run:

bash
uv run python -c "import sys, platform; print(f'{platform.system().lower()}_{platform.machine().lower()}')"

This ensures the platform matches what uv would use.


4. Explicitly Set --python-platform

If you want to force a specific platform, use:

bash
uv pip install <package> --python-platform linux_x86_64

Replace linux_x86_64 with your target (e.g., macos_arm64, windows_amd64).


Summary Table

Platform Detection Methods
Help Text
uv pip install --help | grep -A 5 "python-platform"
Shows default in help
Python
python -c "import platform; print(f'{platform.system().lower()}_{platform.machine().lower()}')"
linux_x86_64
UV Resolved
uv run python -c "import platform; print(f'{platform.system().lower()}_{platform.machine().lower()}')"
darwin_arm64
Force Platform
uv pip install <package> --python-platform linux_x86_64
Uses specified platform

Need to target a specific platform? Let me know which one, and I can help you craft the exact command!

Jun 10, 9:17am

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more