From 33efa88f8fabd3809718513cbaf415a5b3b2d553 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sat, 3 Jul 2021 08:18:33 +0200 Subject: Read requirement files recursively. Normalize and deduplicate items. --- setup.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index c8372146b..458b5bfe7 100644 --- a/setup.py +++ b/setup.py @@ -63,13 +63,17 @@ def get_requirements(file: Path) -> List[str]: requirements = [] with file.open("r") as fh: for line in fh.readlines(): - if line.startswith("#"): + line = line.strip() + if line.startswith("#") or line == "": continue + elif line.startswith("-r"): + filename = line[3:].strip() + requirements += get_requirements(file.parent / filename) elif line.startswith("https"): - _splitItems = line.strip().split("#") + _splitItems = line.split("#") requirements.append("{} @ {}".format(_splitItems[1], _splitItems[0])) else: - requirements.append(line.strip()) + requirements.append(line) return requirements @@ -96,6 +100,8 @@ documentationURL = ( namespace=gitHubNamespace, projectName=projectName ) ) +requirements = list(set(get_requirements(requirementsFile))) + # Assemble all package information setuptools_setup( @@ -114,7 +120,7 @@ setuptools_setup( "Issue Tracker": sourceCodeURL + "/issues", }, python_requires=">=3.6", - install_requires=get_requirements(requirementsFile), + install_requires=requirements, packages=setuptools_find_packages(exclude=("tests",)), entry_points={ "console_scripts": [ -- cgit v1.2.3