Performs python-side bootstrapping of Boost.Build/Python.

    This function arranges for 'b2.whatever' package names to work, while also
    allowing to put python files alongside corresponding jam modules.
519214
def bootstrap(root_path):
    

    m = imp.new_module("b2")
    # Note that:
    # 1. If __path__ is not list of strings, nothing will work
    # 2. root_path is already list of strings.
    m.__path__ = root_path
    sys.modules["b2"] = m

    import b2.build_system
    return b2.build_system.main()
636484
def try_run_setup(**kwargs):
    

    try:
        run_setup(**kwargs)
    except Exception as e:
        print(str(e))
        if "xgboost" in str(e).lower():
            kwargs["test_xgboost"] = False
            print("Couldn't install XGBoost for testing!")
            try_run_setup(**kwargs)
        elif "lightgbm" in str(e).lower():
            kwargs["test_lightgbm"] = False
            print("Couldn't install LightGBM for testing!")
            try_run_setup(**kwargs)
        elif kwargs["with_binary"]:
            kwargs["with_binary"] = False
            print("WARNING: The C extension could not be compiled, sklearn tree models not supported.")
            try_run_setup(**kwargs)
        else:
            print("ERROR: Failed to build!")
1036421
def build(build_name='default')
      description = Fudge::Parser.new.parse('Fudgefile')
      Fudge::Runner.new(description).run_build(build_name, options)
    end
374389
def setup(__pkg: ModuleType) -> Tuple[Callable[[str], str],
                                      Callable[[str, str, int], str]]:
    
    package_locale = path.join(path.dirname(__pkg.__file__), 'locale')
    gettext.install(__pkg.__name__, package_locale)

    return gettext.gettext, gettext.ngettext
73621
def op_bootstrap(self):
        """"""
        self.logger.info('Bootstrapping django-dev directory structure in current directory ...')
        self.make_venv(DJANGO_DEFAULT_VERSION)
        venv_path = self.make_venv('1.6.5')
        self.venv_install('south==1.0.1', venv_path)
        apps_dir = self.make_apps_dir()
        self.logger.info('Now you may symlink (ln -s) your apps '
                         '(and other apps that you apps depend upon) into %s' % apps_dir)
1336703
def install_python_module_locally(name):
    
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),
                  warn_only=False, capture=True):
        local('pip --quiet install %s' % name)
670271
def install():
    
    # check installed package
    print("Compare to '%s' ..." % _DST)
    need_install_flag = check_need_install()
    if not need_install_flag:
        print("\tpackage is up-to-date, no need to install.")
        return
    print("Difference been found, start installing ...")

    # remove __pycache__ folder and *.pyc file
    print("Remove *.pyc file ...")
    pyc_folder_list = list()
    for root, _, basename_list in os.walk(_ROOT):
        if os.path.basename(root) == "__pycache__":
            pyc_folder_list.append(root)

    for folder in pyc_folder_list:
        shutil.rmtree(folder)
    print("\tall *.pyc file has been removed.")

    # install this package to all python version
    print("Uninstall %s from %s ..." % (_PACKAGE_NAME, _DST))
    try:
        shutil.rmtree(_DST)
        print("\tSuccessfully uninstall %s" % _PACKAGE_NAME)
    except Exception as e:
        print("\t%s" % e)

    print("Install %s to %s ..." % (_PACKAGE_NAME, _DST))
    shutil.copytree(_ROOT, _DST)
    print("\tComplete!")
1275791
def install():
    
    import os, shutil
    
    _ROOT = os.getcwd()
    _PACKAGE_NAME = os.path.basename(_ROOT)
    
    print("Installing [%s] to all python version..." % _PACKAGE_NAME)
    # find all Python release installed on this windows computer
    installed_python_version = list()
    for root, folder_list, _ in os.walk(r"C:\\"):
        for folder in folder_list:
            if folder.startswith("Python"):
                if os.path.exists(os.path.join(root, folder, "pythonw.exe")):
                    installed_python_version.append(folder)
        break
    print("\tYou have installed: {0}".format(", ".join(installed_python_version)))
    
    # remove __pycache__ folder and *.pyc file
    print("\tRemoving *.pyc file ...")
    pyc_folder_list = list()
    for root, folder_list, _ in os.walk(_ROOT):
        if os.path.basename(root) == "__pycache__":
            pyc_folder_list.append(root)
    
    for folder in pyc_folder_list:
        shutil.rmtree(folder)
    print("\t\tall *.pyc file has been removed.")
    
    # install this package to all python version
    for py_root in installed_python_version:
        dst = os.path.join(r"C:\\", py_root, r"Lib\site-packages", _PACKAGE_NAME)
        try:
            shutil.rmtree(dst)
        except:
            pass
        print("\tRemoved %s." % dst)
        shutil.copytree(_ROOT, dst)
        print("\tInstalled %s." % dst)
    
    print("Complete!")
1245189
def install_python_package(self, arch, name=None, env=None, is_dir=True):
        ''''''
        if env is None:
            env = self.get_recipe_env(arch)

        with current_directory(self.get_build_dir(arch.arch)):
            hostpython = sh.Command(self.ctx.hostpython)

            shprint(hostpython, 'setup.py', 'build_ext', '--static-libpq',
                    _env=env)
            shprint(hostpython, 'setup.py', 'install', '-O2',
                    '--root={}'.format(self.ctx.get_python_install_dir()),
                    '--install-lib=.', _env=env)
1146946
private BootstrapHandler loadBootstrap(String bootstrapClassName)
      throws ClassNotFoundException, IllegalAccessException, InstantiationException {
    return classLoader.loadClass(bootstrapClassName).asSubclass(BootstrapHandler.class).newInstance();
  }
