Skip to content

Commit

Permalink
Merge pull request #930 from Capsize-Games/devastator
Browse files Browse the repository at this point in the history
build fixes
  • Loading branch information
w4ffl35 authored Oct 11, 2024
2 parents 3cd9c8c + 4574fc2 commit ff2bbe9
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 353 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,4 @@ 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"
297 changes: 98 additions & 199 deletions airunner.spec
Original file line number Diff line number Diff line change
@@ -1,230 +1,129 @@
# -*- mode: python ; coding: utf-8 -*-

import site
import os
import shutil
from PyInstaller.utils.hooks import copy_metadata, collect_data_files
import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)
os.environ["AIRUNNER_ENVIRONMENT"] = "prod"
libraries = [
"./venv/lib/python3.10/site-packages/h5py.libs/",
"./venv/lib/python3.10/site-packages/scipy.libs/",
"./venv/lib/python3.10/site-packages/pillow.libs/",
"./venv/lib/python3.10/site-packages/tokenizers/",
"./opencv_python_headless.libs/",
"./venv/lib/python3.10/site-packages/torchaudio/lib/",
"./venv/lib/python3.10/site-packages/torch/lib/",
"/usr/lib/python3.10",
"/usr/lib/x86_64-linux-gnu/",
"/usr/local/lib/",
"/usr/local/lib/python3.10",
"/usr/local/lib/python3.10/dist-packages",
"./venv/lib/python3.10/site-packages/PySide6/Qt/plugins/platforms/",
"./venv/lib/python3.10/site-packages/PySide6/Qt/lib/",
"/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/",
"./venv/lib/python3.10/site-packages/PySide6/Qt/plugins/platforms/",
]
os.environ["LD_LIBRARY_PATH"] = ":".join(libraries)
block_cipher = None
DEBUGGING = True
EXCLUDE_BINARIES = True
EXE_NAME = "airunner" # used when creating a binary instead of a folder
EXE_STRIP = False
EXE_UPX = True
EXE_RUNTIME_TMP_DIR = None
COLLECT_NAME = 'airunner'
COLLECT_STRIP = False
COLLECT_UPX = True
datas = [
]
datas += copy_metadata('tqdm')
datas += copy_metadata('regex')
datas += copy_metadata('requests')
datas += copy_metadata('packaging')
datas += copy_metadata('filelock')
datas += copy_metadata('numpy')
datas += copy_metadata('tokenizers')
datas += copy_metadata('transformers')
datas += copy_metadata('rich')
datas += copy_metadata('sympy')
datas += copy_metadata('opencv-python-headless')
datas += collect_data_files("torch", include_py_files=True)
datas += collect_data_files("torchvision", include_py_files=True)
#datas += collect_data_files("JIT", include_py_files=True)
# datas += collect_data_files("pytorch_lightning", include_py_files=True)
# datas += collect_data_files("lightning_fabric", include_py_files=True)
datas += collect_data_files("transformers", include_py_files=True)
datas += collect_data_files("sympy", include_py_files=True)
datas += collect_data_files("controlnet_aux", include_py_files=True)
datas += collect_data_files("PySide6", include_py_files=True)
# datas += collect_data_files('PySide6', subdir='plugins/platforms')
#datas += [('/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms', 'PySide6/plugins/platforms')]

# Get the site-packages path
site_packages_path = site.getsitepackages()[0]

