Skip to content

Commit

Permalink
fix: don't require a specific python interpreter for uv (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
bepri authored Feb 5, 2025
1 parent a04f571 commit 3fb0f27
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion craft_parts/plugins/uv_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,14 @@ def _get_rewrite_shebangs_commands(self) -> list[str]:
return []

def _get_create_venv_commands(self) -> list[str]:
# Explicitly request a Python version if provided by the plugin, otherwise use the global
# parts interpreter.
python_ver = (
self._get_system_python_interpreter()
or "$(which ${PARTS_PYTHON_INTERPRETER})"
)
return [
f'uv venv --relocatable --allow-existing --python "{self._get_system_python_interpreter()}" "{self._get_venv_directory()}"',
f'uv venv --relocatable --allow-existing --python {python_ver} "{self._get_venv_directory()}"',
f'PARTS_PYTHON_VENV_INTERP_PATH="{self._get_venv_directory()}/bin/${{PARTS_PYTHON_INTERPRETER}}"',
]

Expand Down
8 changes: 8 additions & 0 deletions docs/reference/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog
*********

X.X.X (2025-MM-DD)
------------------

Bug fixes:

- Allow for a non-specific system Python interpreter when using the
:ref:`uv plugin<craft_parts_uv_plugin>`.

2.5.0 (2025-01-30)
------------------

Expand Down
4 changes: 3 additions & 1 deletion tests/integration/plugins/test_uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ def _should_remove_symlinks(self) -> bool:
)
actions = lf.plan(Step.PRIME)

with lf.action_executor() as ctx, pytest.raises(errors.PluginBuildError):
with lf.action_executor() as ctx, pytest.raises(errors.PluginBuildError) as exc:
ctx.execute(actions)

assert b"No suitable Python interpreter found" in cast(bytes, exc.value.stderr)


def test_uv_plugin_remove_symlinks(new_dir, partitions, uv_parts_simple):
"""Override symlink removal."""
Expand Down

0 comments on commit 3fb0f27

Please sign in to comment.