def remove_easy_install_pth(preserve_egg_dir=False): """ remove the need for easy-install.pth and finally remove easy-install.pth itself """ sp_dir = environ.get_sp_dir() for egg_path in glob(join(sp_dir, '*-py*.egg')): if isdir(egg_path): if preserve_egg_dir: write_pth(egg_path) continue print('found egg dir:', egg_path) try: os.rename(join(egg_path, 'EGG-INFO/PKG-INFO'), egg_path + '-info') except OSError: pass utils.rm_rf(join(egg_path, 'EGG-INFO')) for fn in os.listdir(egg_path): if fn == '__pycache__': utils.rm_rf(join(egg_path, fn)) else: os.rename(join(egg_path, fn), join(sp_dir, fn)) elif isfile(egg_path): print('found egg:', egg_path) write_pth(egg_path) utils.rm_rf(join(sp_dir, 'easy-install.pth'))
def compile_missing_pyc(): sp_dir = environ.get_sp_dir() need_compile = False for root, dirs, files in os.walk(sp_dir): for fn in files: if fn.endswith('.py') and fn + 'c' not in files: need_compile = True if need_compile: print('compiling .pyc files...') utils._check_call([build_python, '-Wi', join(environ.STDLIB_DIR, 'compileall.py'), '-q', '-x', 'port_v3', sp_dir])
def compile_missing_pyc(): sp_dir = environ.get_sp_dir() need_compile = False for root, dirs, files in os.walk(sp_dir): for fn in files: if fn.endswith('.py') and fn + 'c' not in files: need_compile = True if need_compile: print('compiling .pyc files...') utils._check_call([ build_python, '-Wi', join(environ.STDLIB_DIR, 'compileall.py'), '-q', '-x', 'port_v3', sp_dir ])
def compile_missing_pyc(): sp_dir = environ.get_sp_dir() stdlib_dir = environ.get_stdlib_dir() need_compile = False for root, dirs, files in os.walk(sp_dir): for fn in files: if fn.endswith(".py") and fn + "c" not in files: need_compile = True break if need_compile: print("compiling .pyc files...") utils._check_call( [config.build_python, "-Wi", join(stdlib_dir, "compileall.py"), "-q", "-x", "port_v3", sp_dir] )
def remove_easy_install_pth(files, preserve_egg_dir=False): """ remove the need for easy-install.pth and finally remove easy-install.pth itself """ absfiles = [join(config.build_prefix, f) for f in files] sp_dir = environ.get_sp_dir() for egg_path in glob(join(sp_dir, '*-py*.egg')): if isdir(egg_path): if preserve_egg_dir or not any( join(egg_path, i) in absfiles for i in walk_prefix(egg_path, False)): write_pth(egg_path) continue print('found egg dir:', egg_path) try: os.rename(join(egg_path, 'EGG-INFO/PKG-INFO'), egg_path + '-info') except OSError: pass utils.rm_rf(join(egg_path, 'EGG-INFO')) for fn in os.listdir(egg_path): if fn == '__pycache__': utils.rm_rf(join(egg_path, fn)) else: # this might be a name-space package # so the package directory already exists # from another installed dependency if os.path.exists(join(sp_dir, fn)): utils.copy_into(join(egg_path, fn), join(sp_dir, fn)) utils.rm_rf(join(egg_path, fn)) else: os.rename(join(egg_path, fn), join(sp_dir, fn)) elif isfile(egg_path): if not egg_path in absfiles: continue print('found egg:', egg_path) write_pth(egg_path) utils.rm_rf(join(sp_dir, 'easy-install.pth'))
def remove_easy_install_pth(files, preserve_egg_dir=False): """ remove the need for easy-install.pth and finally remove easy-install.pth itself """ absfiles = [join(config.build_prefix, f) for f in files] sp_dir = environ.get_sp_dir() for egg_path in glob(join(sp_dir, '*-py*.egg')): if isdir(egg_path): if preserve_egg_dir or not any(join(egg_path, i) in absfiles for i in walk_prefix(egg_path, False, windows_forward_slashes=False)): write_pth(egg_path) continue print('found egg dir:', egg_path) try: os.rename(join(egg_path, 'EGG-INFO'), egg_path + '-info') except OSError: pass utils.rm_rf(join(egg_path, 'EGG-INFO')) for fn in os.listdir(egg_path): if fn == '__pycache__': utils.rm_rf(join(egg_path, fn)) else: # this might be a name-space package # so the package directory already exists # from another installed dependency if os.path.exists(join(sp_dir, fn)): utils.copy_into(join(egg_path, fn), join(sp_dir, fn)) utils.rm_rf(join(egg_path, fn)) else: os.rename(join(egg_path, fn), join(sp_dir, fn)) elif isfile(egg_path): if not egg_path in absfiles: continue print('found egg:', egg_path) write_pth(egg_path) utils.rm_rf(join(sp_dir, 'easy-install.pth'))
def remove_easy_install_pth(preserve_egg_dir=False): """ remove the need for easy-install.pth and finally remove easy-install.pth itself """ sp_dir = environ.get_sp_dir() for egg_path in glob(join(sp_dir, '*-py*.egg')): if isdir(egg_path): if preserve_egg_dir: write_pth(egg_path) continue print('found egg dir:', egg_path) try: os.rename(join(egg_path, 'EGG-INFO/PKG-INFO'), egg_path + '-info') except OSError: pass utils.rm_rf(join(egg_path, 'EGG-INFO')) for fn in os.listdir(egg_path): if fn == '__pycache__': utils.rm_rf(join(egg_path, fn)) else: # this might be a name-space package # so the package directory already exists # from another installed dependency if os.path.exists(join(sp_dir, fn)): utils.copy_into(join(egg_path, fn), join(sp_dir, fn)) utils.rm_rf(join(egg_path, fn)) else: os.rename(join(egg_path, fn), join(sp_dir, fn)) elif isfile(egg_path): print('found egg:', egg_path) write_pth(egg_path) utils.rm_rf(join(sp_dir, 'easy-install.pth'))
def write_pth(egg_path): fn = basename(egg_path) with open(join(environ.get_sp_dir(), '%s.pth' % (fn.split('-')[0])), 'w') as fo: fo.write('./%s\n' % fn)
def write_pth(egg_path): fn = basename(egg_path) with open(join(environ.get_sp_dir(), "%s.pth" % (fn.split("-")[0])), "w") as fo: fo.write("./%s\n" % fn)