Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/api/python/ge/ge/_capi/pypyatc_wrapper.py: 100%
13 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-27 10:02 +0800
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-27 10:02 +0800
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# -----------------------------------------------------------------------------------------------------------
4# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6# CANN Open Software License Agreement Version 2.0 (the "License").
7# Please refer to the License for details. You may not use this file except in compliance with the License.
8# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10# See LICENSE in the root of the software repository for the full text of the License.
11# -----------------------------------------------------------------------------------------------------------
13import ctypes
14import os
16from ._lib_loader import load_lib_from_path
18LIB_NAME = "libpyatc_wrapper.so"
19_dir = os.path.dirname(os.path.abspath(__file__))
21# 优先使用 GLOBAL|NOW,确保符号可见并尽早完成重定位
22_dlopen_mode = getattr(os, "RTLD_GLOBAL", 0) | getattr(os, "RTLD_NOW", 0)
23pyatc_lib = load_lib_from_path(LIB_NAME, _dir, mode=_dlopen_mode)
25pyatc_lib.GeApiWrapper_Atc_Main.argtypes = [
26 ctypes.c_int,
27 ctypes.POINTER(ctypes.c_char_p),
28]
29pyatc_lib.GeApiWrapper_Atc_Main.restype = ctypes.c_int
32def get_pyatc_lib():
33 """Get the pyatc wrapper library handle.
35 Returns:
36 ctypes.CDLL: The loaded libpyatc_wrapper.so library handle.
37 """
38 return pyatc_lib
41def is_pyatc_lib_loaded():
42 """Check if pyatc library is loaded.
44 Returns:
45 bool: True if library is loaded successfully.
46 """
47 return pyatc_lib is not None