Staging
v0.8.1
Revision d01ae1b22330992eadc7b2a0842ead544f7e507d authored by Miss Islington (bot) on 03 February 2020, 17:17:17 UTC, committed by GitHub on 03 February 2020, 17:17:17 UTC
(cherry picked from commit 5807efd4c396d5718325e21f5a14e324a77ff77c)

Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent db2f311
Raw File
exe_with_zip
#!/bin/bash
INTERPRETER_UNDER_TEST="$1"
if [[ ! -x "${INTERPRETER_UNDER_TEST}" ]]; then
    echo "Interpreter must be the command line argument."
    exit 4
fi
EXECUTABLE="$0" exec "${INTERPRETER_UNDER_TEST}" -E - <<END_OF_PYTHON
import os
import zipfile

namespace = {}

filename = os.environ['EXECUTABLE']
print(f'Opening {filename} as a zipfile.')
with zipfile.ZipFile(filename, mode='r') as exe_zip:
  for file_info in exe_zip.infolist():
    data = exe_zip.read(file_info)
    exec(data, namespace, namespace)
    break  # Only use the first file in the archive.

print('Favorite number in executable:', namespace["FAVORITE_NUMBER"])

### Archive contents will be appended after this file. ###
END_OF_PYTHON
PK
\*OI_?SEEtestdata_module_inside_zip.pyUT	�{w]��w]ux��# Test data file to be stored within a zip file.
FAVORITE_NUMBER = 5
PK
\*OI_?SEE��testdata_module_inside_zip.pyUT�{w]ux��PKc�
back to top