Skip to content
Draft
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
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ conflicts = [
{ extra = "apt-plucky" },
]
]
build-constraint-dependencies = [
# needed until we have rustc >= 1.78
"maturin<1.10.0 ; python_version < '3.14'",
]

[dependency-groups]
dev = [
Expand Down
49 changes: 21 additions & 28 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,18 @@ parts:
prime:
- -usr/include

python3-apt:
plugin: nil
build-attributes:
- enable-patchelf
stage-packages:
- python3-apt
organize:
"usr/lib/python3/dist-packages/*": "lib/python3.12/site-packages/"

rockcraft:
source: .
plugin: python
python-requirements:
# These will be generated by override-build
- uv-requirements.txt
# This has the source for python-apt for noble
- requirements-noble.txt
plugin: uv
build-attributes:
- enable-patchelf
build-packages:
Expand All @@ -115,45 +119,34 @@ parts:
- astral-uv
build-environment:
- "CFLAGS": "$(pkg-config python-3.12 yaml-0.1 --cflags)"
- "PIP_NO_BINARY": ":all:"
- UV_FROZEN: "true"
- UV_PYTHON: /usr/bin/python3
- UV_NO_BINARY: "true"
# Parallel make jobs for things like python-apt
- MAKEOPTS: -j$(nproc --all)
- UV_COMPILE_BYTECODE: "true"
organize:
bin/craftctl: libexec/rockcraft/craftctl
# Extensions currently expect to find data files in share/rockcraft/
"**/site-packages/extensions": share/rockcraft/extensions
override-build: |

# Bug: If git sources are used for any of the requirements (eg. package from a development branch),
# the build will fail because the hashes provided by uv by default trigger pip to validate all
# the packages. If any package does provide a hash, such as a git source the validation will fail.
# Fix: remove the hashes from all requirements files if they are present with git sources
uv export --no-dev --no-emit-workspace --no-emit-package pywin32 --output-file uv-requirements.txt


requirements_pattern='*requirements*.txt'
hash_pattern='--hash=sha256:[a-f0-9]{64}'
if grep -P -- $hash_pattern $requirements_pattern > /dev/null ; then

echo "Warning: git sources detected in uv-requirements.txt, rebuilding requirements without hashes."

for req_txt in $requirements_pattern; do
sed -Ei s/$hash_pattern// $req_txt
done
fi

${SNAP}/libexec/snapcraft/craftctl default

version="$("${CRAFT_STAGE}/usr/bin/python3" -c "import rockcraft;print(rockcraft.__version__)")"
version="$(uv pip show rockcraft | grep "Version:" | cut -d' ' -f2)"
${SNAP}/libexec/snapcraft/craftctl set version="$version"

[ -n "$(echo $version | grep "post")" ] && grade=devel || grade=stable
${SNAP}/libexec/snapcraft/craftctl set grade="${grade}"

sed -i -e '1 s|^#!/.*|#!/snap/rockcraft/current/bin/python -E|' $CRAFT_PART_INSTALL/bin/craftctl

# Fix the Python executable from uv, which had bad symlinks
rm $CRAFT_PART_INSTALL/bin/python*
ln -s ../usr/bin/python3 $CRAFT_PART_INSTALL/bin/python3
ln -s python3 $CRAFT_PART_INSTALL/bin/python
after:
- rockcraft-libs
- libgit2
- python3-apt

bash-completion:
after: [rockcraft]
Expand Down
3 changes: 2 additions & 1 deletion tests/spread/pro/packages/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ environment:
PACK_ARGS/managed_standard_stage_full: ""

prepare: |
sudo pro attach --no-auto-enable $UBUNTU_PRO_TOKEN
sudo pro attach --no-auto-enable $UBUNTU_PRO_TOKEN
sudo pro enable --assume-yes $ENV_PRO_ARG
sudo pro config set lxd_guest_attach=available

execute: |

Expand Down
Loading
Loading