コード例 #1
0
 def get_stdlib():
     # noinspection PyUnresolvedReferences
     paths = [
         sysconfig.get_python_lib(standard_lib=True),
         sysconfig.get_python_lib(standard_lib=True, plat_specific=True),
     ]
     return set(filter(bool, paths))
コード例 #2
0
ファイル: setup.py プロジェクト: xiaoxiangzju/ViZDoom
    def run(self):
        try:
            cpu_cores = max(1, cpu_count() - 1)
            python_executable = os.path.realpath(sys.executable)

            cmake_arg_list = list()
            cmake_arg_list.append("-DCMAKE_BUILD_TYPE=Release")
            cmake_arg_list.append("-DBUILD_PYTHON=ON")
            cmake_arg_list.append("-DPYTHON_EXECUTABLE={}".format(python_executable))

            python_standard_lib = sysconfig.get_python_lib(standard_lib=True)
            python_site_packages = sysconfig.get_python_lib(standard_lib=False)
            python_lib_dir = os.path.dirname(python_standard_lib)
            python_library = get_python_library(python_lib_dir)
            python_include_dir = sysconfig.get_python_inc()
            numpy_include_dir = os.path.join(python_site_packages, "numpy/core/include")

            if os.path.exists(python_library) and os.path.exists(python_include_dir) and os.path.exists(numpy_include_dir):
                cmake_arg_list.append("-DPYTHON_LIBRARY={}".format(python_library))
                cmake_arg_list.append("-DPYTHON_INCLUDE_DIR={}".format(python_include_dir))
                cmake_arg_list.append("-DNUMPY_INCLUDES={}".format(numpy_include_dir))

            if python_version[0] == "3":
                cmake_arg_list.append("-DBUILD_PYTHON3=ON")

            subprocess.check_call(['rm', '-f', 'CMakeCache.txt'])
            subprocess.check_call(['cmake'] + cmake_arg_list)
            subprocess.check_call(['make', '-j', str(cpu_cores)])
        except subprocess.CalledProcessError:
            sys.stderr.write("\033[1m\nInstallation failed, you may be missing some dependencies. "
                             "\nPlease check https://github.com/mwydmuch/ViZDoom/blob/master/doc/Building.md "
                             "for details\n\n\033[0m")
            raise
        build.run(self)
コード例 #3
0
def get_report():

    report = {}

    # Get Python implementation
    report['python_implementation'] = platform.python_implementation()
    report['python_version'] = platform.python_version()

    # Get prefixes from sys
    report['sys'] = {
        'prefix': getattr(sys, 'prefix', None),
        'real_prefix': getattr(sys, 'real_prefix', None),
        'base_prefix': getattr(sys, 'base_prefix', None)
    }

    # Get paths from sysconfig
    if hasattr(sysconfig, 'get_paths'):
        report['sysconfig'] = sysconfig.get_paths()
    else:
        paths = {
            'stdlib':
            sysconfig.get_python_lib(standard_lib=True),
            'platstdlib':
            sysconfig.get_python_lib(standard_lib=True, plat_specific=True),
            'purelib':
            sysconfig.get_python_lib(),
            'platlib':
            sysconfig.get_python_lib(plat_specific=True),
            'include':
            sysconfig.get_python_inc(),
            'platinclude':
            sysconfig.get_python_inc(plat_specific=True)
        }

        report['sysconfig'] = paths

    # Get site module directory
    report['site_mod_dir'] = os.path.dirname(os.path.abspath(site.__file__))

    # Get user site-packages directory
    try:
        # Use getusersitepackages if this is present
        # as it ensures that the value is initialized properly.
        report['user_site'] = site.getusersitepackages()
    except AttributeError:
        report['user_site'] = site.USER_SITE

    return report
コード例 #4
0
    def __init__(self):
        """ Initialise the configuration. """

        if hasattr(sysconfig, 'get_path'):
            # The modern API.
            self.module_dir = sysconfig.get_path('platlib')
        else:
            # The legacy distutils API.
            self.module_dir = sysconfig.get_python_lib(plat_specific=1)

        if sys.platform == 'win32':
            self.data_dir = sys.prefix
        else:
            self.data_dir = sys.prefix + '/share'
コード例 #5
0
ファイル: configure.py プロジェクト: wildone/robomongo
    def __init__(self):
        """ Initialise the configuration. """

        self.platform = sys.platform
        self.version = sys.hexversion >> 8

        if hasattr(sysconfig, 'get_path'):
            # The modern API.
            self.inc_dir = sysconfig.get_path('include')
            self.module_dir = sysconfig.get_path('platlib')
        else:
            # The legacy distutils API.
            self.inc_dir = sysconfig.get_python_inc(plat_specific=1)
            self.module_dir = sysconfig.get_python_lib(plat_specific=1)

        if sys.platform == 'win32':
            self.data_dir = sys.prefix
            self.lib_dir = sys.prefix + '\\libs'
        else:
            self.data_dir = sys.prefix + '/share'
            self.lib_dir = sys.prefix + '/lib'
