From e2ee7714b23b636b20a43a9eecfcd570a647a5b5 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 22 Jun 2021 20:25:22 +0300 Subject: [PATCH] Reduce duplication of dependency information Currently, all runtime dependencies are listed in both `requirements.txt` and `setup.py`, except that they sometimes have differing version constraints. This is confusing and increases the amount of work a maintainer needs to do when updating the dependency list. Fix it by moving all runtime dependencies to a separate file (`requirements-core.txt`) and referencing that file from both `setup.py` and `requirements.txt`. Combine all version constraints from both original files. Unfortunately, some things still need to be duplicated: * The OpenCV dependency varies depending on environment variables, and that logic can't be replicated with a requirements file. So OpenCV has to be listed separately in `setup.py` and `requirements.txt`. * Cython is a build dependency, not a runtime dependency, so it shouldn't go into `requirements-core.txt`. It would technically be possible to move it to a separate requirements file and reference from there, but it's just one dependency, so it doesn't seem worth it. --- CHANGELOG.md | 1 + requirements-core.txt | 21 +++++++++++++++++++++ requirements.txt | 11 +---------- setup.py | 26 +++----------------------- 4 files changed, 26 insertions(+), 33 deletions(-) create mode 100644 requirements-core.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index da859b025e..39ef60adbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Tensorflow AVX check is made optional in API and is disabled by default () - Extensions for images in ImageNet_txt are now mandatory () +- Several dependencies now have lower bounds () ### Deprecated - diff --git a/requirements-core.txt b/requirements-core.txt new file mode 100644 index 0000000000..213867dc4d --- /dev/null +++ b/requirements-core.txt @@ -0,0 +1,21 @@ +attrs>=19.3.0 +defusedxml>=0.6.0 +GitPython>=3.0.8 +lxml>=4.4.1 +matplotlib>=3.3.1 +numpy>=1.17.3 +Pillow>=6.1.0 + +# Avoid 2.0.2 Linux binary distribution because of +# a conflict in numpy versions with TensorFlow: +# - TF is compiled with numpy 1.19 ABI +# - pycocotools is compiled with numpy 1.20 ABI +# Using a previous version allows to force package rebuilding. +# +# https://github.com/openvinotoolkit/datumaro/issues/253 +pycocotools>=2.0.0,!=2.0.2; platform_system != "Windows" + +pycocotools-windows; platform_system == "Windows" +PyYAML>=5.3.1 +scikit-image>=0.15.0 +tensorboardX>=1.8 diff --git a/requirements.txt b/requirements.txt index b5490d77d2..d2b25032ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,5 @@ -attrs>=19.3.0 Cython>=0.27.3 # include before pycocotools -defusedxml>=0.6.0 -GitPython>=3.0.8 -lxml>=4.4.1 -matplotlib>=3.3.1 +-r requirements-core.txt --no-binary=pycocotools # https://github.com/openvinotoolkit/datumaro/issues/253 opencv-python-headless>=4.1.0.25 -Pillow>=6.1.0 -pycocotools>=2.0.0 --no-binary=pycocotools # https://github.com/openvinotoolkit/datumaro/issues/253 -PyYAML>=5.3.1 -scikit-image>=0.15.0 -tensorboardX>=1.8 pandas>=1.1.5 pytest>=5.3.5 \ No newline at end of file diff --git a/setup.py b/setup.py index 68591d9242..a88778db61 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ -# Copyright (C) 2019-2020 Intel Corporation +# Copyright (C) 2019-2021 Intel Corporation # # SPDX-License-Identifier: MIT @@ -34,29 +34,9 @@ def find_version(project_dir=None): return version def get_requirements(): - requirements = [ - 'attrs>=19.3.0', - 'defusedxml', - 'GitPython', - 'lxml', - 'matplotlib', - 'numpy>=1.17.3', - 'Pillow', + with open('requirements-core.txt') as fh: + requirements = [fh.read()] - # Avoid 2.0.2 Linux binary distribution because of - # a conflict in numpy versions with TensorFlow: - # - TF is compiled with numpy 1.19 ABI - # - pycocotools is compiled with numpy 1.20 ABI - # Using a previous version allows to force package rebuilding. - # - # https://github.com/openvinotoolkit/datumaro/issues/253 - 'pycocotools!=2.0.2; platform_system != "Windows"', - 'pycocotools-windows; platform_system == "Windows"', - - 'PyYAML', - 'scikit-image', - 'tensorboardX', - ] if strtobool(os.getenv('DATUMARO_HEADLESS', '0').lower()): requirements.append('opencv-python-headless') else: