Skip to content

Commit

Permalink
devcontainer configurations to build wheel for each python version an…
Browse files Browse the repository at this point in the history
…d to develop pymeshlab
  • Loading branch information
alemuntoni committed Jul 19, 2024
1 parent 720afd3 commit 7b737b0
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 32 deletions.
22 changes: 20 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM ubuntu:20.04

ARG USERNAME=pymeshlab
ARG USER_UID=1000
ARG USER_GID=$USER_UID

ARG QT_VERSION=5.15.2
ARG PYTHON_VERSION=3.11

Expand Down Expand Up @@ -30,9 +34,12 @@ RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
libxcb-render-util0-dev \
libxcb-shape0 \
libxcb-xinerama0-dev \
libxcb-xkb-dev \
libxkbcommon-x11-dev \
libxerces-c-dev \
ninja-build \
patchelf \
rsync \
# to be removed
python3 \
python3-pip \
Expand All @@ -46,7 +53,7 @@ RUN aqt install-qt -O /opt/qt linux desktop ${QT_VERSION} && \
# install python
RUN apt-get -y install software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa -y && apt-get -y update && \
apt-get -y install python${PYTHON_VERSION} python${PYTHON_VERSION}-dev && \
apt-get -y install python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-distutils && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 && \
wget https://bootstrap.pypa.io/get-pip.py && \
python${PYTHON_VERSION} get-pip.py && \
Expand All @@ -66,4 +73,15 @@ RUN apt-get -y purge --auto-remove cmake && \
rm -rf /var/lib/apt/lists/*

# Generating a universally unique ID for the Container
RUN dbus-uuidgen > /etc/machine-id
RUN dbus-uuidgen > /etc/machine-id

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
# [Optional] Add sudo support.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

USER $USERNAME
20 changes: 20 additions & 0 deletions .devcontainer/build_wheel_3_10/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "PyMeshLab wheel for Python 3.10",

"build": {
"dockerfile": "../Dockerfile",
"args": {
"PYTHON_VERSION": "3.10"
}
},
"runArgs": [
"-v", "/lib/modules:/lib/modules",
"--device", "/dev/fuse",
"--cap-add", "SYS_ADMIN",
"--security-opt", "apparmor=unconfined"
],
"workspaceFolder": "/workspaces/pymeshlab",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/pymeshlab,type=bind",

"postStartCommand": "bash scripts/Linux/make_wheel.sh"
}
20 changes: 20 additions & 0 deletions .devcontainer/build_wheel_3_11/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "PyMeshLab wheel for Python 3.11",

"build": {
"dockerfile": "../Dockerfile",
"args": {
"PYTHON_VERSION": "3.11"
}
},
"runArgs": [
"-v", "/lib/modules:/lib/modules",
"--device", "/dev/fuse",
"--cap-add", "SYS_ADMIN",
"--security-opt", "apparmor=unconfined"
],
"workspaceFolder": "/workspaces/pymeshlab",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/pymeshlab,type=bind",

"postStartCommand": "bash scripts/Linux/make_wheel.sh"
}
19 changes: 16 additions & 3 deletions .devcontainer/build_wheel_3_12/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
{
"name": "PyMeshLab wheel for Python 3.12",
"dockerComposeFile": "../docker-compose.yml",
"service": "devcontainer",

"build": {
"dockerfile": "../Dockerfile",
"args": {
"PYTHON_VERSION": "3.12"
}
},
"runArgs": [
"-v", "/lib/modules:/lib/modules",
"--device", "/dev/fuse",
"--cap-add", "SYS_ADMIN",
"--security-opt", "apparmor=unconfined"
],
"workspaceFolder": "/workspaces/pymeshlab",
// TODO
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/pymeshlab,type=bind",

"postStartCommand": "bash scripts/Linux/make_wheel.sh"
}
20 changes: 20 additions & 0 deletions .devcontainer/build_wheel_3_8/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "PyMeshLab wheel for Python 3.8",

"build": {
"dockerfile": "../Dockerfile",
"args": {
"PYTHON_VERSION": "3.8"
}
},
"runArgs": [
"-v", "/lib/modules:/lib/modules",
"--device", "/dev/fuse",
"--cap-add", "SYS_ADMIN",
"--security-opt", "apparmor=unconfined"
],
"workspaceFolder": "/workspaces/pymeshlab",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/pymeshlab,type=bind",

"postStartCommand": "bash scripts/Linux/make_wheel.sh"
}
20 changes: 20 additions & 0 deletions .devcontainer/build_wheel_3_9/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "PyMeshLab wheel for Python 3.9",

"build": {
"dockerfile": "../Dockerfile",
"args": {
"PYTHON_VERSION": "3.9"
}
},
"runArgs": [
"-v", "/lib/modules:/lib/modules",
"--device", "/dev/fuse",
"--cap-add", "SYS_ADMIN",
"--security-opt", "apparmor=unconfined"
],
"workspaceFolder": "/workspaces/pymeshlab",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/pymeshlab,type=bind",

"postStartCommand": "bash scripts/Linux/make_wheel.sh"
}
17 changes: 15 additions & 2 deletions .devcontainer/develop/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"name": "Develop PyMeshLab",
"dockerComposeFile": "../docker-compose.yml",
"service": "devcontainer",

"build": {
"dockerfile": "../Dockerfile",
"args": {
"PYTHON_VERSION": "3.12"
}
},
"runArgs": [
"-ti",
"-v", "/lib/modules:/lib/modules",
"--device", "/dev/fuse",
"--cap-add", "SYS_ADMIN",
"--security-opt", "apparmor=unconfined",
],
"workspaceFolder": "/workspaces/pymeshlab",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/pymeshlab,type=bind",

// vscode extensions
"customizations": {
Expand Down
25 changes: 0 additions & 25 deletions .devcontainer/docker-compose.yml

This file was deleted.

62 changes: 62 additions & 0 deletions scripts/Linux/make_wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

SCRIPTS_PATH="$(dirname "$(realpath "$0")")"
SOURCE_PATH=$SCRIPTS_PATH/../..

BUILD_PATH=$SOURCE_PATH/build
BUILD_OPTION=""

INSTALL_PATH=$SOURCE_PATH/pymeshlab
INSTALL_OPTION=""

WHEELS_PATH=$SOURCE_PATH/wheels

NIGHTLY_OPTION=""
QT_OPTION=""
CCACHE_OPTION=""

#check parameters
for i in "$@"
do
case $i in
-b=*|--build_path=*)
BUILD_PATH="${i#*=}"
BUILD_OPTION="-b=${i#*=}"
shift # past argument=value
;;
-i=*|--install_path=*)
INSTALL_PATH="${i#*=}"
INSTALL_OPTION="-i=${i#*=}"
shift # past argument=value
;;
-w=*|--wheels_path=*)
WHEELS_PATH="${i#*=}"
shift # past argument=value
;;
-n|--nightly)
NIGHTLY_OPTION="-n"
shift # past argument=value
;;
-qt=*|--qt_dir=*)
QT_OPTION="-qt=${i#*=}"
shift # past argument=value
;;
--ccache)
CCACHE_OPTION="--ccache"
shift # past argument=value
;;
*)
# unknown option
;;
esac
done

bash $SCRIPTS_PATH/1_build.sh $BUILD_OPTION $INSTALL_OPTION $NIGHTLY_OPTION $QT_OPTION $CCACHE_OPTION
bash $SCRIPTS_PATH/2_deploy.sh $INSTALL_OPTION $QT_OPTION

pip wheel $SOURCE_PATH -w $WHEELS_PATH

rm -rf $BUILD_PATH
rm -rf $INSTALL_PATH/pmeshlab*
rm -rf $INSTALL_PATH/lib
rm -rf pymeshlab.egg-info

0 comments on commit 7b737b0

Please sign in to comment.