How to use the cppimport.config.quiet_print function in cppimport

To help you get started, we’ve selected a few cppimport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tbenthompson / cppimport / cppimport / importer.py View on Github external
import os
import sys
import sysconfig
import importlib

import cppimport.config
import cppimport.checksum
import cppimport.find

quiet_print = cppimport.config.quiet_print

def get_module_name(full_module_name):
    return full_module_name.split('.')[-1]

def get_extension_suffix():
    ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
    if ext_suffix is None:
        ext_suffix = sysconfig.get_config_var('SO')
    return ext_suffix

def setup_module_data(fullname, filepath):
    module_data = dict()
    module_data['fullname'] = fullname
    module_data['filepath'] = filepath
    module_data['filedirname'] = os.path.dirname(module_data['filepath'])
    module_data['filebasename'] = os.path.basename(module_data['filepath'])
github tbenthompson / cppimport / cppimport / checksum.py View on Github external
def is_checksum_current(module_data):
    try:
        checksum_filepath = get_checksum_filepath(module_data['filepath'])

        if not os.path.exists(checksum_filepath):
            return False

        try:
            with open(checksum_filepath, 'rb') as f:
                deps, old_checksum = pickle.load(f)
        except (ValueError, pickle.UnpicklingError) as e:
            cppimport.config.quiet_print(
                "Failed to load checksum due to exception" + traceback.format_exc()
            )
            return False

        cur_checksum = calc_cur_checksum(deps, module_data)
        if old_checksum != cur_checksum:
            return False
        return True
    except FileNotFoundError as e:
        print(e)
        print("Checksummed file not found while checking cppimport checksum. Rebuilding.")
        return False