File: build_executable

package info (click to toggle)
openvpn3-indicator 0.0~git20260107.d464ef5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,588 kB
  • sloc: python: 2,114; makefile: 127; xml: 42
file content (26 lines) | stat: -rwxr-xr-x 669 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3

import argparse
import pathlib
import subprocess

parser = argparse.ArgumentParser()
parser.add_argument('--directory', required=True)
parser.add_argument('--executable', required=True)
parser.add_argument('--python', default='/usr/bin/env python3')

args = parser.parse_args()
directory = pathlib.Path(args.directory)
executable = pathlib.Path(args.executable)

assert directory.is_dir()

header = f'#!{args.python}\n'.encode()

binary = subprocess.run(
            ['zip', '-', '--recurse-paths', '-9', '.', ],
            cwd=directory, stdout=subprocess.PIPE
        ).stdout

executable.write_bytes(header + binary)
executable.chmod(0o755)