Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor build scripts #962

Merged
merged 14 commits into from
Dec 18, 2023
Merged
Prev Previous commit
Next Next commit
Update release script
  • Loading branch information
VDovidaytis-HORIS committed Dec 6, 2023
commit 06bddc062526b06c5c36daa3c868df9a2e0a3943
15 changes: 14 additions & 1 deletion build_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def build_python_packages(build_command, arch=None):
# Runs Python artifacts build commands. If 'arch' argument was passed, adds it to shell command.
python_extension_build_command = [gradle_script_name, "python-extension:build"]
if arch is not None:
python_extension_build_command += [f"-Pbuild_arch={arch}"]
python_extension_build_command += [f"-Parchitecture={arch}"]
command = build_command + [arch]
else:
command = build_command
Expand All @@ -89,6 +89,17 @@ def build_python_packages(build_command, arch=None):
run_command(command)


def get_python_arch(python_bin_path):
get_python_arch_command = [f"{python_bin_path}/python", "-c", "import platform; print(platform.machine())"]
process = subprocess.check_output(get_python_arch_command, stderr=None)
current_python_arch = process.decode().strip()
if current_python_arch == "arm64" or current_python_arch == "x86_64":
return current_python_arch
else:
print_error_and_exit(f"Got wrong Python architecture for {python_bin_path}!\n"
f"Check your settings file or Python installation.")


# Read Python settings file from script argument.
# Paths to Python binaries and include directories will be got from here:
python_settings = read_settings_file()
Expand Down Expand Up @@ -125,6 +136,7 @@ def build_python_packages(build_command, arch=None):
# Collect all predefined parameters:
build_parameters = [
"-Pbuild_release=true",
"-Parchitecture=%s" % (get_python_arch(python_paths["bin_path"])),
"-Ppython_bin_path=%s" % (python_paths["bin_path"]),
"-Ppython_include_path=%s" % (python_paths["include_path"]),
f"-Penable_python_package={enable_python_package}"
Expand Down Expand Up @@ -158,6 +170,7 @@ def build_python_packages(build_command, arch=None):
# Collect all predefined parameters:
build_parameters = [
"-Pbuild_release=true",
"-Parchitecture=%s" % (get_python_arch(python_paths["bin_path"])),
"-Ppython_bin_path=%s" % (python_paths["bin_path"]),
"-Ppython_include_path=%s" % (python_paths["include_path"]),
f"-Penable_python_package={enable_python_package}"
Expand Down