Files
codeql-action/python-setup/tests/from_python_exe.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1.1 KiB
Python
Raw Normal View History

2020-09-29 09:57:29 +02:00
#!/usr/bin/env python3
import sys
2020-10-08 16:12:40 +02:00
import os
2020-09-29 09:57:29 +02:00
import subprocess
from typing import Tuple
def get_details(path_to_python_exe: str) -> Tuple[str, str]:
import_path = subprocess.check_output(
[
path_to_python_exe,
2022-12-12 18:00:32 +01:00
os.path.join(os.path.dirname(__file__), "..", "find_site_packages.py")
2020-09-29 09:57:29 +02:00
],
stdin=subprocess.DEVNULL,
)
version = subprocess.check_output(
[path_to_python_exe, "-c", "import sys; print(sys.version_info[0])"],
stdin=subprocess.DEVNULL,
)
return version.decode("utf-8").strip(), import_path.decode("utf-8").strip()
if __name__ == "__main__":
version, import_path = get_details(sys.argv[1])
2020-10-08 16:12:40 +02:00
# see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
env_file = open(os.environ["GITHUB_ENV"], mode="at")
2020-09-29 09:57:29 +02:00
print("Setting LGTM_PYTHON_SETUP_VERSION={}".format(version))
2020-10-08 16:12:40 +02:00
print("LGTM_PYTHON_SETUP_VERSION={}".format(version), file=env_file)
2020-09-29 09:57:29 +02:00
print("Setting LGTM_INDEX_IMPORT_PATH={}".format(import_path))
2020-10-08 16:12:40 +02:00
print("LGTM_INDEX_IMPORT_PATH={}".format(import_path), file=env_file)