Пример #1
0
def test_parse_editable_local(isdir_mock, exists_mock, abspath_mock):
    exists_mock.return_value = isdir_mock.return_value = True
    # mocks needed to support path operations on windows tests
    abspath_mock.return_value = "/some/path"
    assert parse_editable(".", "git") == (None, "file:///some/path", None)
    abspath_mock.return_value = "/some/path/foo"
    assert parse_editable("foo", "git") == (None, "file:///some/path/foo", None)
Пример #2
0
def test_parse_editable_local(
        isdir_mock, exists_mock, abspath_mock):
    exists_mock.return_value = isdir_mock.return_value = True
    # mocks needed to support path operations on windows tests
    abspath_mock.return_value = "/some/path"
    assert parse_editable('.') == (None, 'file:///some/path', None)
    abspath_mock.return_value = "/some/path/foo"
    assert parse_editable('foo') == (
        None, 'file:///some/path/foo', None,
    )
Пример #3
0
def test_parse_editable_local(
        isdir_mock, exists_mock, getcwd_mock, normcase_mock):
    exists_mock.return_value = isdir_mock.return_value = True
    # mocks needed to support path operations on windows tests
    normcase_mock.return_value = getcwd_mock.return_value = "/some/path"
    assert parse_editable('.', 'git') == (None, 'file:///some/path', None, {})
    normcase_mock.return_value = "/some/path/foo"
    assert parse_editable('foo', 'git') == (
        None, 'file:///some/path/foo', None, {},
    )
def test_parse_editable_local(
        isdir_mock, exists_mock, getcwd_mock, normcase_mock):
    exists_mock.return_value = isdir_mock.return_value = True
    # mocks needed to support path operations on windows tests
    normcase_mock.return_value = getcwd_mock.return_value = "/some/path"
    assert parse_editable('.', 'git') == (None, 'file:///some/path', None)
    normcase_mock.return_value = "/some/path/foo"
    assert parse_editable('foo', 'git') == (
        None, 'file:///some/path/foo', None,
    )
Пример #5
0
def test_parse_editable_local_extras(
        isdir_mock, exists_mock, abspath_mock):
    exists_mock.return_value = isdir_mock.return_value = True
    abspath_mock.return_value = "/some/path"
    assert parse_editable('.[extras]') == (
        None, 'file://' + "/some/path", set(['extras']),
    )
    abspath_mock.return_value = "/some/path/foo"
    assert parse_editable('foo[bar,baz]') == (
        None, 'file:///some/path/foo', set(['bar', 'baz']),
    )
def test_parse_editable_local_extras(
        isdir_mock, exists_mock, getcwd_mock, normcase_mock):
    exists_mock.return_value = isdir_mock.return_value = True
    normcase_mock.return_value = getcwd_mock.return_value = "/some/path"
    assert parse_editable('.[extras]', 'git') == (
        None, 'file://' + "/some/path", ('extras',),
    )
    normcase_mock.return_value = "/some/path/foo"
    assert parse_editable('foo[bar,baz]', 'git') == (
        None, 'file:///some/path/foo', ('bar', 'baz'),
    )
Пример #7
0
def test_parse_editable_local_extras(
        isdir_mock, exists_mock, getcwd_mock, normcase_mock):
    exists_mock.return_value = isdir_mock.return_value = True
    normcase_mock.return_value = getcwd_mock.return_value = "/some/path"
    assert parse_editable('.[extras]', 'git') == (
        None, 'file://' + "/some/path", ('extras',), {},
    )
    normcase_mock.return_value = "/some/path/foo"
    assert parse_editable('foo[bar,baz]', 'git') == (
        None, 'file:///some/path/foo', ('bar', 'baz'), {},
    )
Пример #8
0
def test_parse_editable_local_extras(
        isdir_mock, exists_mock, abspath_mock):
    exists_mock.return_value = isdir_mock.return_value = True
    abspath_mock.return_value = "/some/path"
    assert parse_editable('.[extras]') == (
        None, 'file://' + "/some/path", set(['extras']),
    )
    abspath_mock.return_value = "/some/path/foo"
    assert parse_editable('foo[bar,baz]') == (
        None, 'file:///some/path/foo', set(['bar', 'baz']),
    )
Пример #9
0
def test_parse_editable_vcs_extras():
    assert parse_editable('svn+https://foo#egg=foo[extras]', 'git') == (
        'foo[extras]',
        'svn+https://foo#egg=foo[extras]',
        None,
        {'egg': 'foo[extras]'},
    )
