コード例 #1
0
def test_create_venv_with_verbose(callmock):
    d = Deployment('test', verbose=True)
    d.create_virtualenv()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 '--verbose',
                                 'debian/test/opt/venvs/test'])
コード例 #2
0
def test_venv_with_custom_python(callmock):
    d = Deployment('test', python='/tmp/python')
    d.create_virtualenv()
    eq_(TEST_VENV_PATH, d.package_dir)
    callmock.assert_called_with(['virtualenv', '--python', '/tmp/python', TEST_VENV_PATH])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', LOG_ARG], d.pip_args)
コード例 #3
0
def test_custom_src_dir(callmock):
    d = Deployment("test")
    d.pip_prefix = ["pip", "install"]
    d.sourcedirectory = "root/srv/application"
    d.create_virtualenv()
    d.install_dependencies()
    callmock.assert_called_with(
        [
            "debian/test/usr/share/python/test/bin/python",
            "debian/test/usr/share/python/test/bin/pip",
            "install",
            "--log=foo",
            "-r",
            "root/srv/application/requirements.txt",
        ]
    )
    d.install_package()
    callmock.assert_called_with(
        [
            "debian/test/usr/share/python/test/bin/python",
            "debian/test/usr/share/python/test/bin/pip",
            "install",
            "--log=foo",
            "root/srv/application",
        ]
    )
コード例 #4
0
def test_create_venv_with_setuptools(callmock):
    d = Deployment('test', setuptools=True)
    d.create_virtualenv()
    eq_(TEST_VENV_PATH, d.package_dir)
    callmock.assert_called_with(['virtualenv', '--setuptools', TEST_VENV_PATH])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', LOG_ARG], d.pip_args)
コード例 #5
0
def test_create_venv_with_verbose(callmock):
    d = Deployment('test', verbose=True)
    d.create_virtualenv()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 '--verbose',
                                 'debian/test/opt/venvs/test'])
コード例 #6
0
def test_create_venv_with_extra_virtualenv(callmock):
    d = Deployment('test', extra_virtualenv_arg=["--never-download"])
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 '--never-download',
                                 'debian/test/usr/share/python/test'])
コード例 #7
0
def test_create_venv_with_extra_virtualenv(callmock):
    d = Deployment('test', extra_virtualenv_arg=["--never-download"])
    d.create_virtualenv()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 '--never-download',
                                 'debian/test/opt/venvs/test'])
コード例 #8
0
def test_create_venv_with_system_packages(callmock):
    d = Deployment('test', use_system_packages=True)
    d.create_virtualenv()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--system-site-packages',
                                 'debian/test/opt/venvs/test'])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', LOG_ARG], d.pip_args)
コード例 #9
0
def test_create_venv_with_extra_pip_arg(callmock):
    d = Deployment('test', extra_pip_arg=['--no-compile'])
    d.create_virtualenv()
    d.install_dependencies()
    eq_(TEST_VENV_PATH, d.package_dir)
    callmock.assert_called_with(['virtualenv', TEST_VENV_PATH])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', LOG_ARG, '--no-compile'], d.pip_args)
コード例 #10
0
def test_create_venv_with_extra_urls(callmock):
    d = Deployment('test', extra_urls=['foo', 'bar'])
    d.create_virtualenv()
    eq_(TEST_VENV_PATH, d.package_dir)
    callmock.assert_called_with(['virtualenv', TEST_VENV_PATH])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', '--extra-index-url=foo', '--extra-index-url=bar', LOG_ARG],
        d.pip_args)
コード例 #11
0
def test_create_venv_with_system_packages(callmock):
    d = Deployment('test', use_system_packages=True)
    d.create_virtualenv()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(
        ['virtualenv', '--system-site-packages', 'debian/test/opt/venvs/test'])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', LOG_ARG], d.pip_args)
コード例 #12
0
def test_create_venv_with_extra_pip_arg(callmock):
    d = Deployment('test', extra_pip_arg=['--no-compile'])
    d.create_virtualenv()
    d.install_dependencies()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(
        ['virtualenv', '--no-site-packages', 'debian/test/opt/venvs/test'])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', LOG_ARG, '--no-compile'], d.pip_args)
