Exemplo n.º 1
0
def install():
    try:
        from pip import main as pip_main
    except ImportError:
        from pip._internal import main as pip_main
    install_command = ['install', "-U"]
    if os.geteuid() != 0:
        print("The current user is not root and is installed in user mode.")
        install_command.append("--user")
    if sys.version_info < (3, 4):
        print(
            "Current python version is lower than 3.4, need to install asyncio."
        )
        install_command.append("asyncio")
    try:
        importlib.import_module("qrcode_terminal")
    except ImportError:
        install_qrcode_dependency = "n"
        try:
            install_qrcode_dependency = str(
                input(
                    "Do you want to install [qrcode_terminal] to support QR code login? (y/N)"
                ))
        except EOFError:
            print("N")
        if install_qrcode_dependency.lower() == 'y':
            install_command.append("qrcode_terminal")
    install_command.extend([
        "Flask", "hoedown", "xpinyin", "pyrss2gen", "gitpython", "requests",
        "watchdog"
    ])
    pip_main(install_command)
    def save_offline_dependencies(self,
                                  requirements_path,
                                  dest_path,
                                  cs_server_address=None):

        if os.path.isdir(dest_path):
            shutil.rmtree(path=dest_path, ignore_errors=True)

        if not os.path.exists(requirements_path):
            return

        proxy = os.environ.get('http_proxy')
        pip_args = ['download']
        if proxy:
            pip_args.append('--proxy')
            pip_args.append(proxy)

        if cs_server_address:
            pip_args.append('--trusted-host={cs_server_address}'.format(
                cs_server_address=cs_server_address))
            pip_args.append(
                '--extra-index-url=http://{cs_server_address}:{cs_pypi_port}'.
                format(cs_server_address=cs_server_address,
                       cs_pypi_port=self.CS_PYPI_PORT))

        pip_args.append('--requirement={requirements_path}'.format(
            requirements_path=requirements_path))
        pip_args.append('--dest={dest_path}'.format(dest_path=dest_path))
        pip_main(pip_args)
Exemplo n.º 3
0
def install_plugin_pip_reqs(install_spec: JSON):
    """Installs a plugin's pip requirements."""
    try:
        napari_spec = napari_spec_from_install_spec(install_spec)
        pip_requirements = napari_spec['pip_requirements']
    except KeyError:
        pass
    else:
        try:
            __IPYTHON__
        except NameError:
            pass
        else:
            global IPY_WARN
            if not IPY_WARN:
                warn('running from IPython - cannot pip install')
                IPY_WARN = True
            return

        if isinstance(pip_requirements, str):
            # requirements.txt-like file
            path = osp.join(get_abs_plugin_path(install_spec),
                            pip_requirements)
            pip_main(PIP_INSTALL.extend(['-r', path]))
        else:
            pip_main(PIP_INSTALL.extend(pip_requirements))
Exemplo n.º 4
0
def uninstall_package(package):
    try:
        from pip import main as pip_main
    except ImportError:
        from pip._internal import main as pip_main
    install_command = ['uninstall']
    if os.geteuid() != 0:
        install_command.append("--user")
    install_command.append(package)
    pip_main(install_command)
Exemplo n.º 5
0
    def install(params):
        """
        Install third-party Mod
        """
        from pip import main as pip_main
        from pip.commands.install import InstallCommand

        params = [param for param in params]

        options, mod_list = InstallCommand().parse_args(params)

        params = ["install"] + params

        for mod_name in mod_list:
            mod_name_index = params.index(mod_name)
            if mod_name.startswith("rqalpha_mod_sys_"):
                print('System Mod can not be installed or uninstalled')
                return
            if "rqalpha_mod_" in mod_name:
                lib_name = mod_name
            else:
                lib_name = "rqalpha_mod_" + mod_name
            params[mod_name_index] = lib_name

        # Install Mod
        pip_main(params)

        # Export config
        mod_config_path = get_mod_config_path(generate=True)
        mod_config = load_mod_config(mod_config_path, loader=yaml.RoundTripLoader)

        if len(mod_list) == 0:
            """
            主要是方便 `pip install -e .` 这种方式 本地调试 Mod 使用,需要满足以下条件:
            1.  `rqalpha mod install -e .` 命令是在对应 自定义 Mod 的根目录下
            2.  该 Mod 必须包含 `setup.py` 文件(否则也不能正常的 `pip install -e .` 来安装)
            3.  该 Mod 包名必须按照 RQAlpha 的规范来命名,具体规则如下
                *   必须以 `rqalpha-mod-` 来开头,比如 `rqalpha-mod-xxx-yyy`
                *   对应import的库名必须要 `rqalpha_mod_` 来开头,并且需要和包名后半部分一致,但是 `-` 需要替换为 `_`, 比如 `rqalpha_mod_xxx_yyy`
            """
            mod_name = _detect_package_name_from_dir()
            mod_name = mod_name.replace("-", "_").replace("rqalpha_mod_", "")
            mod_list.append(mod_name)

        for mod_name in mod_list:
            if "rqalpha_mod_" in mod_name:
                mod_name = mod_name.replace("rqalpha_mod_", "")
            mod_config['mod'][mod_name] = {}
            mod_config['mod'][mod_name]['enabled'] = False

        dump_config(mod_config_path, mod_config)
        list({})
Exemplo n.º 6
0
    def command_dependencies(self, action, *plugins):
        # test pytest is installed and return ready if it is
        if action == "check":
            try:
                import pytest
                del pytest

                for plugin in plugins:
                    __import__(plugin)
                return ('dependencies', 'ready')
            except ImportError:
                pass

            # pytest is missing, we'll report so and expect to be requested to
            # install
            self.send('dependencies', 'missing')
        elif action == "install":
            # test at least pip exists, otherwise we're doomed to fail
            try:
                import pip
                del pip
            except ImportError:
                return ('dependencies', 'failed')

            # handle different versions of pip
            try:
                from pip import main as pip_main
            except ImportError:
                # here be dragons
                from pip._internal import main as pip_main

            # ignoring installed six and upgrading is requried to avoid an osx
            # bug see https://github.com/pypa/pip/issues/3165 for more details
            pip_command = ['install', 'pytest'] + list(plugins)
            if platform.system() == 'Darwin':
                pip_command += [
                    '--upgrade', '--user', '--ignore-installed', 'six'
                ]
            pip_main(pip_command)

            # make sure pytest was successfully installed
            try:
                import pytest
                del pytest
                return ('dependencies', 'ready')
            except ImportError:
                return ('dependencies', 'failed')
        else:
            raise RuntimeError("Unexpected dependencies argument: "
                               "{}".format(action))
Exemplo n.º 7
0
def install(params):
    """
    Install third-party Mod
    """
    from pip import main as pip_main
    from pip.commands.install import InstallCommand

    params = [param for param in params]

    options, mod_list = InstallCommand().parse_args(params)

    params = ["install"] + params

    for mod_name in mod_list:
        mod_name_index = params.index(mod_name)
        if mod_name in system_mod:
            print('System Mod can not be installed or uninstalled')
            return
        if "rqalpha_mod_" in mod_name:
            lib_name = mod_name
            mod_name = lib_name.replace("rqalpha_mod_", "")
        else:
            lib_name = "rqalpha_mod_" + mod_name
        params[mod_name_index] = lib_name

    # Install Mod
    pip_main(params)

    # Export config
    config_path = get_default_config_path()
    config = load_config(config_path, loader=yaml.RoundTripLoader)

    for mod_name in mod_list:
        if "rqalpha_mod_" in mod_name:
            lib_name = mod_name
            mod_name = lib_name.replace("rqalpha_mod_", "")
        else:
            lib_name = "rqalpha_mod_" + mod_name

        mod = import_module(lib_name)

        mod_config = yaml.load(mod.__mod_config__, yaml.RoundTripLoader)

        config['mod'][mod_name] = mod_config
        config['mod'][mod_name]['lib'] = lib_name
        config['mod'][mod_name]['enabled'] = False
        config['mod'][mod_name]['priority'] = 1000

    dump_config(config_path, config)
Exemplo n.º 8
0
    def run(self):
        # install code
        pip_main(['install', '.'])

        specs = self.distribution.pyinstaller_specs

        print("specs: {}".format(specs))

        for spec in specs:
            pyi_args = [
                "--noconfirm", "--onefile", "--distpath=.", "--clean",
                os.path.join(PATH, spec)]

            with remember_cwd(EXE_BUILD_DIR):
                run(pyi_args)
Exemplo n.º 9
0
    def install_requirements(self):
        """Resolve and install requirements. This function will read
        the file ``requirements.txt`` from path passed as argument, and
        then use pip to install them.
        """
        requirements = os.path.abspath(
            os.path.join(self.new_version_path, "..", "requirements.txt"))
        if os.path.exists(requirements):
            try:
                from pip import main as pip_main
            except ImportError:
                raise PackageError("This module needs python dependencies. " +
                                   "You need pip to install dependencies, " +
                                   "please install pip libraries before.")

            pip_main(["-q", "install", "-r", requirements])
Exemplo n.º 10
0
    def install_requirements(self):
        """Resolve and install requirements. This function will read
        the file ``requirements.txt`` from path passed as argument, and
        then use pip to install them.
        """
        requirements = os.path.abspath(
                os.path.join(self.new_version_path, "..", "requirements.txt")
        )
        if os.path.exists(requirements):
            try:
                from pip import main as pip_main
            except ImportError:
                raise PackageError("This module needs python dependencies. " +
                                   "You need pip to install dependencies, " +
                                   "please install pip libraries before.")

            pip_main(["-q", "install", "-r", requirements])
Exemplo n.º 11
0
def download_from_pypi(dest, pkg=None, reqfile=None, extra_args=None):
    if (not pkg and not reqfile) or (pkg and reqfile):
        raise ValueError('Call with either pkg or reqfile')
    extra_args = extra_args or []
    pip_version = LooseVersion(getattr(pip, '__version__', '1.0'))
    cmd = 'install'
    no_wheel = []
    target = [pkg] if pkg else ['-r', reqfile]
    if pip_version >= LooseVersion('1.4'):
        no_wheel = ['--no-use-wheel']
    if pip_version >= LooseVersion('7'):
        no_wheel = ['--no-binary=:all:']
    if pip_version >= LooseVersion('8'):
        cmd = 'download'
    with patch_sys_executable():
        pip_main([cmd, '-d', dest, '--no-deps'] + no_wheel + extra_args +
                 target)
Exemplo n.º 12
0
def download_from_pypi(dest, pkg=None, reqfile=None, extra_args=None):
    if (not pkg and not reqfile) or (pkg and reqfile):
        raise ValueError('Call with either pkg or reqfile')
    extra_args = extra_args or []
    pip_version = LooseVersion(getattr(pip, '__version__', '1.0'))
    cmd = 'install'
    no_wheel = []
    target = [pkg] if pkg else ['-r', reqfile]
    if pip_version >= LooseVersion('1.4'):
        no_wheel = ['--no-use-wheel']
    if pip_version >= LooseVersion('7'):
        no_wheel = ['--no-binary=:all:']
    if pip_version >= LooseVersion('8'):
        cmd = 'download'
    with patch_sys_executable():
        pip_main([cmd, '-d', dest, '--no-deps'] + no_wheel + extra_args +
                 target)
Exemplo n.º 13
0
    def install(params):
        """
        Install third-party Mod
        """
        from pip import main as pip_main
        from pip.commands.install import InstallCommand

        params = [param for param in params]

        options, mod_list = InstallCommand().parse_args(params)

        params = ["install"] + params

        for mod_name in mod_list:
            mod_name_index = params.index(mod_name)
            if mod_name.startswith("rqalpha_mod_sys_"):
                six.print_('System Mod can not be installed or uninstalled')
                return
            if "rqalpha_mod_" in mod_name:
                lib_name = mod_name
            else:
                lib_name = "rqalpha_mod_" + mod_name
            params[mod_name_index] = lib_name

        # Install Mod
        installed_result = pip_main(params)

        # Export config
        from rqalpha.utils.config import load_yaml, user_mod_conf_path
        user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(user_mod_conf_path()) else {'mod': {}}

        if installed_result == 0:
            # 如果为0,则说明安装成功
            if len(mod_list) == 0:
                """
                主要是方便 `pip install -e .` 这种方式 本地调试 Mod 使用,需要满足以下条件:
                1.  `rqalpha mod install -e .` 命令是在对应 自定义 Mod 的根目录下
                2.  该 Mod 必须包含 `setup.py` 文件(否则也不能正常的 `pip install -e .` 来安装)
                3.  该 Mod 包名必须按照 RQAlpha 的规范来命名,具体规则如下
                    *   必须以 `rqalpha-mod-` 来开头,比如 `rqalpha-mod-xxx-yyy`
                    *   对应import的库名必须要 `rqalpha_mod_` 来开头,并且需要和包名后半部分一致,但是 `-` 需要替换为 `_`, 比如 `rqalpha_mod_xxx_yyy`
                """
                mod_name = _detect_package_name_from_dir()
                mod_name = mod_name.replace("-", "_").replace("rqalpha_mod_", "")
                mod_list.append(mod_name)

            for mod_name in mod_list:
                if "rqalpha_mod_" in mod_name:
                    mod_name = mod_name.replace("rqalpha_mod_", "")
                if "==" in mod_name:
                    mod_name = mod_name.split('==')[0]
                user_conf['mod'][mod_name] = {}
                user_conf['mod'][mod_name]['enabled'] = False

            dump_config(user_mod_conf_path(), user_conf)

        return installed_result
Exemplo n.º 14
0
def main():
    from pipproxy.pippatch.venv import restart_in_venv as patched_restart_in_venv
    import pip.venv
    import pip.basecommand
    pip.venv.restart_in_venv = patched_restart_in_venv
    pip.basecommand.restart_in_venv = patched_restart_in_venv


    from pip.req import InstallRequirement
    InstallRequirement._orig_update_editable, InstallRequirement.update_editable = \
        InstallRequirement.update_editable, patched_update_editable

    #InstallRequirement.update_editable = lambda *args, **kwargs: False

    #from pip.commands.install import InstallRequirement
    #InstallRequirement.update_editable = lambda *args, **kwargs: False

    from pip import main as pip_main
    pip_main()
Exemplo n.º 15
0
    def uninstall(params):
        """
        Uninstall third-party Mod
        """

        from pip import main as pip_main
        from pip.commands.uninstall import UninstallCommand

        params = [param for param in params]

        options, mod_list = UninstallCommand().parse_args(params)

        params = ["uninstall"] + params

        for mod_name in mod_list:
            mod_name_index = params.index(mod_name)
            if mod_name.startswith("rqalpha_mod_sys_"):
                print('System Mod can not be installed or uninstalled')
                return
            if "rqalpha_mod_" in mod_name:
                lib_name = mod_name
            else:
                lib_name = "rqalpha_mod_" + mod_name
            params[mod_name_index] = lib_name

        # Uninstall Mod
        pip_main(params)

        # Remove Mod Config
        mod_config_path = get_default_config_path("mod_config")
        mod_config = load_config(mod_config_path,
                                 loader=yaml.RoundTripLoader,
                                 verify_version=False)

        for mod_name in mod_list:
            if "rqalpha_mod_" in mod_name:
                mod_name = mod_name.replace("rqalpha_mod_", "")

            del mod_config['mod'][mod_name]

        dump_config(mod_config_path, mod_config)
        list({})
Exemplo n.º 16
0
 def main(list_of_args):
     """
     It's alias of pip.main function, it needed, because pip10 remove public API
     <br>`param list_of_args` must be list, same arguments as pip
     <br>`return` same as alias
     """
     try:
         from pip import main as pip_main
     except ImportError:
         from pip._internal import main as pip_main
     return pip_main(list_of_args)
    def pip_command(self, command, *args):
        """
        Runs a pip command
        """
        from pip import main as pip_main

        args = [command] + list(args)
        if self.verbosity == 0:
            args.insert(0, '--quiet')
        elif self.verbosity == 2:
            args.insert(0, '--verbose')
        return pip_main(args)
Exemplo n.º 18
0
def main():
    from pip import main as pip_main
    print("Setting up SpinEverydayBot...")

    ver = version.split()[0].split('.')
    if not (int(ver[0]) >= 3 and int(ver[1]) >= 6):
        exit("ERROR: You need to install Python 3.6 or newer to use this bot")

    try:
        import telegram
    except ImportError:
        print("WARNING: 'python-telegram-bot' package is not installed. Installing...")
        if pip_main(['install', 'python-telegram-bot']) != 0:
            exit("""ERROR: An error occurred while installing packages.
Check that you're running this script as root or administrator""")
        import telegram

    del telegram

    try:
        import TeleSocketClient
        del TeleSocketClient
    except ImportError:
        if input("Do you want to use TeleSocket Service? (y/N): ").lower().strip() == "y":
            print("WARNING: 'TeleSocketClient' package is not installed. Installing...")
            if pip_main(['install', 'TeleSocketClient']) != 0:
                exit("""ERROR: An error occurred while installing packages.
            Check that you're running this script as root or administrator""")
            import TeleSocketClient
            del TeleSocketClient

    if not path.exists("config.py"):
        print("WARNING: 'config.py' doesn't exist, copying example...")
        copy("config_example.py", "config.py")
        input("Now change example values to yours in file 'config.py' and press <Enter>")

    check_config()
    print("Setup finished")
    print("Now you can run your bot via 'python3.6 bot.py' command")
    exit(0)
Exemplo n.º 19
0
    def uninstall(params):
        """
        Uninstall third-party Mod
        """

        from pip import main as pip_main
        from pip.commands.uninstall import UninstallCommand

        params = [param for param in params]

        options, mod_list = UninstallCommand().parse_args(params)

        params = ["uninstall"] + params

        for mod_name in mod_list:
            mod_name_index = params.index(mod_name)
            if mod_name.startswith("rqalpha_mod_sys_"):
                print('System Mod can not be installed or uninstalled')
                return
            if "rqalpha_mod_" in mod_name:
                lib_name = mod_name
            else:
                lib_name = "rqalpha_mod_" + mod_name
            params[mod_name_index] = lib_name

        # Uninstall Mod
        pip_main(params)

        # Remove Mod Config
        mod_config_path = get_mod_config_path(generate=True)
        mod_config = load_mod_config(mod_config_path, loader=yaml.RoundTripLoader)

        for mod_name in mod_list:
            if "rqalpha_mod_" in mod_name:
                mod_name = mod_name.replace("rqalpha_mod_", "")

            del mod_config['mod'][mod_name]

        dump_config(mod_config_path, mod_config)
        list({})
Exemplo n.º 20
0
    def install(params):
        """
        Install third-party Mod
        """
        from pip import main as pip_main
        from pip.commands.install import InstallCommand

        params = [param for param in params]

        options, mod_list = InstallCommand().parse_args(params)

        params = ["install"] + params

        for mod_name in mod_list:
            mod_name_index = params.index(mod_name)
            if mod_name.startswith("rqalpha_mod_sys_"):
                print('System Mod can not be installed or uninstalled')
                return
            if "rqalpha_mod_" in mod_name:
                lib_name = mod_name
                mod_name = lib_name.replace("rqalpha_mod_", "")
            else:
                lib_name = "rqalpha_mod_" + mod_name
            params[mod_name_index] = lib_name

        # Install Mod
        pip_main(params)

        # Export config
        mod_config_path = get_mod_config_path(generate=True)
        mod_config = load_mod_config(mod_config_path,
                                     loader=yaml.RoundTripLoader)

        for mod_name in mod_list:
            mod_config['mod'][mod_name] = {}
            mod_config['mod'][mod_name]['enabled'] = False

        dump_config(mod_config_path, mod_config)
        list({})
Exemplo n.º 21
0
def install_precompiled_windows_pyeda():
    def ssl_context():
        """
        create an ssl context, where the certificate is not verified

        Notes:
            This is necessary because http://rumo.biologie.hu-berlin.de has no valid certificate.
        Returns:
            SSLContext

        """
        context = create_default_context()
        context.check_hostname = False
        context.verify_mode = CERT_NONE
        return context

    try:
        import pyeda
    except ImportError:
        system_version = architecture()[0]
        major, minor, micro, releaselevel, serial = version_info

        pyeda_str = 'pyeda-0.28.0-cp{0}{1}-cp{0}{1}m-win'.format(major, minor)

        if system_version == "32bit":
            pyeda_str += '32.whl'
        elif system_version == '64bit':
            pyeda_str += '_amd64.whl'
        else:
            raise OSError(
                'System version {} not known.'.format(system_version))

        source_path = 'http://rumo.biologie.hu-berlin.de/rxncon_downloads/'
        try:
            urlopen(source_path + pyeda_str, context=ssl_context())
            pip_main(['install', source_path + pyeda_str])
        except URLError:
            exit(1)
Exemplo n.º 22
0
    def uninstall(params):
        """
        Uninstall third-party Mod
        """

        from pip import main as pip_main
        from pip.commands.uninstall import UninstallCommand

        params = [param for param in params]

        options, mod_list = UninstallCommand().parse_args(params)

        params = ["uninstall"] + params

        for mod_name in mod_list:
            mod_name_index = params.index(mod_name)
            if mod_name.startswith("rqalpha_mod_sys_"):
                six.print_('System Mod can not be installed or uninstalled')
                return
            if "rqalpha_mod_" in mod_name:
                lib_name = mod_name
            else:
                lib_name = "rqalpha_mod_" + mod_name
            params[mod_name_index] = lib_name

        # Uninstall Mod
        uninstalled_result = pip_main(params)
        # Remove Mod Config
        from rqalpha.utils.config import user_mod_conf_path, load_yaml
        user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(
            user_mod_conf_path()) else {
                'mod': {}
            }

        for mod_name in mod_list:
            if "rqalpha_mod_" in mod_name:
                mod_name = mod_name.replace("rqalpha_mod_", "")

            del user_conf['mod'][mod_name]

        dump_config(user_mod_conf_path(), user_conf)
        return uninstalled_result
Exemplo n.º 23
0
    def uninstall(params):
        """
        Uninstall third-party Mod
        """

        from pip import main as pip_main
        from pip.commands.uninstall import UninstallCommand

        params = [param for param in params]

        options, mod_list = UninstallCommand().parse_args(params)

        params = ["uninstall"] + params

        for mod_name in mod_list:
            mod_name_index = params.index(mod_name)
            if mod_name.startswith("rqalpha_mod_sys_"):
                six.print_('System Mod can not be installed or uninstalled')
                return
            if "rqalpha_mod_" in mod_name:
                lib_name = mod_name
            else:
                lib_name = "rqalpha_mod_" + mod_name
            params[mod_name_index] = lib_name

        # Uninstall Mod
        uninstalled_result = pip_main(params)
        # Remove Mod Config
        from rqalpha.utils.config import user_mod_conf_path, load_yaml
        user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(user_mod_conf_path()) else {'mod': {}}

        for mod_name in mod_list:
            if "rqalpha_mod_" in mod_name:
                mod_name = mod_name.replace("rqalpha_mod_", "")

            del user_conf['mod'][mod_name]

        dump_config(user_mod_conf_path(), user_conf)
        return uninstalled_result
Exemplo n.º 24
0
def main(*args, **kwargs):
    install_pip_patches()
    return pip_main(*args, **kwargs)
Exemplo n.º 25
0
def setup():
    try:
        temp_dir = getcwd()

        if not isfile('{}/waspc.lock'.format(temp_dir)):
            # need to install custom library (SSLyze) for wg_ssl audit plugin support
            pip_main(['install', 'https://github.com/ZenSecurity/sslyze/archive/master.tar.gz#egg=SSLyze', '--verbose'])
            
            file('{}/waspc.lock'.format(temp_dir), 'w').close()

        profiles_dir = 'w3af-repo/profiles'

        distutils_setup(
            name='w3af',

            version=get_version(),
            license='GNU General Public License v2 (GPLv2)',
            platforms='Linux',

            description='w3af is an open source web application security scanner.',
            long_description=file('README.rst').read(),

            author='em',
            author_email='*****@*****.**',
            url='https://github.com/ZenSecurity/w3af-module',

            packages=find_packages(exclude=('tests.*', 'tests', 'mot_utils*',)),
            # include everything in source control which lives inside one of the packages identified by find_packages
            include_package_data=True,

            # include the data files, which don't live inside the directory
            data_files=[('profiles', [normpath(join(profiles_dir, profile_file)) for profile_file in listdir(profiles_dir)])],

            # This allows w3af plugins to read the data files which we deploy with data_files.
            zip_safe=False,

            # Run the module tests using nose
            test_suite='nose.collector',

            # Require at least the easiest PIP requirements from w3af
            install_requires=get_pip_requirements(),
            dependency_links=get_pip_git_requirements(),

            # Install these scripts
            scripts=['w3af-repo/w3af_console',
                     'w3af-repo/w3af_gui',
                     'w3af-repo/w3af_api'],

            # https://pypi.python.org/pypi?%3Aaction=list_classifiers
            classifiers=[
                'Development Status :: 5 - Production/Stable',
                'Intended Audience :: Developers',
                'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
                'Natural Language :: English',
                'Operating System :: POSIX :: Linux',
                'Programming Language :: Python',
                'Programming Language :: Python :: 2.7',
                'Topic :: Security'
            ],
        )
    except Exception as exception:
        print('{} - {}'.format(exception.__class__.__name__, exception))
Exemplo n.º 26
0
    def install(params):
        """
        Install third-party Mod
        """
        from pip import main as pip_main
        from pip.commands.install import InstallCommand

        params = [param for param in params]

        options, mod_list = InstallCommand().parse_args(params)

        params = ["install"] + params

        for mod_name in mod_list:
            mod_name_index = params.index(mod_name)
            if mod_name.startswith("rqalpha_mod_sys_"):
                six.print_('System Mod can not be installed or uninstalled')
                return
            if "rqalpha_mod_" in mod_name:
                lib_name = mod_name
            else:
                lib_name = "rqalpha_mod_" + mod_name
            params[mod_name_index] = lib_name

        # Install Mod
        installed_result = pip_main(params)

        # Export config
        from rqalpha.utils.config import load_yaml, user_mod_conf_path
        user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(
            user_mod_conf_path()) else {
                'mod': {}
            }

        if installed_result == 0:
            # 如果为0,则说明安装成功
            if len(mod_list) == 0:
                """
                主要是方便 `pip install -e .` 这种方式 本地调试 Mod 使用,需要满足以下条件:
                1.  `rqalpha mod install -e .` 命令是在对应 自定义 Mod 的根目录下
                2.  该 Mod 必须包含 `setup.py` 文件(否则也不能正常的 `pip install -e .` 来安装)
                3.  该 Mod 包名必须按照 RQAlpha 的规范来命名,具体规则如下
                    *   必须以 `rqalpha-mod-` 来开头,比如 `rqalpha-mod-xxx-yyy`
                    *   对应import的库名必须要 `rqalpha_mod_` 来开头,并且需要和包名后半部分一致,但是 `-` 需要替换为 `_`, 比如 `rqalpha_mod_xxx_yyy`
                """
                mod_name = _detect_package_name_from_dir()
                mod_name = mod_name.replace("-",
                                            "_").replace("rqalpha_mod_", "")
                mod_list.append(mod_name)

            for mod_name in mod_list:
                if "rqalpha_mod_" in mod_name:
                    mod_name = mod_name.replace("rqalpha_mod_", "")
                if "==" in mod_name:
                    mod_name = mod_name.split('==')[0]
                user_conf['mod'][mod_name] = {}
                user_conf['mod'][mod_name]['enabled'] = False

            dump_config(user_mod_conf_path(), user_conf)

        return installed_result
Exemplo n.º 27
0
def remove_dist(dist):
    pip_main(['uninstall', '-y', dist.project_name])
    # Avoid duplicate output caused by pip.logger.consumers being configured
    # over and over again
    pip_logger.consumers = []
Exemplo n.º 28
0
        'pysolr==3.3.0',
        'pilbox==1.0.3',
        'wsgiref==0.1.2',
        'Logbook==0.6.0',
        'amara',
        'akara',
        'python-dateutil==2.2',
        'CouchDB==0.9',
        'redis>=2.10.1',
        'rq',
        'boto',
        'md5s3stash',
        'pymarc==3.0.4',
        'facet_decade',
        'redis_collections',
        'xmljson',
        'UCLDC-Deep-Harvester',
        'boto3',
        'pynux',
        'mediajson'
        ],
    test_suite='test',
    tests_require=['mock>=1.0.1', 'httpretty>=0.8.3', ],
)

pip_main(['install', 'ansible'])
#pip_main(['install',
#'git+https://github.com/ucldc/pynux.git@b539959ac11caa6fec06f59a0b3768d97bec2693'])
###pip_main(['install',
###         'git+ssh://[email protected]/mredar/dpla-ingestion.git@ucldc'])
Exemplo n.º 29
0
def pip_install(*packages):
    for package in packages:
        pip_main(['install', package])
    return True
Exemplo n.º 30
0
        # python 2 doesn't
        else:
            shutil_copy(src, dest)

    #set up PyQt5?
    print("Do You want to install PyQt5 (latest version of Qt needed to run \
graphical interface to SpectrumTranslate)? (y/n/q)")
    while(True):
        c = getch()
        if(c == b'n' or c == b'N' or c == 'n' or c == 'N'):
            break
        if(c == b'q' or c == b'Q' or c == 'q' or c == 'Q'):
            quit()
        if(c == b'y' or c == b'Y' or c == 'y' or c == 'Y'):
            print()
            pip_main(['install', 'PyQt5'])
            break

    #set up packages needed for development?
    print("\nDo You want to install pep8 and pillow (Only required if running \
development tests)? (y/n/q)")
    while(True):
        c = getch()
        if(c == b'n' or c == b'N' or c == 'n' or c == 'N'):
            break
        if(c == b'q' or c == b'Q' or c == 'q' or c == 'Q'):
            quit()
        if(c == b'y' or c == b'Y' or c == 'y' or c == 'Y'):
            print()
            pip_main(['install', 'pep8'])
            pip_main(['install', 'pillow'])
Exemplo n.º 31
0
from setuptools import setup, Extension
from wheel.bdist_wheel import bdist_wheel as native_bdist_wheel
import os
import subprocess
import platform
import re
try:
    from pip import main as pip_main
except:
    from pip._internal import main as pip_main

try:
    from Cython.Build.Distutils import build_ext as native_build_ext
except ImportError:
    print('Suitable Cython unavailable, installing...')
    pip_main(['install', 'cython'])
    from Cython.Build.Distutils import build_ext as native_build_ext

try:
    import numpy as np
except ImportError:
    print('Suitable numpy unavailable, installing...')
    pip_main(['install', 'numpy'])
    import numpy as np


include_dirs = [np.get_include()]

with open('README.rst') as readme_file:
    readme = readme_file.read()
Exemplo n.º 32
0
from setuptools import setup, find_packages
from os import path
try:
    from jupyterpip import cmdclass
except:
    try:
        from pip import main as pip_main
    except:
        from pip._internal import main as pip_main
    import importlib
    pip_main(['install', 'jupyter-pip'])
    cmdclass = importlib.import_module('jupyterpip').cmdclass

here = path.abspath(path.dirname(__file__))

# Get the long description from the relevant file
with open(path.join(here, 'README.rst')) as f:
        long_description = f.read()

packages = find_packages()

setup(
    name='PyscesToolbox',
    version='0.8.9post2',
    packages=packages,
    url='https://github.com/PySCeS/PyscesToolbox',
    download_url='http://github.com/PySCeS/PyscesToolbox/archive/0.8.9.tar.gz',
    license='BSD-3-Clause',
    author='Carl Christensen',
    author_email='*****@*****.**',
    description='A set of metabolic model analysis tools for PySCeS.',
Exemplo n.º 33
0
    from pip._internal import main as pip_main
if not inspect.isfunction(pip_main):
    pip_main = pip_main.main

sys.path.insert(0, os.path.abspath(".."))

# install 'openapi_client_udm' package from test-pypi to be able to build
# Python module doc
try:
    import openapi_client_udm  # isort:skip
except ImportError:
    print("Installing 'openapi_client_udm' package from test-pypi...")
    pip_main([
        "install",
        "--compile",
        "--upgrade",
        "--index-url",
        "https://test.pypi.org/simple/",
        "openapi-client-udm",
    ])

from udm_rest_client import __version__  # isort:skip

# -- General configuration ---------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
Exemplo n.º 34
0
def install(module):
    spam_spec = find_spec(module)
    found = spam_spec is not None
    if not found:
        pip_main(['install', module])
Exemplo n.º 35
0
def main(*args, **kwargs):
    install_pip_patches()
    return pip_main(*args, **kwargs)
Exemplo n.º 36
0
''' setup.py '''

# Verify the latest pip version
from os import system
system('pip install --upgrade pip')

# install required packages from PyPI
from pip import main as pip_main
pip_req = ['matplotlib', 'numpy', 'pandas', 'seaborn', 'scipy']
pip_main(['install'] + pip_req)

# set "develop" option
import setuptools

from glob import glob
from numpy.distutils.core import Extension, setup
from os.path import join

name = 'pyigrf'
sourcePath = 'source'
extra_compile_args = []
extra_f77_compile_args = ['-w', '-fno-align-commons']
ext = []

modName = 'get_igrf'
igrfSource = ['get_igrf.pyf', 'get_igrf.for', 'igrf_sub.for']
sources = []
for src in igrfSource:
    sources.append(join(sourcePath, src))
ext.append(
    Extension(name=modName,
Exemplo n.º 37
0
 def _pip_install_helper(package_names):
     for package in package_names:
         pip_main(['install', '-q', package])
#!/usr/bin/env python
if __name__ == '__main__':
    import os
    import sys

    if sys.version_info[0:2] < (3, 4):
        raise SystemExit('python 3.4+ is required')

    try:
        import mtp_common

        if mtp_common.VERSION < (5,):
            raise ImportError
    except ImportError:
        try:
            from pip import main as pip_main
        except ImportError:
            raise SystemExit('setuptools and pip are required')

        print('Pre-installing MTP-common')
        pip_main(['--quiet', 'install', '--upgrade', 'money-to-prisoners-common'])

    from mtp_common.build_tasks.executor import Executor

    exit(Executor(root_path=os.path.dirname(__file__)).run())