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'])
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)
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", ] )
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)
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'])
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'])
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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])
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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, )
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, )
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'))
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', ])
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'))
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', ])
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
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])
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])
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])