From 5e69769a4b22e11e68e9674488d68818ff8207d3 Mon Sep 17 00:00:00 2001
From: Jerry Jiarui XU <xvjiarui0826@gmail.com>
Date: Sun, 12 Jul 2020 23:51:36 +0800
Subject: [PATCH] Update setup.py (#3293)

* Update setup.py

* update ci
---
 .github/workflows/build.yml | 1 -
 configs/lvis/README.md      | 4 ++++
 docs/install.md             | 2 --
 requirements/optional.txt   | 1 +
 requirements/runtime.txt    | 1 +
 setup.py                    | 2 ++
 6 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 38064c44..24b7e53d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -52,7 +52,6 @@ jobs:
         run: |
           pip install mmcv-full==latest+torch${{matrix.torch}}+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
           pip install -r requirements.txt
-          pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools"
       - name: Lint with flake8
         run: flake8 .
       - name: Lint with isort
diff --git a/configs/lvis/README.md b/configs/lvis/README.md
index a7059555..3539e5f9 100644
--- a/configs/lvis/README.md
+++ b/configs/lvis/README.md
@@ -16,6 +16,10 @@
     ```
     pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=lvis"
     ```
+    or 
+    ```
+    pip install -r requirements/optional.txt
+    ```
 * All experiments use oversample strategy [here](../../docs/tutorials/new_dataset.md#class-balanced-dataset) with oversample threshold `1e-3`.
 * The size of LVIS v0.5 is half of COCO, so schedule `2x` in LVIS is roughly the same iterations as `1x` in COCO.
 
diff --git a/docs/install.md b/docs/install.md
index 92f21728..b96cdaa5 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -74,7 +74,6 @@ for better compatibility with our repo.)
 
 ```shell
 pip install -r requirements/build.txt
-pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools"
 pip install -v -e .  # or "python setup.py develop"
 ```
 
@@ -152,7 +151,6 @@ pip install mmcv-full
 git clone https://github.com/open-mmlab/mmdetection.git
 cd mmdetection
 pip install -r requirements/build.txt
-pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools"
 pip install -v -e .
 ```
 
diff --git a/requirements/optional.txt b/requirements/optional.txt
index b34b112a..3c406c97 100644
--- a/requirements/optional.txt
+++ b/requirements/optional.txt
@@ -1,3 +1,4 @@
 albumentations>=0.3.2
 cityscapesscripts
 imagecorruptions
+lvis@git+https://github.com/open-mmlab/cocoapi.git#subdirectory=lvis
diff --git a/requirements/runtime.txt b/requirements/runtime.txt
index 800d1238..786c9065 100644
--- a/requirements/runtime.txt
+++ b/requirements/runtime.txt
@@ -6,3 +6,4 @@ six
 terminaltables
 torch>=1.3
 torchvision
+pycocotools@git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools
diff --git a/setup.py b/setup.py
index f67b36be..f26ad3b3 100755
--- a/setup.py
+++ b/setup.py
@@ -142,6 +142,8 @@ def parse_requirements(fname='requirements.txt', with_version=True):
             info = {'line': line}
             if line.startswith('-e '):
                 info['package'] = line.split('#egg=')[1]
+            elif '@git+' in line:
+                info['package'] = line
             else:
                 # Remove versioning from the package
                 pat = '(' + '|'.join(['>=', '==', '>']) + ')'
-- 
GitLab