• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2INTERPRETER_UNDER_TEST="$1"
3if [[ ! -x "${INTERPRETER_UNDER_TEST}" ]]; then
4    echo "Interpreter must be the command line argument."
5    exit 4
6fi
7EXECUTABLE="$0" exec "${INTERPRETER_UNDER_TEST}" -E - <<END_OF_PYTHON
8import os
9import zipfile
10
11namespace = {}
12
13filename = os.environ['EXECUTABLE']
14print(f'Opening {filename} as a zipfile.')
15with zipfile.ZipFile(filename, mode='r') as exe_zip:
16  for file_info in exe_zip.infolist():
17    data = exe_zip.read(file_info)
18    exec(data, namespace, namespace)
19    break  # Only use the first file in the archive.
20
21print('Favorite number in executable:', namespace["FAVORITE_NUMBER"])
22
23### Archive contents will be appended after this file. ###
24END_OF_PYTHON
25PK
26�����\*OI_?SE���E�����testdata_module_inside_zip.pyUT	��{w]��w]ux�������# Test data file to be stored within a zip file.
27FAVORITE_NUMBER = 5
28PK
29�����\*OI_?SE���E�������������������testdata_module_inside_zip.pyUT��{w]ux�������PK������c���������