289191
def initpkg(pkgname, exportdefs, attr=None, eager=False):
    
    attr = attr or {}
    oldmod = sys.modules.get(pkgname)
    d = {}
    f = getattr(oldmod, '__file__', None)
    if f:
        f = _py_abspath(f)
    d['__file__'] = f
    if hasattr(oldmod, '__version__'):
        d['__version__'] = oldmod.__version__
    if hasattr(oldmod, '__loader__'):
        d['__loader__'] = oldmod.__loader__
    if hasattr(oldmod, '__path__'):
        d['__path__'] = [_py_abspath(p) for p in oldmod.__path__]
    if hasattr(oldmod, '__package__'):
        d['__package__'] = oldmod.__package__
    if '__doc__' not in exportdefs and getattr(oldmod, '__doc__', None):
        d['__doc__'] = oldmod.__doc__
    d.update(attr)
    if hasattr(oldmod, "__dict__"):
        oldmod.__dict__.update(d)
    mod = ApiModule(pkgname, exportdefs, implprefix=pkgname, attr=d)
    sys.modules[pkgname] = mod
    # eagerload in bypthon to avoid their monkeypatching breaking packages
    if 'bpython' in sys.modules or eager:
        for module in list(sys.modules.values()):
            if isinstance(module, ApiModule):
                module.__dict__
604426
def install_bootstrapped_files(nb_path=None, server_config=True, DEBUG=False):
    

    install_path = None
    print('Starting hide_code.js install...')
    current_dir = path.abspath(path.dirname(__file__))
    config_dirs = j_path.jupyter_config_path()
    notebook_module_path = Utils.get_notebook_module_dir()

    # check for config directory with a "custom" folder
    # TODO update this logic to check if custom.js file exists
    for dir in config_dirs:
        custom_dir = path.join(dir, "custom")
        if path.isdir(custom_dir):
            install_path = custom_dir
            break

    # last ditch effort in case jupyter config directories don't contain custom/custom.js
    if install_path == None:
        print("No config directories contain \"custom\" folder. Trying Jupyter notebook module path...")
        install_path = path.join(notebook_module_path, "static", "custom")

    if nb_path != None:
        install_path = nb_path
        print("Using argument supplied path: " + install_path)

    if DEBUG:
        print(install_path)

    # copy js into static/custom directory in Jupyter/iPython directory
    if path.isdir(install_path):
        shutil.copyfile(path.join(current_dir, "hide_code.js"), path.join(install_path, "hide_code.js"))
        print('Copying hide_code.js to ' + install_path)

        # add require to end of custom.js to auto-load on notebook startup
        print("Attempting to configure custom.js to auto-load hide_code.js...")
        try:
            with open(path.join(current_dir, "auto-load.txt")) as auto:
                auto_load_txt = auto.read();
                auto_loaded = False

                # check if auto-load.txt is already in custom.js
                with open(path.join(install_path, "custom.js"), 'r') as customJS:
                    if auto_load_txt in customJS.read():
                        auto_loaded = True
                        print("Custom.js already configured to auto-load hide_code.js.")

                if not auto_loaded:  # append auto load require to end of custom.js
                    with open(path.join(install_path, "custom.js"), 'a') as customJS:
                        customJS.write(auto_load_txt)
                        print("Configured custom.js to auto-load hide_code.js.")
        except:
            print("Custom.js not in custom directory.")
    else:
        print('Unable to install into ' + install_path)
        print('Directory doesn\'t exist.')
        print('Make sure Jupyter is installed.')

    if server_config:
        print("Attempting to configure auto-loading for hide_code export handlers.")
        try:
            # Activate the Python server extension
            server_cm = ConfigManager(config_dir=j_path.jupyter_config_dir())
            cfg = server_cm.get('jupyter_notebook_config')
            server_extensions = (cfg.setdefault('NotebookApp', {})
                                 .setdefault('server_extensions', [])
                                 )
            extension = 'hide_code.hide_code'
            if extension not in server_extensions:
                cfg['NotebookApp']['server_extensions'] += [extension]
                server_cm.update('jupyter_notebook_config', cfg)
                print('Configured jupyter to auto-load hide_code export handlers.')
            else:
                print("Jupyter already configured to auto-load export handlers.")
        except:
            print('Unable to install server extension.')
1136392
def build_packages(ctx, hide=False):
    """"""
    print("build_packages:")
    ctx.run("python setup.py sdist bdist_wheel", echo=True, hide=hide)
1319289
def run(self):
        """"""
        if not self.py_modules and not self.packages:
            return

        if self.py_modules:
            self.build_modules()

        if self.packages:
            self.build_packages()
            self.build_package_data()

        self.run_2to3(self.__updated_files, False)
        self.run_2to3(self.__updated_files, True)
        self.run_2to3(self.__doctests_2to3, True)

        # Only compile actual .py files, using our base class' idea of what our
        # output files are.
        self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=0))
328883
def bootstrap():
    ""
    # Link files shared by subprojects
    debian = path("debian")
    debian.exists() or debian.makedirs()

    for shared in ("debian/changelog", "LICENSE"):
        path(shared).exists() or (path("..") / shared).link(shared)

    build()
287074
def load(self, root, module_path, pkg_name):
        
        root = os.path.join(root, module_path)
        import_name = os.path.join(pkg_name, module_path).replace(os.sep, '.')
        for (_, name, _) in pkgutil.iter_modules([root]):
            self.modules[name] = import_module('.' + name, package=import_name)
        return self.modules
288370
def build_arch(self, arch):
        '''
        '''
        Recipe.build_arch(self, arch)
        self.build_cython_components(arch)
        self.install_python_package(arch)