diff --git a/.dockerignore b/.dockerignore index 47dd0cbb0..c3b4e2fd6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ .github .idea -lib dist build diff --git a/Dockerfile b/Dockerfile index c6272e0e0..0ac975862 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,10 +74,12 @@ RUN cd qt-everywhere-src-6.7.0/build \ && rm -rf qt-everywhere-src-6.7.0 qt-everywhere-src-6.7.0.tar.xz FROM install_qt as create_user +ENV DEBIAN_FRONTEND=noninteractive RUN useradd -ms /bin/bash appuser \ && chown -R appuser:appuser /app \ && apt-get update \ && apt-get install -y libxkbcommon-x11-0 \ + && apt-get install -y nvidia-cudnn \ && rm -rf /var/lib/apt/lists/* USER appuser @@ -142,7 +144,9 @@ RUN git clone https://github.com/Capsize-Games/airunner.git /app/airunner \ && git pull \ && python3 -m pip install build \ && python3 -m build \ - && python3 -m pip install build dist/airunner-3.0.16-py3-none-any.whl + && cd /app/airunner/dist \ + && WHL_FILE=$(ls airunner-*.whl) \ + && python3 -m pip install build $WHL_FILE FROM build_airunner as build_airunner_executable USER appuser @@ -150,5 +154,6 @@ WORKDIR /app ENV HOME=/app ENV PATH="/home/appuser/.local/bin:${PATH}" ENV PYTHONUSERBASE=/home/appuser/.local -COPY build.airunner.linux.prod.spec build.airunner.linux.prod.spec -RUN echo "test" +ENV DOCKER_ENV=true +COPY airunner.spec airunner.spec +COPY ./lib/tokenizers/punkt /app/lib/tokenizers/punkt diff --git a/airunner.spec b/airunner.spec index e260cebcd..eaf7a43b7 100644 --- a/airunner.spec +++ b/airunner.spec @@ -3,24 +3,28 @@ import site import os -# Get the site-packages path -site_packages_path = site.getsitepackages()[0] +# Get the directory of the spec file +if os.getenv('DOCKER_ENV') == 'true': + root_path = os.path.dirname(os.path.abspath('airunner.spec')) + base_path = os.path.join(root_path, 'airunner') + site_packages_path = "/home/appuser/.local/lib/python3.10/site-packages/" + dist = "/app/dist" +else: + root_path = os.path.dirname(os.path.abspath('airunner.spec')) + base_path = root_path + site_packages_path = site.getsitepackages()[0] + dist = "./dist" + +# Set the path to the airunner package +airunner_path = os.path.join(base_path, "src/airunner") a = Analysis( - ['./src/airunner/main.py'], + [os.path.join(airunner_path, 'main.py')], pathex=[ - './src', + os.path.join(base_path, 'src'), ], binaries=[ - ('/usr/lib/x86_64-linux-gnu/libpython3.10.so', '.'), - ('./venv/lib/python3.10/site-packages/tiktoken/_tiktoken.cpython-310-x86_64-linux-gnu.so', '.'), - ('/usr/lib/x86_64-linux-gnu/libcudnn.so.8', '.'), # Add libcudnn shared libraries - ('/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8', '.'), - ('/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8', '.'), - ('/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8', '.'), - ('/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8', '.'), - ('/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8', '.'), - ('/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8', '.'), + (os.path.join(site_packages_path, 'tiktoken/_tiktoken.cpython-310-x86_64-linux-gnu.so'), '.'), (os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_adv.so.9'), '.'), (os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_cnn.so.9'), '.'), (os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_engines_precompiled.so.9'), '.'), @@ -29,10 +33,17 @@ a = Analysis( (os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_heuristic.so.9'), '.'), (os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_ops.so.9'), '.'), (os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn.so.9'), '.'), - + (os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6XcbQpa.so.6'), '.'), + (os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6DBus.so.6'), '.'), + (os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6Widgets.so.6'), '.'), + (os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6Gui.so.6'), '.'), + (os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6Core.so.6'), '.'), + ('/usr/lib/x86_64-linux-gnu/libpython3.10.so', '.'), + ('/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0', '.'), + ('/usr/lib/x86_64-linux-gnu/libxkbcommon-x11.so.0.0.0', '.'), ], datas=[ - ('./src/airunner/alembic.ini', '.'), + (os.path.join(airunner_path, 'alembic.ini'), '.'), (os.path.join(site_packages_path, 'inflect'), 'inflect'), (os.path.join(site_packages_path, 'controlnet_aux'), 'controlnet_aux'), (os.path.join(site_packages_path, 'diffusers'), 'diffusers'), @@ -42,6 +53,8 @@ a = Analysis( (os.path.join(site_packages_path, 'xformers'), 'xformers'), (os.path.join(site_packages_path, 'nvidia'), 'nvidia'), (os.path.join(site_packages_path, 'llama_index'), 'llama_index'), + (os.path.join(site_packages_path, 'PySide6'), 'PySide6'), + (os.path.join(site_packages_path, 'PySide6/Qt/plugins/platforms'), 'platforms'), # Add other data files or directories here ], hiddenimports=[ @@ -83,6 +96,7 @@ a = Analysis( 'llama_index.core.chat_engine', 'llama_index.core.indices.keyword_table', 'llama_index.core.base.llms.types', + 'PySide6', ], hookspath=[], hooksconfig={}, @@ -122,8 +136,18 @@ coll = COLLECT( ) import shutil -shutil.copytree('./src/airunner/images/', './dist/airunner/_internal/airunner/images/') -shutil.copytree('./src/airunner/styles/', './dist/airunner/_internal/airunner/styles/') -shutil.copytree('./src/airunner/alembic/', './dist/airunner/_internal/alembic/') -shutil.copytree('./src/airunner/data/', './dist/airunner/data/') -shutil.copytree('./lib/tokenizers/punkt', './dist/airunner/_internal/llama_index/core/_static/nltk_cache/tokenizers/punkt') +images_path = os.path.join(airunner_path, 'images/') +styles_path = os.path.join(airunner_path, 'styles/') +alembic_path = os.path.join(airunner_path, 'alembic/') +data_path = os.path.join(airunner_path, 'data/') +punkt_path = os.path.join(root_path, 'lib/tokenizers/punkt/') +print(f"Copy images from {images_path}...") +shutil.copytree(images_path, os.path.join(base_path, os.path.join(dist, 'airunner/_internal/airunner/images/'))) +print(f"Copy styles from {styles_path}...") +shutil.copytree(styles_path, os.path.join(base_path, os.path.join(dist, 'airunner/_internal/airunner/styles/'))) +print(f"Copy alembic from {alembic_path}...") +shutil.copytree(alembic_path, os.path.join(base_path, os.path.join(dist, 'airunner/_internal/alembic/'))) +print(f"Copy data from {data_path}...") +shutil.copytree(data_path, os.path.join(base_path, os.path.join(dist, 'airunner/data/'))) +print(f"Copy punkt from {punkt_path}...") +shutil.copytree(punkt_path, os.path.join(base_path, os.path.join(dist, 'airunner/_internal/llama_index/core/_static/nltk_cache/tokenizers/punkt'))) diff --git a/build.sh b/build.sh index b1600cbf8..275410246 100644 --- a/build.sh +++ b/build.sh @@ -3,10 +3,6 @@ DISABLE_TELEMETRY=1 cd /app -# Ensure the build directory exists and set permissions -mkdir -p /app/build -chmod -R 777 /app/build - echo "" echo "============================================" echo "Installing dependencies" @@ -18,7 +14,7 @@ echo "============================================" echo "Build airunner for linux" echo "============================================" echo "" -DEV_ENV=0 AIRUNNER_ENVIRONMENT="prod" PYTHONOPTIMIZE=0 python3 -m PyInstaller --log-level=INFO --noconfirm /app/build.airunner.linux.prod.spec 2>&1 | tee build.log +DEV_ENV=0 AIRUNNER_ENVIRONMENT="prod" PYTHONOPTIMIZE=0 python3 -m PyInstaller --log-level=INFO --noconfirm /app/airunner.spec 2>&1 | tee build.log echo "" echo "============================================" echo "Copy timm to dist" diff --git a/dobuild.py b/dobuild.py index 88e37ae4f..e36f75d3d 100644 --- a/dobuild.py +++ b/dobuild.py @@ -3,7 +3,10 @@ import json -# os.chdir("/app/airunner") -# os.system("git pull") -# os.system("python3 -m pip install .") - +os.chdir("/app/airunner") +os.system("git pull") +os.system("python3 -m build") +os.system("cd dist") +os.system("WHL_FILE=$(ls airunner-*.whl)") +os.system("python3 -m pip install build $WHL_FILE") +os.system("python3 -m pip install .") diff --git a/setup.py b/setup.py index 5c067297e..935fd55c1 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="airunner", - version="3.0.17", + version="3.0.18", author="Capsize LLC", description="A Stable Diffusion GUI", long_description=open("README.md", "r", encoding="utf-8").read(), @@ -28,7 +28,6 @@ "optimum==1.21.4", "numpy==1.26.4", "pillow==10.4.0", - "xformers==0.0.28.post1", "tensorflow==2.17.0", "DeepCache==0.1.1", "alembic==1.13.3",