simplify default arguments in build_prepare

This commit is contained in:
nulano 2020-03-27 22:07:59 +01:00 committed by Andrew Murray
parent 98dd1b7e6e
commit 0e5a6e6eb1

View File

@ -465,8 +465,18 @@ def build_pillow():
if __name__ == "__main__": if __name__ == "__main__":
# winbuild directory
winbuild_dir = os.path.dirname(os.path.realpath(__file__))
verbose = False verbose = False
disabled = [] disabled = []
depends_dir = os.environ.get("PILLOW_DEPS", os.path.join(winbuild_dir, "depends"))
python_dir = os.environ.get("PYTHON")
python_exe = os.environ.get("EXECUTABLE", "python.exe")
architecture = os.environ.get(
"ARCHITECTURE", "x86" if struct.calcsize("P") == 4 else "x64"
)
build_dir = os.environ.get("PILLOW_BUILD", os.path.join(winbuild_dir, "build"))
for arg in sys.argv[1:]: for arg in sys.argv[1:]:
if arg == "-v": if arg == "-v":
verbose = True verbose = True
@ -475,38 +485,27 @@ if __name__ == "__main__":
elif arg == "--no-raqm": elif arg == "--no-raqm":
disabled += ["harfbuzz", "fribidi", "libraqm"] disabled += ["harfbuzz", "fribidi", "libraqm"]
elif arg.startswith("--depends="): elif arg.startswith("--depends="):
os.environ["PILLOW_DEPS"] = arg[10:] depends_dir = arg[10:]
elif arg.startswith("--python="): elif arg.startswith("--python="):
os.environ["PYTHON"] = arg[9:] python_dir = arg[9:]
elif arg.startswith("--executable="): elif arg.startswith("--executable="):
os.environ["EXECUTABLE"] = arg[13:] python_exe = arg[13:]
elif arg.startswith("--architecture="): elif arg.startswith("--architecture="):
os.environ["ARCHITECTURE"] = arg[15:] architecture = arg[15:]
elif arg.startswith("--dir="): elif arg.startswith("--dir="):
os.environ["PILLOW_BUILD"] = arg[6:] build_dir = arg[6:]
else: else:
raise ValueError("Unknown parameter: " + arg) raise ValueError("Unknown parameter: " + arg)
# winbuild directory
winbuild_dir = os.path.dirname(os.path.realpath(__file__))
# dependency cache directory # dependency cache directory
depends_dir = os.environ.get("PILLOW_DEPS", os.path.join(winbuild_dir, "depends"))
os.makedirs(depends_dir, exist_ok=True) os.makedirs(depends_dir, exist_ok=True)
print("Caching dependencies in:", depends_dir) print("Caching dependencies in:", depends_dir)
# Python bin directory
python_dir = os.environ.get("PYTHON")
python_exe = os.environ.get("EXECUTABLE", "python.exe")
if python_dir is None: if python_dir is None:
python_dir = os.path.dirname(os.path.realpath(sys.executable)) python_dir = os.path.dirname(os.path.realpath(sys.executable))
python_exe = os.path.basename(sys.executable) python_exe = os.path.basename(sys.executable)
print("Target Python:", os.path.join(python_dir, python_exe)) print("Target Python:", os.path.join(python_dir, python_exe))
# use ARCHITECTURE or PYTHON to select architecture
architecture = os.environ.get(
"ARCHITECTURE", "x86" if struct.calcsize("P") == 4 else "x64"
)
arch_prefs = architectures[architecture] arch_prefs = architectures[architecture]
print("Target Architecture:", architecture) print("Target Architecture:", architecture)
@ -517,16 +516,12 @@ if __name__ == "__main__":
) )
print("Found Visual Studio at:", msvs["vs_dir"]) print("Found Visual Studio at:", msvs["vs_dir"])
# build root directory
build_dir = os.environ.get("PILLOW_BUILD", os.path.join(winbuild_dir, "build"))
print("Using output directory:", build_dir) print("Using output directory:", build_dir)
# build directory for *.h files # build directory for *.h files
inc_dir = os.path.join(build_dir, "inc") inc_dir = os.path.join(build_dir, "inc")
# build directory for *.lib files # build directory for *.lib files
lib_dir = os.path.join(build_dir, "lib") lib_dir = os.path.join(build_dir, "lib")
# build directory for *.bin files # build directory for *.bin files
bin_dir = os.path.join(build_dir, "bin") bin_dir = os.path.join(build_dir, "bin")