Fix o3de CLI install on read-only /app via prebuilt sdist
The real first-launch installer is python/get_python.sh, not LYPython.cmake. It does `pip install -e scripts/o3de`, whose egg_info write hits read-only /app and fails ([Errno 30]). get_python.sh has a built-in immutable-install hook: if scripts/o3de/dist/o3de-1.0.0.tar.gz exists it installs that (non-editable) instead. Pre-build that tarball at Flatpak build time (python3 setup.py sdist) so the runtime CLI lands in the writable ~/.o3de venv. Verified end-to-end: tarball install -> `import o3de` resolves from site-packages. Also patch every LYPython.cmake copy (not just the first) for the separate project-build CMake-configure path, and add python3/python3-setuptools to CI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+30
-12
@@ -29,21 +29,39 @@ tar -C data -xf data.tar.*
|
||||
mkdir -p "$DEST/opt"
|
||||
cp -a data/opt/. "$DEST/opt/"
|
||||
|
||||
echo ">> patching the editable pip install (read-only /app workaround)"
|
||||
# On first launch O3DE sets up a per-user Python venv in ~/.o3de and pip-installs
|
||||
# its 'o3de' CLI with 'pip install -e' (editable). Editable mode writes an
|
||||
# egg-info next to the source under /app, which is read-only in a Flatpak, so it
|
||||
# fails. Force a normal (non-editable) install instead: pip builds in a temp dir
|
||||
# and installs into the writable ~/.o3de venv. (Nothing Python-related needs to
|
||||
# be baked into the image; it all lives per-user under ~/.o3de.)
|
||||
LYPYTHON=$(find "$DEST/opt/O3DE" -path '*/cmake/LYPython.cmake' | head -n1)
|
||||
if [ -n "$LYPYTHON" ] && grep -qF -- '-m pip install -e ' "$LYPYTHON"; then
|
||||
sed -i 's/-m pip install -e /-m pip install /g' "$LYPYTHON"
|
||||
echo " patched: $LYPYTHON"
|
||||
echo ">> pre-building the o3de sdist (read-only /app workaround)"
|
||||
# On first launch O3DE builds a per-user Python venv in ~/.o3de and installs its
|
||||
# 'o3de' CLI from <engine>/scripts/o3de. By default python/get_python.sh does an
|
||||
# *editable* install ('pip install -e'), which writes an egg-info next to the
|
||||
# source under read-only /app and fails. get_python.sh has a built-in escape hatch
|
||||
# for immutable installs (the Snap path): if a prebuilt sdist exists at
|
||||
# scripts/o3de/dist/o3de-1.0.0.tar.gz it installs THAT (non-editable) instead. So
|
||||
# we build that tarball here, while the tree is still writable. At runtime the
|
||||
# tarball is copied into the writable ~/.o3de venv - nothing is written to /app.
|
||||
O3DE_PKG=$(find "$DEST/opt/O3DE" -maxdepth 3 -type d -path '*/scripts/o3de' | head -n1)
|
||||
if [ -n "$O3DE_PKG" ] && [ -f "$O3DE_PKG/setup.py" ]; then
|
||||
( cd "$O3DE_PKG" && python3 setup.py sdist )
|
||||
if [ -f "$O3DE_PKG/dist/o3de-1.0.0.tar.gz" ]; then
|
||||
echo " built: $O3DE_PKG/dist/o3de-1.0.0.tar.gz"
|
||||
else
|
||||
echo " ERROR: sdist did not produce o3de-1.0.0.tar.gz" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo " WARNING: 'pip install -e' not found in LYPython.cmake; O3DE layout may have changed" >&2
|
||||
echo " ERROR: scripts/o3de/setup.py not found; O3DE layout may have changed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Belt-and-suspenders for the project-build path: LYPython.cmake also installs the
|
||||
# o3de package (editable) during a CMake configure when you build a project. Patch
|
||||
# every copy to a non-editable install so that write doesn't hit read-only /app.
|
||||
find "$DEST/opt/O3DE" -path '*/cmake/LYPython.cmake' | while read -r LYPYTHON; do
|
||||
if grep -qF -- '-m pip install -e ' "$LYPYTHON"; then
|
||||
sed -i 's/-m pip install -e /-m pip install /g' "$LYPYTHON"
|
||||
echo " patched: $LYPYTHON"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ">> installing launcher + metadata"
|
||||
install -Dm755 o3de-wrapper.sh "$DEST/bin/o3de-wrapper.sh"
|
||||
install -Dm644 org.o3de.O3DE.desktop "$DEST/share/applications/$APP_ID.desktop"
|
||||
|
||||
Reference in New Issue
Block a user