summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShahwat Dalal <sdalal29@bloomberg.net>2019-04-23 09:45:21 +0100
committerChandan Singh <chandan@chandansingh.net>2019-05-14 22:50:59 +0000
commitf79351d65c99757ba5f7806e4b0d9c706fca518e (patch)
tree9673b52c754e205619d89138afc6bd99afaa0e11
parenteb9f7a8ce0f98a46a32a0a3c41939308e72aaa30 (diff)
downloadbuildstream-f79351d65c99757ba5f7806e4b0d9c706fca518e.tar.gz
tests: Allow `python_repo` to install nested package deps
In order to ensure that pip_source is pulling transitive dependencies, adapted python_repo to use `install_reqiures` in its default setup script.
-rw-r--r--tests/integration/pip_source.py26
-rw-r--r--tests/testutils/python_repo.py14
2 files changed, 28 insertions, 12 deletions
diff --git a/tests/integration/pip_source.py b/tests/integration/pip_source.py
index 645dad444..ed71636b2 100644
--- a/tests/integration/pip_source.py
+++ b/tests/integration/pip_source.py
@@ -26,13 +26,18 @@ def test_pip_source_import(cli, datafiles, setup_pypi_repo):
element_name = 'pip/hello.bst'
# check that exotically named packages are imported correctly
- myreqs_packages = ['hellolib']
- packages = ['app2', 'app.3', 'app-4', 'app_5', 'app.no.6', 'app-no-7', 'app_no_8']
+ myreqs_packages = 'hellolib'
+ 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
+ }
+ }
# create mock pypi repository
pypi_repo = os.path.join(project, 'files', 'pypi-repo')
os.makedirs(pypi_repo, exist_ok=True)
- setup_pypi_repo(myreqs_packages + packages, pypi_repo)
+ setup_pypi_repo(mock_packages, pypi_repo)
element = {
'kind': 'import',
@@ -45,7 +50,7 @@ def test_pip_source_import(cli, datafiles, setup_pypi_repo):
'kind': 'pip',
'url': 'file://{}'.format(os.path.realpath(pypi_repo)),
'requirements-files': ['myreqs.txt'],
- 'packages': packages
+ 'packages': [myreqs_packages]
}
]
}
@@ -80,13 +85,18 @@ def test_pip_source_build(cli, datafiles, setup_pypi_repo):
element_name = 'pip/hello.bst'
# check that exotically named packages are imported correctly
- myreqs_packages = ['hellolib']
- packages = ['app2', 'app.3', 'app-4', 'app_5', 'app.no.6', 'app-no-7', 'app_no_8']
+ myreqs_packages = 'hellolib'
+ 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
+ }
+ }
# create mock pypi repository
pypi_repo = os.path.join(project, 'files', 'pypi-repo')
os.makedirs(pypi_repo, exist_ok=True)
- setup_pypi_repo(myreqs_packages + packages, pypi_repo)
+ setup_pypi_repo(mock_packages, pypi_repo)
element = {
'kind': 'manual',
@@ -100,7 +110,7 @@ def test_pip_source_build(cli, datafiles, setup_pypi_repo):
'kind': 'pip',
'url': 'file://{}'.format(os.path.realpath(pypi_repo)),
'requirements-files': ['myreqs.txt'],
- 'packages': packages
+ 'packages': dependencies
}
],
'config': {
diff --git a/tests/testutils/python_repo.py b/tests/testutils/python_repo.py
index fcaf2d293..c8e5bf343 100644
--- a/tests/testutils/python_repo.py
+++ b/tests/testutils/python_repo.py
@@ -15,6 +15,7 @@ setup(
version='{version}',
description='{name}',
packages=['{pkgdirname}'],
+ install_requires={pkgdeps},
entry_points={{
'console_scripts': [
'{pkgdirname}={pkgdirname}:main'
@@ -56,7 +57,9 @@ HTML_TEMPLATE = '''\
# Returns:
# None
#
-def generate_pip_package(tmpdir, pypi, name, version='0.1'):
+def generate_pip_package(tmpdir, pypi, name, version='0.1', dependencies=None):
+ if dependencies is None:
+ dependencies = []
# check if package already exists in pypi
pypi_package = os.path.join(pypi, re.sub('[^0-9a-zA-Z]+', '-', name))
if os.path.exists(pypi_package):
@@ -77,7 +80,8 @@ def generate_pip_package(tmpdir, pypi, name, version='0.1'):
SETUP_TEMPLATE.format(
name=name,
version=version,
- pkgdirname=pkgdirname
+ pkgdirname=pkgdirname,
+ pkgdeps=dependencies
)
)
os.chmod(setup_file, 0o755)
@@ -125,8 +129,10 @@ def setup_pypi_repo(tmpdir):
return pkgdir
def add_packages(packages, pypi_repo):
- for package in packages:
+ for package, dependencies in packages.items():
pkgdir = create_pkgdir(package)
- generate_pip_package(pkgdir, pypi_repo, package)
+ generate_pip_package(pkgdir, pypi_repo, package, dependencies=list(dependencies.keys()))
+ for dependency, dependency_dependencies in dependencies.items():
+ add_packages({dependency: dependency_dependencies}, pypi_repo)
return add_packages