a = Analysis(
[
f'./src/airunner/main.py',
],
['./src/airunner/main.py'],
pathex=[
"./venv/lib/python3.10/site-packages/",
"./venv/lib/python3.10/site-packages/torch/lib",
"./venv/lib/python3.10/site-packages/tokenizers",
"./venv/lib/python3.10/site-packages/tensorflow",
"/usr/lib/x86_64-linux-gnu/",
'./src',
],
binaries=[
('/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8', '.'),
('/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/qt6/plugins/platforms/libqxcb.so', '.'),
# ('/usr/lib/x86_64-linux-gnu/libxcb-cursor.so', '.')
('./venv/lib/python3.10/site-packages/PySide6/Qt/plugins/platforms/clea.so', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb-cursor.so', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb-cursor.so.0', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb-xinerama.so.0', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb-xinput.so.0', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb-icccm.so.4', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb-image.so.0', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb-keysyms.so.1', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb-render-util.so.0', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb-xkb.so.1', '.'),
('/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, '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'), '.'),
(os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_engines_runtime_compiled.so.9'), '.'),
(os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_graph.so.9'), '.'),
(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'), '.'),

],
datas=[
('./src/airunner/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'),
(os.path.join(site_packages_path, 'tiktoken'), 'tiktoken'),
(os.path.join(site_packages_path, 'tiktoken_ext'), 'tiktoken_ext'),
(os.path.join(site_packages_path, 'pydantic'), 'pydantic'),
(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'),
# Add other data files or directories here
],
datas=datas,
hiddenimports=[
"xcb-cursor0",
"airunner",
#"JIT",
"tqdm",
"diffusers",
"transformers",
"nvidia",
"torch",
"torchvision",
"torchvision.io",
"logging",
"logging.config",
"einops",
# "omegaconf",
"contextlib",
"itertools",
#"pytorch_lightning",
"huggingface_hub.hf_api",
"huggingface_hub.repository",
"inspect",
"psutil",
"matplotlib",
"numpy",
"PIL._tkinter_finder",
"sympy",
"opencv-python-headless",
"pytz",
"PySide6",
'airunner',
'airunner.data.models',
'airunner.data.models.settings_models',
'airunner.utils.db.column_exists',
'airunner.data.bootstrap.controlnet_bootstrap_data',
'airunner.data.bootstrap.font_settings_bootstrap_data',
'airunner.data.bootstrap.imagefilter_bootstrap_data',
'airunner.data.bootstrap.model_bootstrap_data',
'airunner.data.bootstrap.pipeline_bootstrap_data',
'airunner.data.bootstrap.prompt_templates_bootstrap_data',
'diffusers',
'diffusers.loaders',
'diffusers.loaders.ip_adapter',
'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion',
'torch',
'torch.jit',
'torch.jit._script',
'torch.jit.frontend',
'torch._sources',
'xformers',
'xformers.ops',
'xformers.ops.fmha',
'xformers.ops.fmha.triton_splitk',
'tiktoken',
'tiktoken.model',
'tiktoken.registry',
'tiktoken_ext',
'nvidia',
'nvidia.lib',
'nvidia.lib.cudnn',
'llama_index',
'llama_index.core',
'llama_index.readers',
'llama_index.readers.file',
'llama_index.core.node_parser',
'llama_index.core.chat_engine',
'llama_index.core.indices.keyword_table',
'llama_index.core.base.llms.types',
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
"tcl",
"tcl8",
"cmake",
"cryptography",
"email-validator",
"google",
"google-auth",
"google-auth-oauthlib",
"google-pasta",
"Jinja2",
"lightning-cloud",
"Markdown",
"markdown-it-py",
"MarkupSafe",
"mdurl",
"ninja",
"nvidia-pyindex",
"tensorboard",
"tensorboard-data-server",
"tensorboard-plugin-wit",
"unattended-upgrades",
"watchfiles",
"wcwidth",
"websocket-client",
"websockets",
],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(
a.pure,
a.zipped_data,
cipher=block_cipher
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=EXCLUDE_BINARIES,
name=EXE_NAME,
debug=DEBUGGING,
strip=EXE_STRIP,
upx=EXE_UPX,
runtime_tmpdir=EXE_RUNTIME_TMP_DIR,
console=DEBUGGING
exclude_binaries=True,
name='airunner',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
# onefile=True,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=COLLECT_STRIP,
upx=COLLECT_UPX,
strip=False,
upx=True,
upx_exclude=[],
name=COLLECT_NAME
name='airunner',
)

import shutil
import os
import glob

# Define source directories
source_dirs = ['./src/airunner/widgets', './src/airunner/windows']
destination_base_dir = './dist/airunner'

# Copy all .ui files from source directories to the destination directory
for source_dir in source_dirs:
for templates_dir in glob.glob(os.path.join(source_dir, '**', 'templates'), recursive=True):
for ui_file in glob.glob(os.path.join(templates_dir, '*.ui'), recursive=True):
# Create the corresponding subdirectory in the destination directory
relative_path = os.path.relpath(ui_file, source_dir)
destination_dir = os.path.join(destination_base_dir, os.path.dirname(relative_path))
os.makedirs(destination_dir, exist_ok=True)
# Copy the .ui file to the destination directory
shutil.copy(ui_file, destination_dir)



os.makedirs('./dist/airunner/diffusers/pipelines/stable_diffusion', exist_ok=True)
os.makedirs('./dist/airunner/images', exist_ok=True)

# copy files for distribution
# shutil.copyfile('./linux.itch.toml', './dist/airunner/.itch.toml')
shutil.copyfile('./src/airunner/images/splashscreen.png', './dist/airunner/images/splashscreen.png')
shutil.copytree('src/airunner/styles/icons/dark/', './dist/airunner/icons/dark/')
shutil.copytree('src/airunner/styles/icons/light/', './dist/airunner/icons/light/')

# copy alembic files
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.copyfile('./src/airunner/alembic.ini', './dist/airunner/_internal/alembic.ini')

# copy bootstrap data
shutil.copytree('./src/airunner/data/', './dist/airunner/data/')

# copy sd config files
# shutil.copyfile('./src/airunner/v1.yaml', './dist/airunner/v1.yaml')
# shutil.copyfile('./src/airunner/v2.yaml', './dist/airunner/v2.yaml')

# copy llamaindex nltk cache requirements
shutil.copytree('./lib/corpora', './dist/airunner/_internal/llama_index/core/_static/nltk_cache/corpora')
shutil.copytree('./lib/tokenizers', './dist/airunner/_internal/llama_index/core/_static/nltk_cache/tokenizers')

# shutil.copyfile(
# f'./venv/lib/python3.10/site-packages/JIT/__pycache__/random.cpython-310.pyc',
# f'./dist/airunner/random.pyc'
# )
shutil.copytree('./lib/tokenizers/punkt', './dist/airunner/_internal/llama_index/core/_static/nltk_cache/tokenizers/punkt')
9 changes: 5 additions & 4 deletions build.airunner.linux.prod.spec
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ a = Analysis(
f'/app/airunner/src/airunner/main.py',
],
pathex=[
"/app/airunner/src",
"/home/appuser/.local/lib/python3.10/site-packages/",
"/home/appuser/.local/lib/python3.10/site-packages/torch/lib/",
"/home/appuser/.local/lib/python3.10/site-packages/tokenizers/",
Expand Down Expand Up @@ -195,8 +196,8 @@ os.makedirs('/app/dist/airunner/images', exist_ok=True)

# Copy files for distribution
shutil.copyfile('/app/airunner/src/airunner/images/splashscreen.png', '/app/dist/airunner/images/splashscreen.png')
shutil.copytree('/app/airunner/src/airunner/styles/icons/dark/', '/app/dist/airunner/styles/icons/dark/')
shutil.copytree('/app/airunner/src/airunner/styles/icons/light/', '/app/dist/airunner/styles/icons/light/')
# shutil.copytree('/app/airunner/src/airunner/styles/icons/dark/', '/app/dist/airunner/styles/icons/dark/')
# shutil.copytree('/app/airunner/src/airunner/styles/icons/light/', '/app/dist/airunner/styles/icons/light/')

# Copy alembic files
shutil.copytree('/app/airunner/src/airunner/alembic/', '/app/dist/airunner/_internal/alembic/')
Expand All @@ -206,5 +207,5 @@ shutil.copyfile('/app/airunner/src/airunner/alembic.ini', '/app/dist/airunner/_i
shutil.copytree('/app/airunner/src/airunner/data/', '/app/dist/airunner/data/')

# Copy llamaindex nltk cache requirements
shutil.copytree('/app/airunner/lib/corpora', '/app/dist/airunner/_internal/llama_index/core/_static/nltk_cache/corpora')
shutil.copytree('/app/airunner/lib/tokenizers', '/app/dist/airunner/_internal/llama_index/core/_static/nltk_cache/tokenizers')
# shutil.copytree('/app/airunner/lib/corpora', '/app/dist/airunner/_internal/llama_index/core/_static/nltk_cache/corpora')
# shutil.copytree('/app/airunner/lib/tokenizers', '/app/dist/airunner/_internal/llama_index/core/_static/nltk_cache/tokenizers')
6 changes: 3 additions & 3 deletions dobuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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 pip install .")

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="airunner",
version="3.0.16",
version="3.0.17",
author="Capsize LLC",
description="A Stable Diffusion GUI",
long_description=open("README.md", "r", encoding="utf-8").read(),
Expand Down
2 changes: 1 addition & 1 deletion src/airunner/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ level = INFO
handlers =
qualname = alembic

[handler_console]
[handler_console]pyinstaller~/
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
Expand Down
Loading

0 comments on commit ff2bbe9

Please sign in to comment.