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

feat: support for the uv plugin #5196

Merged
merged 29 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
13fe54e
feat: support for uv plugin
bepri Jan 6, 2025
2a6917a
test: tests for uv plugin
bepri Jan 6, 2025
2088c3b
chore: bump requirements files
bepri Jan 6, 2025
1946f93
chore: fix copyright header
bepri Jan 6, 2025
6af7333
docs: add uv plugin documentation
bepri Jan 7, 2025
368d64f
docs: update changelog
bepri Jan 8, 2025
df4d236
wip: use the hotfixed uv plugin
bepri Jan 8, 2025
7ac3f23
wip: re-freeze requirements
bepri Jan 8, 2025
28a7d78
Merge branch 'main' into work/uv-plugin/CRAFT-3841
bepri Jan 8, 2025
bc98690
docs: fix whitespace on uv plugin docs
bepri Jan 8, 2025
5fd0578
docs: fix duplicate label errors
medubelko Jan 9, 2025
2154f36
fix: revert freezing requirements
bepri Jan 13, 2025
597c1fe
Merge branch 'main' into work/uv-plugin/CRAFT-3841
bepri Jan 13, 2025
7d1f219
fix: revert requirements files (again)
bepri Jan 13, 2025
89679fc
chore: revert docs requirements change
bepri Jan 15, 2025
faf47c5
chore: update copyright
bepri Jan 15, 2025
a44829b
docs: add go-use plugin docs
bepri Jan 15, 2025
7a0a8d9
docs: fix trailing whitespace
bepri Jan 15, 2025
5885546
chore: pr feedback, rename spread test projects
bepri Jan 15, 2025
9474518
tests: clean up spread tests
bepri Jan 15, 2025
431bf18
fix: correct docstring style
medubelko Jan 15, 2025
8136dd6
refactor: unify python plugins into a function
bepri Jan 16, 2025
7338e79
style: run black
bepri Jan 16, 2025
6c19b77
style: fix lint errors
bepri Jan 17, 2025
5142f80
Merge branch 'main' into work/uv-plugin/CRAFT-3841
bepri Jan 17, 2025
c960660
chore: fix craft-parts versioning
bepri Jan 17, 2025
91f0cf8
chore: fix craft-parts versioning
bepri Jan 17, 2025
8f1612a
chore: update craft parts to 2.3.0
sergiusens Jan 21, 2025
e9d802b
chore: update craft-parts on setup.py too
bepri Jan 21, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ __pycache__
*.comp
*.snap
snap/.snapcraft/
.spread_multipass
.spread-reuse.*
/stage
*.swp
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def recursive_data_files(directory, install_directory):
"craft-archives~=2.0",
"craft-cli~=2.9",
"craft-grammar>=2.0.1,<3.0.0",
"craft-parts>=2.1.2,<3.0.0",
"craft-parts>=2.2.1,<3.0.0",
bepri marked this conversation as resolved.
Show resolved Hide resolved
"craft-platforms~=0.4",
"craft-providers>=2.0.4,<3.0.0",
"craft-store>=3.0.2,<4.0.0",
Expand Down
5 changes: 4 additions & 1 deletion snapcraft/parts/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
"""Snapcraft specific plugins."""


from .register import get_plugins, register

from .colcon_plugin import ColconPlugin
from .conda_plugin import CondaPlugin
from .flutter_plugin import FlutterPlugin
from .kernel_plugin import KernelPlugin
from .matter_sdk_plugin import MatterSdkPlugin
from .poetry_plugin import PoetryPlugin
from .python_plugin import PythonPlugin
from .register import get_plugins, register
from .uv_plugin import UvPlugin
bepri marked this conversation as resolved.
Show resolved Hide resolved

__all__ = [
"ColconPlugin",
Expand All @@ -36,4 +38,5 @@
"PythonPlugin",
"get_plugins",
"register",
"UvPlugin",
]
2 changes: 2 additions & 0 deletions snapcraft/parts/plugins/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .matter_sdk_plugin import MatterSdkPlugin
from .poetry_plugin import PoetryPlugin
from .python_plugin import PythonPlugin
from .uv_plugin import UvPlugin


def get_plugins(core22: bool) -> dict[str, PluginType]:
Expand All @@ -40,6 +41,7 @@ def get_plugins(core22: bool) -> dict[str, PluginType]:
"python": PythonPlugin,
"matter-sdk": MatterSdkPlugin,
"poetry": PoetryPlugin,
"uv": UvPlugin,
bepri marked this conversation as resolved.
Show resolved Hide resolved
}

if core22:
Expand Down
32 changes: 32 additions & 0 deletions snapcraft/parts/plugins/uv_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright 2022 Canonical Ltd.
bepri marked this conversation as resolved.
Show resolved Hide resolved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Snapcraft uv plugin"""

from typing import Optional

from craft_parts.plugins import uv_plugin
from overrides import override

from snapcraft.parts.plugins import python_common


class UvPlugin(uv_plugin.UvPlugin):
"""A uv plugin for Snapcraft."""

@override
def _get_system_python_interpreter(self) -> Optional[str]:
return python_common.get_system_interpreter(self._part_info)
1 change: 1 addition & 0 deletions tests/spread/core24/python-hello/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ environment:
PARAM/strict: ""
PARAM/classic: "--classic"
PARAM/poetry: ""
PARAM/uv: ""

restore: |
cd ./"${SPREAD_VARIANT}"
Expand Down
16 changes: 16 additions & 0 deletions tests/spread/core24/python-hello/uv/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: python-hello-uv
version: "1.0"
summary: simple python application
description: build a python application using core24
base: core24
confinement: strict

apps:
python-hello-uv:
command: bin/python $SNAP/bin/hello
parts:
hello:
plugin: uv
source: src
build-snaps:
- astral-uv
5 changes: 5 additions & 0 deletions tests/spread/core24/python-hello/uv/src/hello/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import black


def main():
print(f"hello world! black version: {black.__version__}")
16 changes: 16 additions & 0 deletions tests/spread/core24/python-hello/uv/src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[project]
name = "example"
bepri marked this conversation as resolved.
Show resolved Hide resolved
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"black==24.8.0",
]

[build-system]
requires = ["setuptools>61"]
build-backend = "setuptools.build_meta"

[project.scripts]
hello = "hello:main"
10 changes: 10 additions & 0 deletions tests/spread/core24/python-hello/uv/src/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3

from distutils.core import setup

setup(
name="hello",
version="0.1",
entry_points={"console_scripts": ["hello=hello:main"]},
packages=["hello"],
)
148 changes: 148 additions & 0 deletions tests/spread/core24/python-hello/uv/src/uv.lock
bepri marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ environment:
SNAP/qmake: qmake-hello
SNAP/maven: maven-hello
SNAP/dotnet: dotnet-hello
SNAP/uv: uv-hello

prepare: |
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: uv-hello
version: "1.0"
summary: simple python application
description: build a python application using core22
base: core22
confinement: strict

apps:
uv-hello:
command: bin/python $SNAP/bin/hello

parts:
hello:
plugin: uv
source: src
build-snaps:
- astral-uv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def main():
print("hello world")
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[project]
name = "example"
bepri marked this conversation as resolved.
Show resolved Hide resolved
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"black==24.8.0",
]

[build-system]
requires = ["setuptools>61"]
build-backend = "setuptools.build_meta"

[project.scripts]
hello = "hello:main"

Large diffs are not rendered by default.

Loading