diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 834af7e..4fa1690 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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 @@ -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 \ @@ -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 && \ @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/.devcontainer/build_wheel_3_10/devcontainer.json b/.devcontainer/build_wheel_3_10/devcontainer.json new file mode 100644 index 0000000..a479fb5 --- /dev/null +++ b/.devcontainer/build_wheel_3_10/devcontainer.json @@ -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" +} \ No newline at end of file diff --git a/.devcontainer/build_wheel_3_11/devcontainer.json b/.devcontainer/build_wheel_3_11/devcontainer.json new file mode 100644 index 0000000..ff99718 --- /dev/null +++ b/.devcontainer/build_wheel_3_11/devcontainer.json @@ -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" +} \ No newline at end of file diff --git a/.devcontainer/build_wheel_3_12/devcontainer.json b/.devcontainer/build_wheel_3_12/devcontainer.json index a5a01d3..ab8f125 100644 --- a/.devcontainer/build_wheel_3_12/devcontainer.json +++ b/.devcontainer/build_wheel_3_12/devcontainer.json @@ -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" } \ No newline at end of file diff --git a/.devcontainer/build_wheel_3_8/devcontainer.json b/.devcontainer/build_wheel_3_8/devcontainer.json new file mode 100644 index 0000000..a03f031 --- /dev/null +++ b/.devcontainer/build_wheel_3_8/devcontainer.json @@ -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" +} \ No newline at end of file diff --git a/.devcontainer/build_wheel_3_9/devcontainer.json b/.devcontainer/build_wheel_3_9/devcontainer.json new file mode 100644 index 0000000..3230d0b --- /dev/null +++ b/.devcontainer/build_wheel_3_9/devcontainer.json @@ -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" +} \ No newline at end of file diff --git a/.devcontainer/develop/devcontainer.json b/.devcontainer/develop/devcontainer.json index c795348..ced6fc7 100644 --- a/.devcontainer/develop/devcontainer.json +++ b/.devcontainer/develop/devcontainer.json @@ -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": { diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml deleted file mode 100644 index 6786b00..0000000 --- a/.devcontainer/docker-compose.yml +++ /dev/null @@ -1,25 +0,0 @@ -services: - devcontainer: - platform: linux/amd64 - build: - context: . - dockerfile: Dockerfile - args: - - PYTHON_VERSION=3.12 - stdin_open: true # docker run -i - tty: true # docker run -t - volumes: - - ..:/workspaces/pymeshlab - # Next flags are necessary to deploy meshlab and create the AppImage - # fuse is needed. If you don't plan to create the AppImage, you can remove the - # following lines - - /lib/modules:/lib/modules - # flag --device /dev/fuse - devices: - - /dev/fuse - # flag --cap-add SYS_ADMIN - cap_add: - - SYS_ADMIN - # flag --security-opt apparmor:unconfined - security_opt: - - apparmor:unconfined diff --git a/scripts/Linux/make_wheel.sh b/scripts/Linux/make_wheel.sh new file mode 100644 index 0000000..99cab3b --- /dev/null +++ b/scripts/Linux/make_wheel.sh @@ -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 \ No newline at end of file