コード例 #6
0
    def __init__(self):
        """ Initialise the configuration. """

        self.platform = sys.platform
        self.version = sys.hexversion >> 8

        if hasattr(sysconfig, 'get_path'):
            # The modern API.
            self.inc_dir = sysconfig.get_path('include')
            self.module_dir = sysconfig.get_path('platlib')
        else:
            # The legacy distutils API.
            self.inc_dir = sysconfig.get_python_inc(plat_specific=1)
            self.module_dir = sysconfig.get_python_lib(plat_specific=1)

        if sys.platform == 'win32':
            self.data_dir = sys.prefix
            self.lib_dir = sys.prefix + '\\libs'
        else:
            self.data_dir = sys.prefix + '/share'
            self.lib_dir = sys.prefix + '/lib'
コード例 #7
0
ファイル: configure.py プロジェクト: 6qat/robomongo
    def __init__(self):
        """ Initialise the configuration. """

        self.platform = sys.platform
        self.version = sys.hexversion >> 8

        if hasattr(sysconfig, "get_path"):
            # The modern API.
            self.inc_dir = sysconfig.get_path("include")
            self.module_dir = sysconfig.get_path("platlib")
        else:
            # The legacy distutils API.
            self.inc_dir = sysconfig.get_python_inc(plat_specific=1)
            self.module_dir = sysconfig.get_python_lib(plat_specific=1)

        if sys.platform == "win32":
            self.data_dir = sys.prefix
            self.lib_dir = sys.prefix + "\\libs"
        else:
            self.data_dir = sys.prefix + "/share"
            self.lib_dir = sys.prefix + "/lib"
コード例 #8
0
ファイル: __init__.py プロジェクト: ARSLAN79/pythonWork
 def get_stdlib():
     paths = [
         sysconfig.get_python_lib(standard_lib=True),
         sysconfig.get_python_lib(standard_lib=True, plat_specific=True),
     ]
     return set(filter(bool, paths))
コード例 #9
0
 def get_stdlib():
     paths = [
         sysconfig.get_python_lib(standard_lib=True),
         sysconfig.get_python_lib(standard_lib=True, plat_specific=True),
     ]
     return set(filter(bool, paths))
コード例 #10
0
ファイル: test_debian.py プロジェクト: jdsieci/salt
def system_aptsources(request, grains):
    sys_modules = list(sys.modules)
    copied_paths = []
    exc_kwargs = {}
    if PYTEST_GE_7:
        exc_kwargs["_use_item_location"] = True
    if grains["os_family"] != "Debian":
        raise pytest.skip.Exception("Test only for debian based platforms",
                                    **exc_kwargs)
    try:
        try:
            from aptsources import sourceslist  # pylint: disable=unused-import

            if request.param == "without":
                raise pytest.skip.Exception(
                    "This test is meant to run without the system aptsources package, but it's "
                    "available from '{}'.".format(sourceslist.__file__),
                    **exc_kwargs)
            else:
                # Run the test
                yield request.param
        except ImportError:
            if request.param == "without":
                # Run the test
                yield
            else:
                copied_paths = []
                py_version_keys = [
                    "{}".format(*sys.version_info),
                    "{}.{}".format(*sys.version_info),
                ]
                session_site_packages_dir = get_python_lib()
                session_site_packages_dir = os.path.relpath(
                    session_site_packages_dir, str(CODE_DIR))
                for py_version in py_version_keys:
                    dist_packages_path = "/usr/lib/python{}/dist-packages".format(
                        py_version)
                    if not os.path.isdir(dist_packages_path):
                        continue
                    for aptpkg in glob.glob(
                            os.path.join(dist_packages_path, "*apt*")):
                        src = os.path.realpath(aptpkg)
                        dst = os.path.join(session_site_packages_dir,
                                           os.path.basename(src))
                        if os.path.exists(dst):
                            log.info(
                                "Not overwritting already existing %s with %s",
                                dst, src)
                            continue
                        log.info("Copying %s into %s", src, dst)
                        copied_paths.append(dst)
                        if os.path.isdir(src):
                            shutil.copytree(src, dst)
                        else:
                            shutil.copyfile(src, dst)
                if not copied_paths:
                    raise pytest.skip.Exception(
                        "aptsources.sourceslist python module not found",
                        **exc_kwargs)
                # Run the test
                yield request.param
    finally:
        for path in copied_paths:
            log.info("Deleting %r", path)
            if os.path.isdir(path):
                shutil.rmtree(path, ignore_errors=True)
            else:
                os.unlink(path)
        for name in list(sys.modules):
            if name in sys_modules:
                continue
            if "apt" not in name:
                continue
            log.debug("Removing '%s' from 'sys.modules'", name)
            sys.modules.pop(name)
コード例 #11
0
ファイル: ignore.py プロジェクト: pwwang/python-varname
import inspect
import warnings
from os import path
from pathlib import Path
from fnmatch import fnmatch
from abc import ABC, abstractmethod
from typing import List, Union
from types import FrameType, ModuleType, FunctionType

from executing import Source

try:
    import sysconfig  # 3.10+
except ImportError:  # pragma: no cover
    from distutils import sysconfig
    STANDLIB_PATH = sysconfig.get_python_lib(standard_lib=True)
else:
    STANDLIB_PATH = sysconfig.get_path('stdlib')

from .utils import (
    IgnoreElemType,
    IgnoreType,
    MaybeDecoratedFunctionWarning,
    cached_getmodule,
    attach_ignore_id_to_module,
    frame_matches_module_by_ignore_id,
    check_qualname_by_source,
    debug_ignore_frame,
)