Skip to content

Update the Python module (notably find_ruff_bin) for parity with uv#23406

Merged
zanieb merged 1 commit intomainfrom
zb/find-ruff-bin
Feb 20, 2026
Merged

Update the Python module (notably find_ruff_bin) for parity with uv#23406
zanieb merged 1 commit intomainfrom
zb/find-ruff-bin

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented Feb 18, 2026

Closes astral-sh/uv#14874
Closes #23402

uv has fairly extensive test coverage for this functionality but it seems challenging to copy it over

My smoke test strategy was to ask an LLM to build the wheel and test all of the cases

$ uv build --wheel
Building wheel...
Successfully built dist/ruff-0.15.1-py3-none-macosx_11_0_arm64.whl

$ WHEEL=dist/ruff-0.15.1-py3-none-macosx_11_0_arm64.whl

$ uv venv -q .smoke-venv && uv pip install -q --python .smoke-venv $WHEEL
$ .smoke-venv/bin/python -c "from ruff import find_ruff_bin; print(find_ruff_bin())"
/Users/zb/workspace/ruff/.smoke-venv/bin/ruff

$ .smoke-venv/bin/python -m ruff version
ruff 0.15.1+81 (1e42d4f11 2026-02-18)

$ uv run --no-project --with $WHEEL -- python -c "from ruff import find_ruff_bin; print(find_ruff_bin())"
/Users/zb/.cache/uv/archive-v0/zf7_vNji2jmEGEDox-9Vj/bin/ruff

$ uv run --no-project --with $WHEEL -- python -m ruff version
ruff 0.15.1+81 (1e42d4f11 2026-02-18)

$ uv pip install --target .smoke-target $WHEEL
$ PYTHONPATH=.smoke-target python3 -c "from ruff import find_ruff_bin; print(find_ruff_bin())"
/Users/zb/workspace/ruff/.smoke-target/bin/ruff

$ uv pip install --prefix .smoke-prefix $WHEEL
$ PYTHONPATH=.smoke-prefix/lib/python3.14/site-packages python3 -c "from ruff import find_ruff_bin; print(find_ruff_bin())"
/Users/zb/workspace/ruff/.smoke-prefix/bin/ruff

$ python3 -m pip install --user --break-system-packages $WHEEL                                                                                                                        
$ python3 -c "from ruff import find_ruff_bin; print(find_ruff_bin())"                                                                                                                                             
/Users/zb/Library/Python/3.13/bin/ruff                                                                                                                                                                            
                                                                                                                                                                                                                  
$ python3 -m ruff version                                                                                                                                                                                         
ruff 0.15.1+81 (1e42d4f11 2026-02-18)   

@zanieb zanieb changed the title Update find_ruff_bin for parity with find_uv_bin Update the Python module (notably find_ruff_bin) for parity with uv Feb 18, 2026
Comment on lines -38 to -43
# Search for pip-specific build environments.
#
# Expect to find ruff in <prefix>/pip-build-env-<rand>/overlay/bin/ruff
# Expect to find a "normal" folder at <prefix>/pip-build-env-<rand>/normal
#
# See: https://github.com/pypa/pip/blob/102d8187a1f5a4cd5de7a549fd8a9af34e89a54f/src/pip/_internal/build_env.py#L87
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started porting this over to uv then noticed we support it already

See astral-sh/uv#18095

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally added per #13321

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 18, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!


ruff_exe = "ruff" + sysconfig.get_config_var("EXE")
def _run() -> None:
ruff = os.fsdecode(find_ruff_bin())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine either way, but we did have a previous PR removing the os.fsdecode call: #18551.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm nice, let me apply that everywhere

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zanieb zanieb enabled auto-merge (squash) February 20, 2026 13:15
@zanieb zanieb merged commit d537f03 into main Feb 20, 2026
41 checks passed
@zanieb zanieb deleted the zb/find-ruff-bin branch February 20, 2026 13:18
knutwannheden pushed a commit to openrewrite/ruff that referenced this pull request Feb 20, 2026
…astral-sh#23406)

Closes astral-sh/uv#14874
Closes astral-sh#23402

uv has fairly extensive test coverage for this functionality but it
seems challenging to copy it over

My smoke test strategy was to ask an LLM to build the wheel and test all
of the cases

```
$ uv build --wheel
Building wheel...
Successfully built dist/ruff-0.15.1-py3-none-macosx_11_0_arm64.whl

$ WHEEL=dist/ruff-0.15.1-py3-none-macosx_11_0_arm64.whl

$ uv venv -q .smoke-venv && uv pip install -q --python .smoke-venv $WHEEL
$ .smoke-venv/bin/python -c "from ruff import find_ruff_bin; print(find_ruff_bin())"
/Users/zb/workspace/ruff/.smoke-venv/bin/ruff

$ .smoke-venv/bin/python -m ruff version
ruff 0.15.1+81 (1e42d4f 2026-02-18)

$ uv run --no-project --with $WHEEL -- python -c "from ruff import find_ruff_bin; print(find_ruff_bin())"
/Users/zb/.cache/uv/archive-v0/zf7_vNji2jmEGEDox-9Vj/bin/ruff

$ uv run --no-project --with $WHEEL -- python -m ruff version
ruff 0.15.1+81 (1e42d4f 2026-02-18)

$ uv pip install --target .smoke-target $WHEEL
$ PYTHONPATH=.smoke-target python3 -c "from ruff import find_ruff_bin; print(find_ruff_bin())"
/Users/zb/workspace/ruff/.smoke-target/bin/ruff

$ uv pip install --prefix .smoke-prefix $WHEEL
$ PYTHONPATH=.smoke-prefix/lib/python3.14/site-packages python3 -c "from ruff import find_ruff_bin; print(find_ruff_bin())"
/Users/zb/workspace/ruff/.smoke-prefix/bin/ruff

$ python3 -m pip install --user --break-system-packages $WHEEL                                                                                                                        
$ python3 -c "from ruff import find_ruff_bin; print(find_ruff_bin())"                                                                                                                                             
/Users/zb/Library/Python/3.13/bin/ruff                                                                                                                                                                            
                                                                                                                                                                                                                  
$ python3 -m ruff version                                                                                                                                                                                         
ruff 0.15.1+81 (1e42d4f 2026-02-18)   
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ruff fails to find itself when installed into an ephemeral venv uv run --with can't find installed ruff in subprocess

2 participants