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:
2026-06-16 02:41:20 +02:00
parent 8e3fd053d8
commit 3146cab449
4 changed files with 64 additions and 27 deletions
+18 -7
View File
@@ -37,17 +37,28 @@ modules:
# is kept for robustness in case a future release adds desktop glue there.)
- 'if [ -d data/opt ]; then mkdir -p "${FLATPAK_DEST}/opt"; cp -a data/opt/. "${FLATPAK_DEST}/opt/"; fi'
- 'if [ -d data/usr ]; then cp -a data/usr/. "${FLATPAK_DEST}/"; fi'
# On first launch O3DE pip-installs its 'o3de' CLI editable ('pip install
# -e'), which writes an egg-info into read-only /app and fails. Force a
# normal install (built in a temp dir, lands in the writable ~/.o3de venv).
# On first launch O3DE installs its 'o3de' CLI from scripts/o3de. By default
# python/get_python.sh does an *editable* install ('pip install -e'), which
# writes an egg-info into read-only /app and fails. get_python.sh has a
# built-in immutable-install hook (the Snap path): if a prebuilt sdist exists
# at scripts/o3de/dist/o3de-1.0.0.tar.gz it installs that (non-editable)
# instead. Build the tarball now, while /app is still writable.
- |
set -e
LYPYTHON=$(find "${FLATPAK_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"
O3DE_PKG=$(find "${FLATPAK_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 )
test -f "$O3DE_PKG/dist/o3de-1.0.0.tar.gz"
else
echo "::warning:: 'pip install -e' not found in LYPython.cmake"
echo "scripts/o3de/setup.py not found; O3DE layout may have changed" >&2
exit 1
fi
# Belt-and-suspenders: LYPython.cmake also installs o3de (editable) during a
# project-build CMake configure. Patch every copy to non-editable.
find "${FLATPAK_DEST}/opt/O3DE" -path '*/cmake/LYPython.cmake' | while read -r LYPYTHON; do
grep -qF -- '-m pip install -e ' "$LYPYTHON" && \
sed -i 's/-m pip install -e /-m pip install /g' "$LYPYTHON" || true
done
# Launcher + AppStream + desktop entry under the Flatpak app-id.
- install -Dm755 o3de-wrapper.sh "${FLATPAK_DEST}/bin/o3de-wrapper.sh"
- install -Dm644 org.o3de.O3DE.desktop "${FLATPAK_DEST}/share/applications/org.o3de.O3DE.desktop"