diff options
author | Shahwat Dalal <sdalal29@bloomberg.net> | 2019-04-23 09:45:21 +0100 |
---|---|---|
committer | Chandan Singh <chandan@chandansingh.net> | 2019-05-14 22:50:59 +0000 |
commit | 27f4f3b7a2fd22c8c812f0f35b32426afe776444 (patch) | |
tree | b71a7ccd7183f182f35c02efaa6ffd996cbbb98f /tests/integration | |
parent | f79351d65c99757ba5f7806e4b0d9c706fca518e (diff) | |
download | buildstream-27f4f3b7a2fd22c8c812f0f35b32426afe776444.tar.gz |
pip_element: Install packages pulled by pip_source
In refrence to https://gitlab.com/BuildStream/buildstream/issues/589.
`pip.yaml` now installs pip packages from `/.bst_pip_downloads` if
the directory exists.
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/pip_element.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/integration/pip_element.py b/tests/integration/pip_element.py index 9ef163125..94130d9ab 100644 --- a/tests/integration/pip_element.py +++ b/tests/integration/pip_element.py @@ -6,6 +6,7 @@ from buildstream import _yaml from buildstream.testing import cli_integration as cli from buildstream.testing.integration import assert_contains +from tests.testutils import setup_pypi_repo from tests.testutils.site import HAVE_SANDBOX @@ -67,3 +68,64 @@ def test_pip_run(cli, datafiles): result = cli.run(project=project, args=['shell', element_name, '/usr/bin/hello']) assert result.exit_code == 0 assert result.output == 'Hello, world!\n' + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox') +def test_pip_element_should_install_pip_deps(cli, datafiles, setup_pypi_repo): + project = str(datafiles) + elements_path = os.path.join(project, 'elements') + element_name = 'pip/hello.bst' + + # check that exotically named packages are imported correctly + myreqs_packages = 'alohalib' + dependencies = ['app2', 'app.3', 'app-4', 'app_5', 'app.no.6', 'app-no-7', 'app_no_8'] + mock_packages = { + myreqs_packages: { + package: {} for package in dependencies + } + } + + # set up directories + pypi_repo = os.path.join(project, 'files', 'pypi-repo') + os.makedirs(pypi_repo, exist_ok=True) + os.makedirs(os.path.dirname(os.path.join(elements_path, element_name)), exist_ok=True) + setup_pypi_repo(mock_packages, pypi_repo) + + # create pip element + element = { + 'kind': 'pip', + 'variables': { + 'pip': 'pip3' + }, + 'depends': [{ + 'filename': 'base.bst' + }], + 'sources': [ + { + 'kind': 'tar', + 'url': 'file://{}/files/hello.tar.xz'.format(project), + # FIXME: remove hardcoded ref once issue #1010 is closed + 'ref': 'ad96570b552498807abec33c06210bf68378d854ced6753b77916c5ed517610d' + }, + { + 'kind': 'pip', + 'url': 'file://{}'.format(os.path.realpath(pypi_repo)), + 'packages': [myreqs_packages], + } + ] + } + _yaml.dump(element, os.path.join(elements_path, element_name)) + + result = cli.run(project=project, args=['source', 'track', element_name]) + assert result.exit_code == 0 + + result = cli.run(project=project, args=['build', element_name]) + assert result.exit_code == 0 + + # get installed packages in sandbox + installed_packages = set( + cli.run(project=project, args=['shell', element_name, 'pip3', 'freeze']).output.split('\n')) + # compare with packages that are expected to be installed + pip_source_packages = {package.replace('_', "-") + '==0.1' for package in dependencies + [myreqs_packages]} + assert pip_source_packages.issubset(installed_packages) |