Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't require a specific python interpreter for uv #1003

Merged
merged 8 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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