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

build(snap): add sitecustomize to snap package #822

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies = [
"craft-parts",
"craft-platforms",
"craft-providers",
"craft-store",
"overrides",
"spdx-lookup",
"tabulate",
Expand Down
26 changes: 26 additions & 0 deletions snap/local/sitecustomize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Dynamically load stage-package from another snap into our sys.path.

https://docs.python.org/3/library/site.html#module-sitecustomize
"""

import hashlib
import os
import sys
from pathlib import Path

TARGET_HASH = "8641d59472d54186f68939ab09cd4882cfba8f20efe278e6a539973c0b3e512c84d952e80f1d7297f8fd025e6878ea58"


def _find_pkg() -> None:
for craft_dir in Path("/snap").glob("*craft*/current"):
hasher = hashlib.sha3_384()
hasher.update(str(craft_dir).encode())
pkg_dir_hash = hasher.hexdigest()
if pkg_dir_hash != TARGET_HASH:
continue
pkg_path = craft_dir / "craft-plugins"
sys.path.insert(0, os.fspath(pkg_path))
return


_find_pkg()
2 changes: 2 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ parts:
plugin: dump
organize:
craft.git: libexec/rockcraft/craft.git
# Put sitecustomize in site-packages
sitecustomize.py: lib/python3.12/site-packages/sitecustomize.py

git:
plugin: nil
Expand Down
109 changes: 109 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading