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

Draft: feat(22.04): Slicing python3.10-venv and python3.10 #270

Closed

Conversation

gregory-schiano
Copy link

Proposed changes

Adding python3.10-venv chiseled package and its dependency, including python3.10
The aim is to be able to use the python plugin on rockcraft entirely with chiseled packages, allowing very small OCI images for python applications.

Related issues/PRs

N/A

Forward porting

Python3.12 is available on Noble and is the default Python version for noble

Testing

To test in a VM, start an ubuntu-22.04, copy this branch into /home/chisel folder (or mount it):

apt update && apt install -y golang-1.22 ca-certificates
update-alternatives --install /usr/bin/go go /usr/lib/go-1.22/bin/go 0
go install github.com/canonical/chisel/cmd/chisel@latest
/root/go/bin/chisel cut --release /home/chisel/ --root / python3.10-venv_ensurepip
cd ~
mkdir test
cd test
python3.10 -m venv env
echo "flask" > requirements.txt
source env/bin/activate
pip install -r requirements.txt

To test using rockcraft use the following rockcraft.yaml at the root of this repository folder

name: python-venv
title: python-venv
version: '0.1'
summary: Testing python3.10-venv slice in bare
description: |
  Testing python3.10-venv slice in bare
base: bare
build-base: [email protected]
platforms:
  amd64:
parts:
  chisel:
    plugin: dump
    source: .
    override-build: |
      chisel cut --release ./ --root ${CRAFT_PART_INSTALL} python3.10-venv_ensurepip
  slices:
    plugin: nil
    override-build: mkdir -m 777 ${CRAFT_PART_INSTALL}/tmp
    stage-packages:
    - bash_bins
    - coreutils_bins
    - ca-certificates_data
run-user: _daemon_

You'll need rockcraft snap installed, and docker installed:

rockcraft pack
rockcraft.skopeo copy --insecure-policy oci-archive:python-venv_0.1_amd64.rock docker-daemon:python-venv:test
docker run --name test -d python-venv:test
docker exec -ti test bash
cd ~
mkdir test
cd test
python3.10 -m venv env
echo "flask" > requirements.txt
source env/bin/activate
pip install -r requirements.txt

Checklist

Additional Context

This a followup PR of #259 as Python3.11 is a universe package, running a release candidate of Python3.11. We wanted to have a sliced Python version relying on a maintained package.

@gregory-schiano gregory-schiano deleted the python3-10-slice branch June 24, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants