the pip source plugin incorrectly search for a valid version

Summary

The pip source plugin search for a pip version with a whitelist of python versions (python2.7 to 3.7).

It does not however look for "python", which in some virtual environments (python3 -m venv in Ubuntu WSL).

Steps to reproduce

  • create a ubuntu wsl root, install only python3.
  • Create a venv: python3 -m venv
  • Run pytest tests/sources/pip.py in the venv

What is the current bug behavior?

one (unrelated) bug fails

What is the expected correct behavior?

The tests should pass

Relevant logs and/or screenshots

Without "python" in the list

bschubert15@PF16JAKX:buildstream@master[-3;*1]: buildstream (1) $ pytest tests/sources/pip.py  --no-cov --durations 1
==================================================================== test session starts ====================================================================platform linux -- Python 3.6.6, pytest-3.9.2, py-1.7.0, pluggy-0.8.0 -- /c/Users/SchubertBenjamin/Documents/git/buildstream/buildstream/venv/bin/python3
cachedir: .pytest_cache
rootdir: /c/Users/SchubertBenjamin/Documents/git/buildstream/buildstream, inifile: setup.cfg
plugins: xdist-1.23.2, timeout-1.3.2, pylint-0.12.3, pep8-1.0.6, forked-0.2, env-0.6.2, datafiles-2.0, cov-2.6.0
collected 13 items

tests/sources/pip.py PASSED                                                                                                                           [  7%]
tests/sources/pip.py::test_no_ref FAILED                                                                                                              [ 15%]
tests/sources/pip.py::test_first_source PASSED                                                                                                        [ 23%]
tests/sources/pip.py::test_no_packages PASSED                                                                                                         [ 30%]
tests/sources/pip.py::test_match_package_name[dotted.package-0.9.8.tar.gz-dotted.package-0.9.8] PASSED                                                [ 38%]
tests/sources/pip.py::test_match_package_name[hyphenated-package-2.6.0.tar.gz-hyphenated-package-2.6.0] PASSED                                        [ 46%]
tests/sources/pip.py::test_match_package_name[underscore_pkg-3.1.0.tar.gz-underscore_pkg-3.1.0] PASSED                                                [ 53%]
tests/sources/pip.py::test_match_package_name[numbers2and5-1.0.1.tar.gz-numbers2and5-1.0.1] PASSED                                                    [ 61%]
tests/sources/pip.py::test_match_package_name[multiple.dots.package-5.6.7.tar.gz-multiple.dots.package-5.6.7] PASSED                                  [ 69%]
tests/sources/pip.py::test_match_package_name[multiple-hyphens-package-1.2.3.tar.gz-multiple-hyphens-package-1.2.3] PASSED                            [ 76%]
tests/sources/pip.py::test_match_package_name[multiple_underscore_pkg-3.4.5.tar.gz-multiple_underscore_pkg-3.4.5] PASSED                              [ 84%]
tests/sources/pip.py::test_match_package_name[shortversion-1.0.tar.gz-shortversion-1.0] PASSED                                                        [ 92%]
tests/sources/pip.py::test_match_package_name[longversion-1.2.3.4.tar.gz-longversion-1.2.3.4] PASSED                                                  [100%]

========================================================================= FAILURES ==========================================================================________________________________________________________________________ test_no_ref ________________________________________________________________________
cli = <tests.testutils.runcli.Cli object at 0x7f9c5ca0de10>
tmpdir = local('/c/Users/SchubertBenjamin/Documents/git/buildstream/buildstream/tmp/test_no_ref0')
datafiles = local('/c/Users/SchubertBenjamin/Documents/git/buildstream/buildstream/tmp/test_no_ref0')

    @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-ref'))
    def test_no_ref(cli, tmpdir, datafiles):
        project = os.path.join(datafiles.dirname, datafiles.basename)
        generate_project(project, tmpdir)
>       assert cli.get_element_state(project, 'target.bst') == 'no reference'

tests/sources/pip.py:25:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _tests/testutils/runcli.py:354: in get_element_state
    result.assert_success()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.testutils.runcli.Result object at 0x7f9c5c6815c0>, fail_message = ''

    def assert_success(self, fail_message=''):
>       assert self.exit_code == 0, fail_message
E       AssertionError:
E       assert -1 == 0
E        +  where -1 = <tests.testutils.runcli.Result object at 0x7f9c5c6815c0>.exit_code

