builder: Allow .pyc files without .py

This is common for binary-only releases, for example as described
in:
https://lists.freedesktop.org/archives/flatpak/2017-June/000697.html
tingping/wmclass
Alexander Larsson 2017-06-13 11:17:06 +02:00
parent daf36ba2af
commit bc7ebd20e2
5 changed files with 56 additions and 4 deletions

View File

@ -197,7 +197,9 @@ fixup_python_time_stamp (const char *path,
if (lstat (py_path, &stbuf) != 0)
{
remove_pyc = TRUE;
/* pyc file without .py file, this happens for binary-only deployments.
* Accept it as-is. */
return TRUE;
}
else if (pyc_mtime == OSTREE_TIMESTAMP)
{

View File

@ -98,6 +98,7 @@ dist_installed_test_data = \
tests/session.conf.in \
tests/0001-Add-test-logo.patch \
tests/org.test.Python.json \
tests/org.test.Python2.json \
tests/importme.py \
tests/importme2.py \
$(NULL)

View File

@ -215,8 +215,8 @@ setup_sdk_repo () {
setup_python2_repo () {
REPONAME=${1:-test}
GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonPlatform bash python2 ls cat echo readlink > /dev/null
GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonSdk python2 bash ls cat echo readlink make mkdir cp touch > /dev/null
GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonPlatform bash python2 ls cat echo rm readlink > /dev/null
GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonSdk python2 bash ls cat echo rm readlink make mkdir cp touch > /dev/null
update_repo $REPONAME
}

View File

@ -0,0 +1,37 @@
{
"app-id": "org.test.Python2",
"runtime": "org.test.PythonPlatform",
"sdk": "org.test.PythonSdk",
"command": "testpython.py",
"modules": [
{
"name": "compiled-python",
"post-install": [
"mkdir /app/bin",
"cp testpython.py /app/bin",
"cp importme.py /app/bin",
/* Compile importme.py */
"/app/bin/testpython.py",
/* Remove .py file, but keep .pyc */
"rm /app/bin/importme.py",
/* Make sure it still works */
"/app/bin/testpython.py"
],
"sources": [
{
"type": "file",
"path": "empty-configure",
"dest-filename": "configure"
},
{
"type": "file",
"path": "testpython.py"
},
{
"type": "file",
"path": "importme.py"
}
]
}
]
}

View File

@ -25,7 +25,7 @@ skip_without_bwrap
skip_without_user_xattrs
skip_without_python2
echo "1..1"
echo "1..2"
setup_repo
install_repo
@ -37,6 +37,7 @@ REPO=`pwd`/repo
cd $TEST_DATA_DIR/
cp $(dirname $0)/org.test.Python.json .
cp $(dirname $0)/org.test.Python2.json .
cp -a $(dirname $0)/empty-configure .
cp -a $(dirname $0)/testpython.py .
cp $(dirname $0)/importme.py .
@ -51,3 +52,14 @@ flatpak-builder --run appdir org.test.Python.json testpython.py > testpython.out
assert_file_has_content testpython.out ^modified$
echo "ok handled pyc rewriting multiple times"
flatpak-builder --force-clean appdir org.test.Python2.json
assert_not_has_file appdir/files/bin/importme.py
assert_has_file appdir/files/bin/importme.pyc
flatpak-builder --run appdir org.test.Python2.json testpython.py > testpython.out
assert_file_has_content testpython.out "^first $"
echo "ok handled .pyc without .py"