diff options
author | Mike Crute <mike@crute.us> | 2020-05-29 20:38:41 -0700 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2020-05-29 20:58:11 -0700 |
commit | 5b2f32c9c854ab30178cb78bc2272f2c71d0a60e (patch) | |
tree | accc1914d436e669f1bfe9e2b5d8a2acdf13a8e6 | |
parent | 41f127d77b8d386244bf5f617711ed884df5df4f (diff) | |
download | alpine-ec2-ami-5b2f32c9c854ab30178cb78bc2272f2c71d0a60e.tar.bz2 alpine-ec2-ami-5b2f32c9c854ab30178cb78bc2272f2c71d0a60e.tar.xz alpine-ec2-ami-5b2f32c9c854ab30178cb78bc2272f2c71d0a60e.zip |
Allow builder to be run by itself
-rwxr-xr-x[-rw-r--r--] | scripts/builder.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/builder.py b/scripts/builder.py index de95bdb..7491e25 100644..100755 --- a/scripts/builder.py +++ b/scripts/builder.py | |||
@@ -1,3 +1,34 @@ | |||
1 | #!/usr/bin/env python3.8 | ||
2 | |||
3 | # This bit has to stay at the very top of the script. It exists to ensure that | ||
4 | # running this script all by itself uses the python virtual environment with | ||
5 | # our dependencies installed. If will create that environment if it doesn't | ||
6 | # exist. | ||
7 | import os | ||
8 | import sys | ||
9 | import subprocess | ||
10 | |||
11 | args = [os.path.join("build", "bin", "python3.8")] + sys.argv | ||
12 | |||
13 | # Create the build root if it doesn't exist | ||
14 | if not os.path.exists("build"): | ||
15 | import venv | ||
16 | |||
17 | print("Build environment does not exist, creating...", file=sys.stderr) | ||
18 | venv.create("build", with_pip=True) | ||
19 | subprocess.run(["build/bin/pip", "install", "-U", "pip", | ||
20 | "pyhocon", "boto3", "PyYAML"]) | ||
21 | |||
22 | print("Re-executing with builder python...", file=sys.stderr) | ||
23 | os.execv(args[0], args) | ||
24 | else: | ||
25 | # If the build root python is not running this script re-execute it with | ||
26 | # that python instead to ensure all of our dependencies exist. | ||
27 | if os.path.join(os.getcwd(), args[0]) != sys.executable: | ||
28 | print("Re-executing with builder python...", file=sys.stderr) | ||
29 | os.execv(args[0], args) | ||
30 | |||
31 | # Below here is the real script | ||
1 | import io | 32 | import io |
2 | import os | 33 | import os |
3 | import re | 34 | import re |