MCPcopy Index your code
hub / github.com/PaddlePaddle/FastDeploy / get_version_info

Function get_version_info

fastdeploy/utils.py:913–956  ·  view source on GitHub ↗

Read version.txt file and parse version information, returning as a dict structure. Returns: dict: A dictionary containing version information, or None if the file does not exist The dictionary contains the following keys: - 'fastdeploy_commit': FastDeploy GIT COMMI

()

Source from the content-addressed store, hash-verified

911
912
913def get_version_info():
914 """
915 Read version.txt file and parse version information, returning as a dict structure.
916
917 Returns:
918 dict: A dictionary containing version information, or None if the file does not exist
919 The dictionary contains the following keys:
920 - 'fastdeploy_commit': FastDeploy GIT COMMIT ID
921 - 'paddle_version': Paddle version
922 - 'paddle_commit': Paddle GIT COMMIT ID
923 - 'cuda_version': CUDA version
924 - 'cxx_version': CXX compiler version
925 - 'fastdeploy_version': fastdeploy version
926 """
927 current_dir = os.path.dirname(os.path.abspath(__file__))
928 version_file_path = os.path.join(current_dir, "version.txt")
929
930 try:
931 with open(version_file_path, "r") as f:
932 content = f.read()
933 except FileNotFoundError:
934 return None
935
936 version_info = {}
937 try:
938 lines = content.strip().split("\n")
939 for line in lines:
940 if line.startswith("fastdeploy GIT COMMIT ID:"):
941 version_info["fastdeploy_commit"] = line.split("fastdeploy GIT COMMIT ID:")[1].strip()
942 elif line.startswith("Paddle version:"):
943 version_info["paddle_version"] = line.split("Paddle version:")[1].strip()
944 elif line.startswith("Paddle GIT COMMIT ID:"):
945 version_info["paddle_commit"] = line.split("Paddle GIT COMMIT ID:")[1].strip()
946 elif line.startswith("CUDA version:"):
947 version_info["cuda_version"] = line.split("CUDA version:")[1].strip()
948 elif line.startswith("CXX compiler version:"):
949 version_info["cxx_version"] = line.split("CXX compiler version:")[1].strip()
950 elif line.startswith("fastdeploy version:"):
951 version_info["fastdeploy_version"] = line.split("fastdeploy version:")[1].strip()
952 except Exception as e:
953 console_logger.error(f"Failed to parse version info from version.txt: {e}")
954 return None
955
956 return version_info if version_info else None
957
958
959def current_package_version():

Calls 4

joinMethod · 0.80
splitMethod · 0.80
readMethod · 0.45
errorMethod · 0.45