コード例 #1
0
def test_fix_activate_path():
    deployment = Deployment('test')
    temp = tempfile.NamedTemporaryFile()

    with open(temp.name, 'w') as fh:
        fh.write(textwrap.dedent("""
            other things

            VIRTUAL_ENV="/this/path/is/wrong/and/longer/than/new/path"

            more other things
        """))

    expected = textwrap.dedent("""
        other things

        VIRTUAL_ENV="/usr/share/python/test"

        more other things
    """)

    with patch('dh_virtualenv.deployment.os.path.join',
               return_value=temp.name):
        deployment.fix_activate_path()

    with open(temp.name) as fh:
        eq_(expected, temp.read())
コード例 #2
0
def test_fix_activate_path():
    deployment = Deployment('test')
    temp = tempfile.NamedTemporaryFile()

    with open(temp.name, 'w') as fh:
        fh.write(
            textwrap.dedent("""
            other things

            VIRTUAL_ENV="/this/path/is/wrong/and/longer/than/new/path"

            more other things
        """))

    expected = textwrap.dedent("""
        other things

        VIRTUAL_ENV="/usr/share/python/test"

        more other things
    """)

    with patch('dh_virtualenv.deployment.os.path.join',
               return_value=temp.name):
        deployment.fix_activate_path()

    with open(temp.name) as fh:
        eq_(expected, temp.read())
コード例 #3
0
        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
        shutil.rmtree(local_dir)

    sys.exit(0)