コード例 #13
0
def test_create_venv_with_extra_urls(callmock):
    d = Deployment('test', extra_urls=['foo', 'bar'])
    d.create_virtualenv()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(
        ['virtualenv', '--no-site-packages', 'debian/test/opt/venvs/test'])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', '--extra-index-url=foo', '--extra-index-url=bar', LOG_ARG],
        d.pip_args)
コード例 #14
0
def test_venv_with_custom_python(callmock):
    d = Deployment('test', python='/tmp/python')
    d.create_virtualenv()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 '--python', '/tmp/python',
                                 'debian/test/opt/venvs/test'])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', LOG_ARG], d.pip_args)
コード例 #15
0
def test_create_venv_with_extra_pip_arg(callmock):
    d = Deployment('test', extra_pip_arg=['--no-compile'])
    d.create_virtualenv()
    d.install_dependencies()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 'debian/test/opt/venvs/test'])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', LOG_ARG, '--no-compile'], d.pip_args)
コード例 #16
0
def test_create_venv(callmock):
    d = Deployment('test')
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with([
        'virtualenv', '--no-site-packages', 'debian/test/usr/share/python/test'
    ])
    eq_([PY_CMD, PIP_CMD, 'install', '--log=' + os.path.abspath('foo')],
        d.pip_prefix)
コード例 #17
0
def test_venv_with_custom_python(callmock):
    d = Deployment('test', python='/tmp/python')
    d.create_virtualenv()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 '--python', '/tmp/python',
                                 'debian/test/opt/venvs/test'])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', LOG_ARG], d.pip_args)
コード例 #18
0
def test_create_venv_with_extra_urls(callmock):
    d = Deployment('test', extra_urls=['foo', 'bar'])
    d.create_virtualenv()
    eq_('debian/test/opt/venvs/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 'debian/test/opt/venvs/test'])
    eq_([PY_CMD, PIP_CMD], d.pip_prefix)
    eq_(['install', '--extra-index-url=foo',
         '--extra-index-url=bar',
         LOG_ARG], d.pip_args)
コード例 #19
0
def test_create_builtin_venv_with_unsupported_options(callmock):
    d = Deployment('test',
                   python='python_interpreter',
                   builtin_venv=True,
                   setuptools=True,
                   verbose=True)
    d.create_virtualenv()
    eq_(TEST_VENV_PATH, d.package_dir)
    callmock.assert_called_with(
        ['python_interpreter', '-m', 'venv', TEST_VENV_PATH])
コード例 #20
0
def test_create_venv_with_system_packages(callmock):
    d = Deployment('test', use_system_packages=True)
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--system-site-packages',
                                 'debian/test/usr/share/python/test'])
    eq_([PY_CMD,
         PIP_CMD,
         'install',
         '--log=' + os.path.abspath('foo')], d.pip_prefix)
コード例 #21
0
def test_create_venv(callmock):
    d = Deployment('test')
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 'debian/test/usr/share/python/test'])
    eq_(['debian/test/usr/share/python/test/bin/python',
         'debian/test/usr/share/python/test/bin/pip',
         'install',
         '--log=foo'], d.pip_prefix)
コード例 #22
0
def test_create_venv_with_extra_urls(callmock):
    d = Deployment('test', extra_urls=['foo', 'bar'])
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 'debian/test/usr/share/python/test'])
    eq_(['debian/test/usr/share/python/test/bin/python',
         'debian/test/usr/share/python/test/bin/pip',
         'install', '--extra-index-url=foo',
         '--extra-index-url=bar',
         '--log=foo'], d.pip_prefix)
コード例 #23
0
def test_venv_with_custom_python(callmock):
    d = Deployment('test', python='/tmp/python')
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 '--python', '/tmp/python',
                                 'debian/test/usr/share/python/test'])
    eq_([PY_CMD,
         PIP_CMD,
         'install',
         '--log=' + os.path.abspath('foo')], d.pip_prefix)
コード例 #24
0
def test_create_venv(callmock):
    d = Deployment('test')
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with([
        'virtualenv', '--no-site-packages', 'debian/test/usr/share/python/test'
    ])
    eq_([
        'debian/test/usr/share/python/test/bin/python',
        'debian/test/usr/share/python/test/bin/pip', 'install', '--log=foo'
    ], d.pip_prefix)
