def _find_stale_files(site_packages, python_packages, python_modules, ext_modules): """ Find stale files This method lists all files installed and then subtracts the ones which are intentionally being installed. EXAMPLES: It is crucial that only truly stale files are being found, of course. We check that when the doctest is being run, that is, after installation, there are no stale files:: sage: from sage.env import SAGE_SRC, SAGE_LIB sage: from sage_setup.find import find_python_sources sage: python_packages, python_modules = find_python_sources( ....: SAGE_SRC, ['sage', 'sage_setup']) sage: from sage_setup.clean import _find_stale_files TODO: move ``module_list.py`` into ``sage_setup`` and also check extension modules:: sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, []) sage: from sage.misc.sageinspect import loadable_module_extension sage: for f in stale_iter: ....: if f.endswith(loadable_module_extension()): continue ....: print('Found stale file: ' + f) """ PYMOD_EXTS = (os.path.extsep + 'py', os.path.extsep + 'pyc') from sage.misc.sageinspect import loadable_module_extension CEXTMOD_EXTS = (loadable_module_extension(), ) INIT_FILES = map(lambda x: '__init__' + x, PYMOD_EXTS) module_files = installed_files_by_module(site_packages, ['sage', 'sage_setup']) for mod in python_packages: try: files = module_files[mod] except KeyError: # the source module "mod" has not been previously installed, fine. continue _remove(files, mod, INIT_FILES) for mod in python_modules: try: files = module_files[mod] except KeyError: continue _remove(files, mod, PYMOD_EXTS) for ext in ext_modules: mod = ext.name try: files = module_files[mod] except KeyError: continue _remove(files, mod, CEXTMOD_EXTS) for files in module_files.values(): for f in files: yield f
def _find_stale_files(site_packages, python_packages, python_modules, ext_modules): """ Find stale files This method lists all files installed and then subtracts the ones which are intentionally being installed. EXAMPLES: It is crucial that only truly stale files are being found, of course. We check that when the doctest is being run, that is, after installation, there are no stale files:: sage: from sage.env import SAGE_SRC, SAGE_LIB sage: from sage_setup.find import find_python_sources sage: python_packages, python_modules = find_python_sources( ....: SAGE_SRC, ['sage', 'sage_setup']) sage: from sage_setup.clean import _find_stale_files TODO: move ``module_list.py`` into ``sage_setup`` and also check extension modules:: sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, []) sage: from sage.misc.sageinspect import loadable_module_extension sage: for f in stale_iter: ....: if f.endswith(loadable_module_extension()): continue ....: print('Found stale file: ' + f) """ PYMOD_EXTS = (os.path.extsep + 'py', os.path.extsep + 'pyc') from sage.misc.sageinspect import loadable_module_extension CEXTMOD_EXTS = (loadable_module_extension(),) INIT_FILES= map(lambda x: '__init__' + x, PYMOD_EXTS) module_files = installed_files_by_module(site_packages, ['sage', 'sage_setup']) for mod in python_packages: try: files = module_files[mod] except KeyError: # the source module "mod" has not been previously installed, fine. continue _remove(files, mod, INIT_FILES) for mod in python_modules: try: files = module_files[mod] except KeyError: continue _remove(files, mod, PYMOD_EXTS) for ext in ext_modules: mod = ext.name try: files = module_files[mod] except KeyError: continue _remove(files, mod, CEXTMOD_EXTS) for files in module_files.values(): for f in files: yield f
def _find_stale_files(site_packages, python_packages, python_modules, ext_modules, data_files, nobase_data_files=()): """ Find stale files This method lists all files installed and then subtracts the ones which are intentionally being installed. EXAMPLES: It is crucial that only truly stale files are being found, of course. We check that when the doctest is being run, that is, after installation, there are no stale files:: sage: from sage.env import SAGE_SRC, SAGE_LIB, SAGE_ROOT sage: cythonized_dir = os.path.join(SAGE_ROOT, "build", "pkgs", "sagelib", "src", "build", "cythonized") sage: from sage_setup.find import find_python_sources, find_extra_files sage: python_packages, python_modules, cython_modules = find_python_sources( ....: SAGE_SRC, ['sage', 'sage_setup']) sage: extra_files = list(find_extra_files(SAGE_SRC, ....: ['sage', 'sage_setup'], cythonized_dir, []).items()) sage: from sage_setup.clean import _find_stale_files TODO: move ``module_list.py`` into ``sage_setup`` and also check extension modules:: sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, [], extra_files) sage: from sage.misc.sageinspect import loadable_module_extension sage: skip_extensions = (loadable_module_extension(),) sage: for f in stale_iter: ....: if f.endswith(skip_extensions): continue ....: if '/ext_data/' in f: continue ....: print('Found stale file: ' + f) """ PYMOD_EXTS = get_extensions('source') + get_extensions('bytecode') CEXTMOD_EXTS = get_extensions('extension') INIT_FILES = tuple('__init__' + x for x in PYMOD_EXTS) module_files = installed_files_by_module(site_packages, ['sage', 'sage_setup']) for mod in python_packages: try: files = module_files[mod] except KeyError: # the source module "mod" has not been previously installed, fine. continue _remove(files, mod, INIT_FILES) for mod in python_modules: try: files = module_files[mod] except KeyError: continue _remove(files, mod, PYMOD_EXTS) for ext in ext_modules: mod = ext.name try: files = module_files[mod] except KeyError: continue _remove(files, mod, CEXTMOD_EXTS) # Convert data_files to a set installed_files = set() for dir, files in data_files: for f in files: installed_files.add(os.path.join(dir, os.path.basename(f))) for dir, files in nobase_data_files: for f in files: installed_files.add(f) for files in module_files.values(): for f in files: if f not in installed_files: yield f
def _find_stale_files(site_packages, python_packages, python_modules, ext_modules, data_files): """ Find stale files This method lists all files installed and then subtracts the ones which are intentionally being installed. EXAMPLES: It is crucial that only truly stale files are being found, of course. We check that when the doctest is being run, that is, after installation, there are no stale files:: sage: from sage.env import SAGE_SRC, SAGE_LIB, SAGE_CYTHONIZED sage: from sage_setup.find import find_python_sources, find_extra_files sage: python_packages, python_modules = find_python_sources( ....: SAGE_SRC, ['sage', 'sage_setup']) sage: extra_files = find_extra_files(python_packages, SAGE_SRC, ....: SAGE_CYTHONIZED, SAGE_LIB, ["ntlwrap.cpp"]) sage: from sage_setup.clean import _find_stale_files TODO: move ``module_list.py`` into ``sage_setup`` and also check extension modules:: sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, [], extra_files) sage: from sage.misc.sageinspect import loadable_module_extension sage: skip_extensions = (loadable_module_extension(),) sage: for f in stale_iter: ....: if f.endswith(skip_extensions): continue ....: print('Found stale file: ' + f) """ from sage.misc.sageinspect import loadable_module_extension PYMOD_EXTS = (os.path.extsep + 'py', os.path.extsep + 'pyc') CEXTMOD_EXTS = (loadable_module_extension(),) INIT_FILES = tuple('__init__' + x for x in PYMOD_EXTS) module_files = installed_files_by_module(site_packages, ['sage', 'sage_setup']) for mod in python_packages: try: files = module_files[mod] except KeyError: # the source module "mod" has not been previously installed, fine. continue _remove(files, mod, INIT_FILES) for mod in python_modules: try: files = module_files[mod] except KeyError: continue _remove(files, mod, PYMOD_EXTS) for ext in ext_modules: mod = ext.name try: files = module_files[mod] except KeyError: continue _remove(files, mod, CEXTMOD_EXTS) # Convert data_files to a set installed_files = set() for dir, files in data_files: dir = os.path.relpath(dir, site_packages) if dir.startswith("."): # dir is not inside site_packages continue for f in files: installed_files.add(os.path.join(dir, os.path.basename(f))) for files in module_files.values(): for f in files: if f not in installed_files: yield f
def _find_stale_files(site_packages, python_packages, python_modules, ext_modules, data_files): """ Find stale files This method lists all files installed and then subtracts the ones which are intentionally being installed. EXAMPLES: It is crucial that only truly stale files are being found, of course. We check that when the doctest is being run, that is, after installation, there are no stale files:: sage: from sage.env import SAGE_SRC, SAGE_LIB, SAGE_CYTHONIZED sage: from sage_setup.find import find_python_sources, find_extra_files sage: python_packages, python_modules = find_python_sources( ....: SAGE_SRC, ['sage', 'sage_setup']) sage: extra_files = find_extra_files(python_packages, SAGE_SRC, ....: SAGE_CYTHONIZED, SAGE_LIB, ["ntlwrap.cpp"]) sage: from sage_setup.clean import _find_stale_files TODO: move ``module_list.py`` into ``sage_setup`` and also check extension modules:: sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, [], extra_files) sage: from sage.misc.sageinspect import loadable_module_extension sage: skip_extensions = (loadable_module_extension(),) sage: for f in stale_iter: ....: if f.endswith(skip_extensions): continue ....: print('Found stale file: ' + f) """ from sage.misc.sageinspect import loadable_module_extension PYMOD_EXTS = (os.path.extsep + 'py', os.path.extsep + 'pyc') CEXTMOD_EXTS = (loadable_module_extension(), ) INIT_FILES = tuple('__init__' + x for x in PYMOD_EXTS) module_files = installed_files_by_module(site_packages, ['sage', 'sage_setup']) for mod in python_packages: try: files = module_files[mod] except KeyError: # the source module "mod" has not been previously installed, fine. continue _remove(files, mod, INIT_FILES) for mod in python_modules: try: files = module_files[mod] except KeyError: continue _remove(files, mod, PYMOD_EXTS) for ext in ext_modules: mod = ext.name try: files = module_files[mod] except KeyError: continue _remove(files, mod, CEXTMOD_EXTS) # Convert data_files to a set installed_files = set() for dir, files in data_files: dir = os.path.relpath(dir, site_packages) if dir.startswith("."): # dir is not inside site_packages continue for f in files: installed_files.add(os.path.join(dir, os.path.basename(f))) for files in module_files.values(): for f in files: if f not in installed_files: yield f