tests/testutils/runcli.py:82: AssertionError
------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------BuildStream exited with code -1 for invocation:
        bst --no-colors --no-verbose --config /c/Users/SchubertBenjamin/Documents/git/buildstream/buildstream/tmp/test_no_ref0/cache/buildstream.conf --directory /c/Users/SchubertBenjamin/Documents/git/buildstream/buildstream/tmp/test_no_ref0 show --deps none --format %{state} target.bst
Program stderr was:
[--:--:--][][] START   Loading elements
[00:00:00][][] SUCCESS Loading elements
[--:--:--][][] START   Resolving elements
[00:00:00][][] SUCCESS Resolving elements
[--:--:--][][] START   Resolving cached state
[00:00:00][][] FAILURE Resolving cached state

pip source at target.bst [line 6 column 2]: pip source at target.bst [line 6 column 2]: Unable to find a suitable pip command

WARNING: Coverage disabled via --no-cov switch!
================================================================= slowest 1 test durations ==================================================================0.48s call     tests/sources/pip.py::test_no_ref
===================================================================== warnings summary ======================================================================  Coverage disabled via --no-cov switch!

unknown file:0: RemovedInPytest4Warning: config.warn has been deprecated, use warnings.warn instead

-- Docs: https://docs.pytest.org/en/latest/warnings.html
====================================================== 1 failed, 12 passed, 2 warnings in 2.91 seconds ======================================================

With python in the list

bschubert15@PF16JAKX:buildstream@master[-3;*1]: buildstream (1) $ pytest tests/sources/pip.py  --no-cov --durations 1
==================================================================== test session starts ====================================================================platform linux -- Python 3.6.6, pytest-3.9.2, py-1.7.0, pluggy-0.8.0 -- /c/Users/SchubertBenjamin/Documents/git/buildstream/buildstream/venv/bin/python3
cachedir: .pytest_cache
rootdir: /c/Users/SchubertBenjamin/Documents/git/buildstream/buildstream, inifile: setup.cfg
plugins: xdist-1.23.2, timeout-1.3.2, pylint-0.12.3, pep8-1.0.6, forked-0.2, env-0.6.2, datafiles-2.0, cov-2.6.0
collected 13 items

tests/sources/pip.py PASSED                                                                                                                           [  7%]
tests/sources/pip.py::test_no_ref PASSED                                                                                                              [ 15%]
tests/sources/pip.py::test_first_source PASSED                                                                                                        [ 23%]
tests/sources/pip.py::test_no_packages PASSED                                                                                                         [ 30%]
tests/sources/pip.py::test_match_package_name[dotted.package-0.9.8.tar.gz-dotted.package-0.9.8] PASSED                                                [ 38%]
tests/sources/pip.py::test_match_package_name[hyphenated-package-2.6.0.tar.gz-hyphenated-package-2.6.0] PASSED                                        [ 46%]
tests/sources/pip.py::test_match_package_name[underscore_pkg-3.1.0.tar.gz-underscore_pkg-3.1.0] PASSED                                                [ 53%]
tests/sources/pip.py::test_match_package_name[numbers2and5-1.0.1.tar.gz-numbers2and5-1.0.1] PASSED                                                    [ 61%]
tests/sources/pip.py::test_match_package_name[multiple.dots.package-5.6.7.tar.gz-multiple.dots.package-5.6.7] PASSED                                  [ 69%]
tests/sources/pip.py::test_match_package_name[multiple-hyphens-package-1.2.3.tar.gz-multiple-hyphens-package-1.2.3] PASSED                            [ 76%]
tests/sources/pip.py::test_match_package_name[multiple_underscore_pkg-3.4.5.tar.gz-multiple_underscore_pkg-3.4.5] PASSED                              [ 84%]
tests/sources/pip.py::test_match_package_name[shortversion-1.0.tar.gz-shortversion-1.0] PASSED                                                        [ 92%]
tests/sources/pip.py::test_match_package_name[longversion-1.2.3.4.tar.gz-longversion-1.2.3.4] PASSED                                                  [100%]
WARNING: Coverage disabled via --no-cov switch!

================================================================= slowest 1 test durations ==================================================================3.96s call     tests/sources/pip.py::test_no_ref
===================================================================== warnings summary ======================================================================  Coverage disabled via --no-cov switch!

unknown file:0: RemovedInPytest4Warning: config.warn has been deprecated, use warnings.warn instead

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================================================== 13 passed, 2 warnings in 5.54 seconds ===========================================================

Possible fixes

  • add python to the list of python versions checked.

Other relevant information

  • BuildStream version affected: /milestone %BuildStream_v1.x

Edited by Benjamin Schubert
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information