コード例 #25
0
def test_create_venv_with_extra_urls(callmock):
    d = Deployment('test', extra_urls=['foo', 'bar'])
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with([
        'virtualenv', '--no-site-packages', 'debian/test/usr/share/python/test'
    ])
    eq_([
        'debian/test/usr/share/python/test/bin/python',
        'debian/test/usr/share/python/test/bin/pip', 'install',
        '--extra-index-url=foo', '--extra-index-url=bar', '--log=foo'
    ], d.pip_prefix)
コード例 #26
0
def test_create_venv_with_extra_pip_arg(callmock):
    d = Deployment('test', extra_pip_arg=['--no-compile'])
    d.create_virtualenv()
    d.install_dependencies()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 'debian/test/usr/share/python/test'])
    eq_([PY_CMD,
         PIP_CMD,
         'install',
         '--log=' + os.path.abspath('foo'),
         '--no-compile'], d.pip_prefix)
コード例 #27
0
def test_create_venv_with_extra_pip_arg(callmock):
    d = Deployment('test', extra_pip_arg=['--no-compile'])
    d.create_virtualenv()
    d.install_dependencies()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with([
        'virtualenv', '--no-site-packages', 'debian/test/usr/share/python/test'
    ])
    eq_([
        PY_CMD, PIP_CMD, 'install', '--log=' + os.path.abspath('foo'),
        '--no-compile'
    ], d.pip_prefix)
コード例 #28
0
def test_create_venv_with_custom_index_url(callmock):
    d = Deployment('test', extra_urls=['foo', 'bar'],
                   pypi_url='http://example.com/simple')
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with(['virtualenv', '--no-site-packages',
                                 'debian/test/usr/share/python/test'])
    eq_(['debian/test/usr/share/python/test/bin/python',
         'debian/test/usr/share/python/test/bin/pip',
         'install',
         '--pypi-url=http://example.com/simple',
         '--extra-index-url=foo',
         '--extra-index-url=bar',
         '--log=foo'], d.pip_prefix)
コード例 #29
0
def test_create_venv_with_custom_index_url(callmock):
    d = Deployment('test',
                   extra_urls=['foo', 'bar'],
                   pypi_url='http://example.com/simple')
    d.create_virtualenv()
    eq_('debian/test/usr/share/python/test', d.package_dir)
    callmock.assert_called_with([
        'virtualenv', '--no-site-packages', 'debian/test/usr/share/python/test'
    ])
    eq_([
        PY_CMD, PIP_CMD, 'install', '--pypi-url=http://example.com/simple',
        '--extra-index-url=foo', '--extra-index-url=bar',
        '--log=' + os.path.abspath('foo')
    ], d.pip_prefix)
コード例 #30
0
def test_create_venv(callmock):
    d = Deployment("test")
    d.create_virtualenv()
    eq_("debian/test/usr/share/python/test", d.package_dir)
    callmock.assert_called_with(["virtualenv", "--no-site-packages", "debian/test/usr/share/python/test"])
    eq_(
        [
            "debian/test/usr/share/python/test/bin/python",
            "debian/test/usr/share/python/test/bin/pip",
            "install",
            "--log=foo",
        ],
        d.pip_prefix,
    )
コード例 #31
0
def test_create_venv_with_custom_index_url(callmock):
    d = Deployment("test", extra_urls=["foo", "bar"], pypi_url="http://example.com/simple")
    d.create_virtualenv()
    eq_("debian/test/usr/share/python/test", d.package_dir)
    callmock.assert_called_with(["virtualenv", "--no-site-packages", "debian/test/usr/share/python/test"])
    eq_(
        [
            "debian/test/usr/share/python/test/bin/python",
            "debian/test/usr/share/python/test/bin/pip",
            "install",
            "--pypi-url=http://example.com/simple",
            "--extra-index-url=foo",
            "--extra-index-url=bar",
            "--log=foo",
        ],
        d.pip_prefix,
    )
コード例 #32
0
def test_custom_src_dir(callmock):
    d = Deployment('test')
    d.sourcedirectory = 'root/srv/application'
    d.create_virtualenv()
    d.install_dependencies()
    callmock.assert_called_with([
        PY_CMD, PIP_CMD, 'install', LOG_ARG, '-r',
        'root/srv/application/requirements.txt'
    ], )
    d.install_package()
    callmock.assert_called_with([
        PY_CMD,
        PIP_CMD,
        'install',
        LOG_ARG,
        '.',
    ],
                                cwd=os.path.abspath('root/srv/application'))
