def do_main(temp_folder="build/update_modules", skip_module=None, # ["ete", "dataspyre", "pycuda", "cubehelix"], list_module=None, deps=False, schedule_only=False, deep_deps=False, checkings=None, task="install", source=None, download_only=False, force=False): """ calls function @see fn install_all but is meant to be added to scripts folder @param temp_folder folder where modules will be downloaded @param skip_module skip the module on this list @param list_module list of modules to update or None for all @param deps install a module with its dependencies @param schedule_only if True, the function returns the list of modules scheduled to be installed @param deep_deps check dependencies for dependencies @param checkings if True, run checkings, do not install anything, example of values @param task *install* or *shebang* or *download* ``""``, ``matplotlib``, ``100,end``, option *download* is equivalent to *checkings* @param source overwrite the source of the wheel @param download_only only download the modules, no installation @param force force the download or the installation If *deps* is True, *list_module* cannot be empty. .. versionchanged:: 1.1 Parameters *source*, *force* were added. """ try: from pymyinstall import is_travis_or_appveyor except ImportError: def is_travis_or_appveyor(): import sys if "travis" in sys.executable: return "travis" import os if os.environ.get("USERNAME", os.environ.get("USER", None)) == "appveyor": return "appveyor" return None if is_travis_or_appveyor() and source is None: source = "2" if task in ("install", "download"): checkings = checkings or task == "download" if checkings: try: from pymyinstall.win_installer import import_every_module except ImportError: pfolder = os.path.normpath(os.path.join( os.path.abspath(os.path.dirname(__file__)), "..", "..")) sys.path.append(pfolder) if "pymyinstall" in sys.modules: del sys.modules["pymyinstall"] if "pymyinstall.win_installer" in sys.modules: del sys.modules["pymyinstall.win_installer"] from pymyinstall.win_installer import import_every_module def to_int(s): if "end" in s: return -1 try: return int(s) except: return -1 if checkings in ("", "0,end", "0,-1"): module_list = None start = 0 end = -1 elif ":" in checkings: module_list = None spl = checkings.split(":") if len(spl) == 2: start = to_int(spl[0]) end = to_int(spl[1]) else: raise ValueError("unable to interpret: " + checkings) else: module_list = [_.strip() for _ in checkings.split(",")] start = 0 end = -1 print("CHECKINGS {}:{} -- {}".format(start, end, "all" if module_list is None else ",".join(module_list))) import_every_module(None, module_list, start=start, end=end) else: if not os.path.exists(temp_folder): os.makedirs(temp_folder) try: from pymyinstall.packaged import install_all except ImportError: folder = os.path.normpath(os.path.join( os.path.abspath(os.path.dirname(__file__)), "..", "..")) sys.path.append(folder) if "pymyinstall" in sys.modules: del sys.modules["pymyinstall"] if "pymyinstall.packaged" in sys.modules: del sys.modules["pymyinstall.packaged"] from pymyinstall.packaged import install_all res = install_all(temp_folder=temp_folder, verbose=True, skip_module=skip_module, list_module=list_module, deps=deps, schedule_only=schedule_only, deep_deps=deep_deps, source=source, download_only=download_only, force=force) if schedule_only: print("SCHEDULED") for r in res: print(r) elif task == "shebang": try: from pymyinstall.win_installer import win_patch_paths from pymyinstall.installhelper import get_pip_program except ImportError: pfolder = os.path.normpath(os.path.join( os.path.abspath(os.path.dirname(__file__)), "..", "..")) sys.path.append(pfolder) if "pymyinstall" in sys.modules: del sys.modules["pymyinstall"] if "pymyinstall.packaged" in sys.modules: del sys.modules["pymyinstall.packaged"] if "pymyinstall.win_installer" in sys.modules: del sys.modules["pymyinstall.win_installer"] from pymyinstall.win_installer import win_patch_paths from pymyinstall.installhelper import get_pip_program pip = get_pip_program() folder = os.path.dirname(os.path.abspath(pip)) win_patch_paths(temp_folder, None, fLOG=print) elif task in ("tool", "tool_download"): try: from pymyinstall.installcustom import install_graphviz except ImportError: pfolder = os.path.normpath(os.path.join( os.path.abspath(os.path.dirname(__file__)), "..", "..")) sys.path.append(pfolder) if "pymyinstall" in sys.modules: del sys.modules["pymyinstall"] if "pymyinstall.installcustom" in sys.modules: del sys.modules["pymyinstall.installcustom"] from pymyinstall.installcustom import install_graphviz if list_module is None: raise ValueError("A tool must be precised, list cannot be empty.") else: low = [_.lower() for _ in list_module] for tool in low: if tool == "graphviz": install_graphviz(temp_folder, install=task == "tool", fLOG=print, source=source) else: raise NameError("unable to install '{0}'".format(tool)) else: raise ValueError("unable to interpret task: " + task)
import sys sys.path.append("src") skip = ["actuariat_python", "code_beatrix", "ensae_teaching_cs", "jupytalk", "jyquickhelper", "mlstatpy", "pyquickhelper", "pyensae", "pyrsslocal", "pymyinstall", "pymmails", "teachpyx", "pythonnet", ] from pymyinstall.packaged import install_all install_all(temp_folder="build/update_modules{0}{1}{2}".format(*sys.version_info[:3]), verbose=True, skip_module=skip, source="2")
def do_main( temp_folder="build/update_modules", skip_module=None, # ["ete", "dataspyre", "pycuda", "cubehelix"], list_module=None, deps=False, schedule_only=False, deep_deps=False, checkings=None, task="install", source=None, download_only=False, force=False): """ calls function @see fn install_all but is meant to be added to scripts folder @param temp_folder folder where modules will be downloaded @param skip_module skip the module on this list @param list_module list of modules to update or None for all @param deps install a module with its dependencies @param schedule_only if True, the function returns the list of modules scheduled to be installed @param deep_deps check dependencies for dependencies @param checkings if True, run checkings, do not install anything, example of values @param task *install* or *shebang* or *download* ``""``, ``matplotlib``, ``100,end``, option *download* is equivalent to *checkings* @param source overwrite the source of the wheel @param download_only only download the modules, no installation @param force force the download or the installation If *deps* is True, *list_module* cannot be empty. .. versionchanged:: 1.1 Parameters *source*, *force* were added. """ try: from pymyinstall import is_travis_or_appveyor except ImportError: def is_travis_or_appveyor(): import sys if "travis" in sys.executable: return "travis" import os if os.environ.get("USERNAME", os.environ.get("USER", None)) == "appveyor": return "appveyor" return None if is_travis_or_appveyor() and source is None: source = "2" if task in ("install", "download"): checkings = checkings or task == "download" if checkings: try: from pymyinstall.win_installer import import_every_module except ImportError: pfolder = os.path.normpath( os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..")) sys.path.append(pfolder) if "pymyinstall" in sys.modules: del sys.modules["pymyinstall"] if "pymyinstall.win_installer" in sys.modules: del sys.modules["pymyinstall.win_installer"] from pymyinstall.win_installer import import_every_module def to_int(s): if "end" in s: return -1 try: return int(s) except ValueError: return -1 if checkings in ("", "0,end", "0,-1"): module_list = None start = 0 end = -1 elif ":" in checkings: module_list = None spl = checkings.split(":") if len(spl) == 2: start = to_int(spl[0]) end = to_int(spl[1]) else: raise ValueError("unable to interpret: " + checkings) else: module_list = [_.strip() for _ in checkings.split(",")] start = 0 end = -1 print("CHECKINGS {}:{} -- {}".format( start, end, "all" if module_list is None else ",".join(module_list))) import_every_module(None, module_list, start=start, end=end) else: if not os.path.exists(temp_folder): os.makedirs(temp_folder) try: from pymyinstall.packaged import install_all except ImportError: folder = os.path.normpath( os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..")) sys.path.append(folder) if "pymyinstall" in sys.modules: del sys.modules["pymyinstall"] if "pymyinstall.packaged" in sys.modules: del sys.modules["pymyinstall.packaged"] from pymyinstall.packaged import install_all res = install_all(temp_folder=temp_folder, verbose=True, skip_module=skip_module, list_module=list_module, deps=deps, schedule_only=schedule_only, deep_deps=deep_deps, source=source, download_only=download_only, force=force) if schedule_only: print("SCHEDULED") for r in res: print(r) elif task == "shebang": try: from pymyinstall.win_installer import win_patch_paths from pymyinstall.installhelper import get_pip_program except ImportError: pfolder = os.path.normpath( os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..")) sys.path.append(pfolder) if "pymyinstall" in sys.modules: del sys.modules["pymyinstall"] if "pymyinstall.packaged" in sys.modules: del sys.modules["pymyinstall.packaged"] if "pymyinstall.win_installer" in sys.modules: del sys.modules["pymyinstall.win_installer"] from pymyinstall.win_installer import win_patch_paths from pymyinstall.installhelper import get_pip_program pip = get_pip_program() folder = os.path.dirname(os.path.abspath(pip)) win_patch_paths(temp_folder, None, fLOG=print) elif task in ("tool", "tool_download"): try: from pymyinstall.installcustom import install_graphviz except ImportError: pfolder = os.path.normpath( os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..")) sys.path.append(pfolder) if "pymyinstall" in sys.modules: del sys.modules["pymyinstall"] if "pymyinstall.installcustom" in sys.modules: del sys.modules["pymyinstall.installcustom"] from pymyinstall.installcustom import install_graphviz if list_module is None: raise ValueError("A tool must be precised, list cannot be empty.") else: low = [_.lower() for _ in list_module] for tool in low: if tool == "graphviz": install_graphviz(temp_folder, install=task == "tool", fLOG=print, source=source) else: raise NameError("unable to install '{0}'".format(tool)) else: raise ValueError("unable to interpret task: " + task)