fix dependencies (#146)

* fix requirements

* don't reuse build dependencies between different envs

* minor fix

* change the order of opencv and opencv-headless
pull/143/head
Rinat Shigapov 2019-11-21 09:34:26 -06:00 committed by Kai Chen
parent b480ee475f
commit aea750051f
6 changed files with 47 additions and 10 deletions

6
.dockerignore 100644
View File

@ -0,0 +1,6 @@
.git
.gitignore
*.egg-info
.eggs/
.mypy-cache
pip-wheel-metadata

View File

@ -8,7 +8,7 @@ before_install:
- sudo apt-get install -y ffmpeg
install:
- pip install Cython opencv-python pyyaml codecov flake8 yapf isort
- rm -rf .eggs && pip install -e . codecov flake8 yapf isort
cache:
pip: true

7
Dockerfile 100644
View File

@ -0,0 +1,7 @@
FROM python:3.7
WORKDIR /mmcv
COPY . /mmcv
RUN pip install -e .

View File

@ -48,3 +48,7 @@ or install from source
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
pip install -e .
Note: If you would like to use :code:`opencv-python-headless` instead of :code:`opencv-python`,
e.g., in a minimum container environment or servers without GUI,
you can first install it before installing MMCV to skip the installation of :code:`opencv-python`.

View File

@ -1,6 +0,0 @@
addict
numpy>=1.11.1
pyyaml
six
requests
opencv-python

View File

@ -1,17 +1,43 @@
import platform
import re
import sys
from io import open # for Python 2 (identical to builtin in Python 3)
from setuptools import Extension, find_packages, setup, dist
from setuptools import Extension, dist, find_packages, setup
from pkg_resources import DistributionNotFound, get_distribution
dist.Distribution().fetch_build_eggs(['Cython', 'numpy>=1.11.1'])
import numpy # noqa: E402
from Cython.Distutils import build_ext # noqa: E402
def choose_requirement(primary, secondary):
"""If some version of primary requirement installed, return primary,
else return secondary.
"""
try:
name = re.split(r'[!<>=]', primary)[0]
get_distribution(name)
except DistributionNotFound:
return secondary
return str(primary)
install_requires = [
'numpy>=1.11.1', 'pyyaml', 'six', 'addict', 'requests', 'opencv-python',
'Cython'
'numpy>=1.11.1',
'pyyaml',
'six',
'addict',
'requests',
]
# If first not installed install second package
CHOOSE_INSTALL_REQUIRES = [('opencv-python-headless>=3', 'opencv-python>=3')]
for main, secondary in CHOOSE_INSTALL_REQUIRES:
install_requires.append(choose_requirement(main, secondary))
if sys.version_info < (3, 3):
install_requires.append('backports.shutil_get_terminal_size')
if sys.version_info < (3, 4):