コード例 #33
0
def test_custom_src_dir(callmock):
    d = Deployment('test')
    d.pip_prefix = ['pip', 'install']
    d.sourcedirectory = 'root/srv/application'
    d.create_virtualenv()
    d.install_dependencies()
    callmock.assert_called_with([
        'debian/test/usr/share/python/test/bin/python',
        'debian/test/usr/share/python/test/bin/pip', 'install', '--log=foo',
        '-r', 'root/srv/application/requirements.txt'
    ], )
    d.install_package()
    callmock.assert_called_with([
        'debian/test/usr/share/python/test/bin/python',
        'debian/test/usr/share/python/test/bin/pip',
        'install',
        '--log=foo',
        'root/srv/application',
    ])
コード例 #34
0
def test_custom_src_dir(callmock):
    d = Deployment('test')
    d.sourcedirectory = 'root/srv/application'
    d.create_virtualenv()
    d.install_dependencies()
    callmock.assert_called_with([
        PY_CMD,
        PIP_CMD,
        'install',
        LOG_ARG,
        '-r',
        'root/srv/application/requirements.txt'],
    )
    d.install_package()
    callmock.assert_called_with([
        PY_CMD,
        PIP_CMD,
        'install',
        LOG_ARG,
        '.',
    ], cwd=os.path.abspath('root/srv/application'))
コード例 #35
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
def test_custom_src_dir(callmock):
    d = Deployment('test')
    d.pip_prefix = ['pip', 'install']
    d.sourcedirectory = 'root/srv/application'
    d.create_virtualenv()
    d.install_dependencies()
    callmock.assert_called_with([
        'debian/test/usr/share/python/test/bin/python',
        'debian/test/usr/share/python/test/bin/pip',
        'install',
        '--log=foo',
        '-r',
        'root/srv/application/requirements.txt'],
    )
    d.install_package()
    callmock.assert_called_with([
        'debian/test/usr/share/python/test/bin/python',
        'debian/test/usr/share/python/test/bin/pip',
        'install',
        '--log=foo',
        'root/srv/application',
    ])
コード例 #36
0
    deploy = Deployment(
        package=os.path.basename(root_dir),
        requirements_filename=args.requirements,
        upgrade_pip=True,
        pip_version="10.0.1",
        use_system_packages=args.use_system_packages,
        python=python_executable,
        extra_pip_arg=['-qq'],
        log_file=None,
        # TODO(pbovbel) Builtin venv (python3-venv) is not available on trusty. This flag can be re-enabled when
        # trusty support is dropped.
        # builtin_venv=args.python3,
    )

    print('Generating virtualenv in {}'.format(deploy.package_dir))
    deploy.create_virtualenv()

    print('Installing requirements')
    deploy.install_dependencies()

    print('Fixing virtualenv root to {}'.format(deploy.virtualenv_install_dir))
    deploy.fix_activate_path()
    deploy.fix_shebangs()
    deploy.fix_local_symlinks()

    # Remove all .py[co] files since they embed absolute paths
    delete_bytecode(deploy.package_dir)

    local_dir = os.path.join(deploy.package_dir, 'local')
    if os.path.exists(local_dir):
        # Remove local folder
コード例 #37
0
def test_create_venv(callmock):
    d = Deployment('test')
    d.create_virtualenv()
    eq_(TEST_VENV_PATH, d.package_dir)
    callmock.assert_called_with(['virtualenv', TEST_VENV_PATH])
コード例 #38
0
def test_create_venv_with_verbose(callmock):
    d = Deployment('test', verbose=True)
    d.create_virtualenv()
    eq_(TEST_VENV_PATH, d.package_dir)
    callmock.assert_called_with(['virtualenv', '--verbose', TEST_VENV_PATH])
コード例 #39
0
def test_create_venv_with_extra_virtualenv(callmock):
    d = Deployment('test', extra_virtualenv_arg=["--never-download"])
    d.create_virtualenv()
    eq_(TEST_VENV_PATH, d.package_dir)
    callmock.assert_called_with(
        ['virtualenv', '--never-download', TEST_VENV_PATH])