forked from Mirrors/flatpak-builder
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.htmltingping/wmclass
parent
daf36ba2af
commit
bc7ebd20e2
|
@ -197,7 +197,9 @@ fixup_python_time_stamp (const char *path,
|
||||||
|
|
||||||
if (lstat (py_path, &stbuf) != 0)
|
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)
|
else if (pyc_mtime == OSTREE_TIMESTAMP)
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,6 +98,7 @@ dist_installed_test_data = \
|
||||||
tests/session.conf.in \
|
tests/session.conf.in \
|
||||||
tests/0001-Add-test-logo.patch \
|
tests/0001-Add-test-logo.patch \
|
||||||
tests/org.test.Python.json \
|
tests/org.test.Python.json \
|
||||||
|
tests/org.test.Python2.json \
|
||||||
tests/importme.py \
|
tests/importme.py \
|
||||||
tests/importme2.py \
|
tests/importme2.py \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
|
@ -215,8 +215,8 @@ setup_sdk_repo () {
|
||||||
|
|
||||||
setup_python2_repo () {
|
setup_python2_repo () {
|
||||||
REPONAME=${1:-test}
|
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.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 readlink make mkdir cp touch > /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
|
update_repo $REPONAME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -25,7 +25,7 @@ skip_without_bwrap
|
||||||
skip_without_user_xattrs
|
skip_without_user_xattrs
|
||||||
skip_without_python2
|
skip_without_python2
|
||||||
|
|
||||||
echo "1..1"
|
echo "1..2"
|
||||||
|
|
||||||
setup_repo
|
setup_repo
|
||||||
install_repo
|
install_repo
|
||||||
|
@ -37,6 +37,7 @@ REPO=`pwd`/repo
|
||||||
cd $TEST_DATA_DIR/
|
cd $TEST_DATA_DIR/
|
||||||
|
|
||||||
cp $(dirname $0)/org.test.Python.json .
|
cp $(dirname $0)/org.test.Python.json .
|
||||||
|
cp $(dirname $0)/org.test.Python2.json .
|
||||||
cp -a $(dirname $0)/empty-configure .
|
cp -a $(dirname $0)/empty-configure .
|
||||||
cp -a $(dirname $0)/testpython.py .
|
cp -a $(dirname $0)/testpython.py .
|
||||||
cp $(dirname $0)/importme.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$
|
assert_file_has_content testpython.out ^modified$
|
||||||
|
|
||||||
echo "ok handled pyc rewriting multiple times"
|
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"
|
||||||
|
|
Loading…
Reference in New Issue