How to use the crossenv.scripts.site.BuildPathFinder function in crossenv

To help you get started, we’ve selected a few crossenv 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 benfogle / crossenv / crossenv / scripts / site.py View on Github external
for i, p in enumerate(sys.path):
                if p.startswith(stdlib):
                    path.extend(sys.build_path)
                    path.extend(sys.path[i:])
                    break
                else:
                    path.append(p)
        return super().find_spec(fullname, path, target)

# Insert just before the regular sys.path handler
for i, meta in enumerate(sys.meta_path):
    if meta is importlib.machinery.PathFinder:
        sys.meta_path[i] = BuildPathFinder
        break
else:
    sys.meta_path.append(BuildPathFinder) #???

# Remove this directory. It's not needed after startup.
# The one after will be one of ours too.
cross_dir = os.path.dirname(__file__)
for index, p in enumerate(sys.path):
    if os.path.exists(p) and os.path.samefile(p, cross_dir):
        del sys.path[index:index+2]
        break

# Fixup sys:
# sysconfig should be correct, but some little parts of
# sys are hardcoded (but changable)
multiarch = sysconfig.get_config_var('MULTIARCH')
if multiarch is None:
    try:
        del sys.implementation._multiarch
github benfogle / crossenv / crossenv / scripts / site.py View on Github external
# Need to do this every time in case sys.path changes.
            # We insert build paths just before the host stdlibs
            path = []
            for i, p in enumerate(sys.path):
                if p.startswith(stdlib):
                    path.extend(sys.build_path)
                    path.extend(sys.path[i:])
                    break
                else:
                    path.append(p)
        return super().find_spec(fullname, path, target)

# Insert just before the regular sys.path handler
for i, meta in enumerate(sys.meta_path):
    if meta is importlib.machinery.PathFinder:
        sys.meta_path[i] = BuildPathFinder
        break
else:
    sys.meta_path.append(BuildPathFinder) #???

# Remove this directory. It's not needed after startup.
# The one after will be one of ours too.
cross_dir = os.path.dirname(__file__)
for index, p in enumerate(sys.path):
    if os.path.exists(p) and os.path.samefile(p, cross_dir):
        del sys.path[index:index+2]
        break

# Fixup sys:
# sysconfig should be correct, but some little parts of
# sys are hardcoded (but changable)
multiarch = sysconfig.get_config_var('MULTIARCH')