From 2f074ecd262878ecae04897473c1c76df341efa6 Mon Sep 17 00:00:00 2001 From: kakashi Date: Mon, 13 Nov 2017 00:01:30 +0800 Subject: [PATCH] Solve dependency issues [Why] When we perform `pip install https://github.com/pdollar/coco.git#subdirectory=PythonAPI`, it requires `matplotlib` and `cython` package. Although we put cython in our requirements.txt, sadly `pip install -r requirements` doesn't follow the speficied order according to https://stackoverflow.com/questions/5394356/how-to-specify-install-order-for-python-pip I wanna change setup.py to install coco python api along with cython. [How] According to https://stackoverflow.com/questions/37471313/setup-requires-with-cython, we can use `setuptools` to speficy cython as setup_requires and it will deal with `*.pyx` automatically --- PythonAPI/setup.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/PythonAPI/setup.py b/PythonAPI/setup.py index eb3d508..dbf0093 100644 --- a/PythonAPI/setup.py +++ b/PythonAPI/setup.py @@ -1,6 +1,4 @@ -from distutils.core import setup -from Cython.Build import cythonize -from distutils.extension import Extension +from setuptools import setup, Extension import numpy as np # To compile and install locally run "python setup.py build_ext --inplace" @@ -15,10 +13,15 @@ ext_modules = [ ) ] -setup(name='pycocotools', - packages=['pycocotools'], - package_dir = {'pycocotools': 'pycocotools'}, - version='2.0', - ext_modules= - cythonize(ext_modules) - ) \ No newline at end of file +setup( + name='pycocotools', + packages=['pycocotools'], + package_dir = {'pycocotools': 'pycocotools'}, + install_requires=[ + 'setuptools>=18.0', + 'cython>=0.27.3', + 'matplotlib>=2.1.0' + ], + version='2.0', + ext_modules= ext_modules +) -- GitLab