Пример #10
0
def test_parse_editable_explicit_vcs():
    assert parse_editable('svn+https://foo#egg=foo', 'git') == (
        'foo',
        'svn+https://foo#egg=foo',
        None,
        {'egg': 'foo'},
    )
Пример #11
0
def test_parse_editable_default_vcs():
    assert parse_editable('https://foo#egg=foo', 'git') == (
        'foo',
        'git+https://foo#egg=foo',
        None,
        {'egg': 'foo'},
    )
Пример #12
0
def test_parse_editable_vcs_extras():
    assert parse_editable('svn+https://foo#egg=foo[extras]', 'git') == (
        'foo[extras]',
        'svn+https://foo#egg=foo[extras]',
        None,
        {'egg': 'foo[extras]'},
    )
Пример #13
0
def test_parse_editable_explicit_vcs():
    assert parse_editable('svn+https://foo#egg=foo', 'git') == (
        'foo',
        'svn+https://foo#egg=foo',
        None,
        {'egg': 'foo'},
    )
Пример #14
0
def test_parse_editable_default_vcs():
    assert parse_editable('https://foo#egg=foo', 'git') == (
        'foo',
        'git+https://foo#egg=foo',
        None,
        {'egg': 'foo'},
    )
Пример #15
0
def _install_deps(venv_prefix, filename):
    """"""
    reqs = []
    installed_locations = {
        x.key: x.location
        for x in get_installed_distributions()
    }
    with open(filename, 'r') as fp:
        for line in fp:
            line = line.strip()
            if not line or line.startswith('#'):
                continue
            if line.startswith('-i '):
                continue
            if line.startswith('-e'):
                # skip req if we have a local copy
                editable = parse_editable(line[3:])
                req_name = editable[0]
                url = editable[1]
                path = urlparse.urlsplit(url).path
                repo_name = path.rpartition('/')[-1]
                if repo_name.endswith('.git'):
                    repo_name = repo_name[:-4]
                local_checkout_path = os.path.join(ctx.conf.repos.root,
                                                   repo_name)
                if os.path.exists(local_checkout_path):
                    # we have a local checkout, check that it's what we use in our venv
                    installed_location = installed_locations.get(req_name)
                    if local_checkout_path == installed_location:
                        print '[refresh] info: using local checkout %s for %s' % (
                            local_checkout_path, req_name)
                        continue
                    else:
                        if installed_location is not None:
                            print '[refresh] notice: local checkout of %s exists in %s but another install is active in octools (%s)' % (
                                req_name, local_checkout_path,
                                installed_location)
            reqs.append(line)

    final_req_fname = os.path.join(ctx.conf.user.dotdir,
                                   'requirements.txt')  # FIXME(stf/oss)
    with open(final_req_fname, 'w') as fp:
        fp.write('\n'.join(reqs))

    command_line = [
        os.path.join(venv_prefix, 'pip'), 'install', '-r', final_req_fname
    ]
    env = {'PIP_EXISTS_ACTION': 's'}
    env.update(os.environ)
    try:
        subprocess.check_output(command_line,
                                env=env,
                                stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError as cpe:
        print "[refresh] %s failed:" % (' '.join(command_line))
        print cpe.output
        raise
Пример #16
0
def test_parse_editable_explicit_vcs():
    assert parse_editable("svn+https://foo#egg=foo", "git") == ("foo", "svn+https://foo#egg=foo", None)
Пример #17
0
def test_parse_editable_vcs_extras():
    assert parse_editable("svn+https://foo#egg=foo[extras]", "git") == (
        "foo[extras]",
        "svn+https://foo#egg=foo[extras]",
        None,
    )
Пример #18
0
def test_parse_editable_default_vcs():
    assert parse_editable("https://foo#egg=foo", "git") == ("foo", "git+https://foo#egg=foo", None)
Пример #19
0
def test_parse_editable_local_extras(isdir_mock, exists_mock, abspath_mock):
    exists_mock.return_value = isdir_mock.return_value = True
    abspath_mock.return_value = "/some/path"
    assert parse_editable(".[extras]", "git") == (None, "file://" + "/some/path", set(["extras"]))
    abspath_mock.return_value = "/some/path/foo"
    assert parse_editable("foo[bar,baz]", "git") == (None, "file:///some/path/foo", set(["bar", "baz"]))