-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild-portable-commands.py
46 lines (36 loc) · 1.31 KB
/
build-portable-commands.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import argparse
import datetime
import io
import os
import time
import yaml
from pathlib import Path
from textwrap import dedent
from freezegun import freeze_time
# https://github.com/takluyver/pynsist/blob/2.8/nsist/commands.py
from nsist.commands import prepare_bin_directory
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--config", type=Path, default=Path(__file__).parent / "portable.yml")
parser.add_argument("--target", type=Path, required=True)
parser.add_argument("--prepend-ffmpeg", action="store_true", default=False)
return parser.parse_args()
if __name__ == "__main__":
args = get_args()
with open(args.config, "r") as fp:
data = yaml.load(fp, yaml.Loader)
extra_preamble = io.StringIO()
if args.prepend_ffmpeg:
extra_preamble.write(dedent("""
sys.argv.insert(1, f"--ffmpeg-ffmpeg={installdir}\\\\ffmpeg\\\\ffmpeg.exe")
"""))
commands = data.get("commands")
for command in commands.values():
command.update(extra_preamble=extra_preamble)
timestamp = int(os.getenv("SOURCE_DATE_EPOCH", time.time()))
with freeze_time(datetime.datetime.fromtimestamp(timestamp, tz=datetime.timezone.utc)):
prepare_bin_directory(
args.target,
commands,
bitness=64,
)