Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhance] Support for installing minimal runtime dependencies #1362

Merged
merged 13 commits into from
Oct 8, 2023
27 changes: 27 additions & 0 deletions .circleci/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ jobs:
name: Run unit tests
command: pytest tests/test_config tests/test_registry tests/test_fileio tests/test_logging tests/test_utils --ignore=tests/test_utils/test_dl_utils

build_lite:
parameters:
# The python version must match available image tags in
# https://circleci.com/developer/images/image/cimg/python
python:
type: string
default: "3.7.4"
docker:
- image: cimg/python:<< parameters.python >>
resource_class: large
steps:
- checkout
- run:
name: Upgrade pip
command: |
pip install pip --upgrade
pip --version
- run:
name: Build MMEngine from source
command: MMENGINE_LITE=1 pip install -e -v
zhouzaida marked this conversation as resolved.
Show resolved Hide resolved
- run:
name: Install unit tests dependencies
command: pip install -r requirements/tests.txt
- run:
name: Run unit tests
command: pytest tests/test_config tests/test_registry tests/test_fileio tests/test_logging tests/test_utils --ignore=tests/test_utils/test_dl_utils

build_cpu:
parameters:
# The python version must match available image tags in
Expand Down
10 changes: 10 additions & 0 deletions docs/en/get_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ pip install -U openmim
mim install mmengine
```

If you only want to use fileio, registry and configs in MMEngine, you can install mmengine lite:

```bash
MMENGINE_LITE=1 mim install mmengine
```

### Install with pip

```bash
pip install mmengine
# MMENGINE_LITE=1 pip install mmengine
```

### Use docker images
Expand All @@ -64,6 +71,9 @@ pip install mmengine
git clone https://github.com/open-mmlab/mmengine.git
cd mmengine
pip install -e . -v

# If you only want to use fileio, registry and configs in MMEngine, you can install mmengine lite:
# MMENGINE_LITE=1 pip install -e . -v
```

### Verify the Installation
Expand Down
10 changes: 10 additions & 0 deletions docs/zh_cn/get_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ pip install -U openmim
mim install mmengine
```

如果你只想使用 MMEngine 中的 fileio、registry 和 configs,可以安装 mmengine lite:

```bash
MMENGINE_LITE=1 mim install mmengine
```

### 使用 pip 安装

```bash
pip install mmengine
# MMENGINE_LITE=1 pip install mmengine
```

### 使用 docker 镜像
Expand All @@ -64,6 +71,9 @@ pip install mmengine
git clone https://github.com/open-mmlab/mmengine.git
cd mmengine
pip install -e . -v

# If you only want to use fileio, registry and configs in MMEngine, you can install mmengine lite:
# MMENGINE_LITE=1 pip install -e . -v
```

## 验证安装
Expand Down
32 changes: 18 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import re
from setuptools import find_packages, setup # type: ignore

Expand Down Expand Up @@ -106,20 +107,23 @@ def gen_packages_items():
return packages


install_requires = parse_requirements()
try:
# OpenCV installed via conda.
import cv2 # NOQA: F401
major, minor, *rest = cv2.__version__.split('.')
if int(major) < 3:
raise RuntimeError(
f'OpenCV >=3 is required but {cv2.__version__} is installed')
except ImportError:
# 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 int(os.getenv('MMENGINE_LITE', '0')) == 1:
install_requires = parse_requirements('requirements/runtime_lite.txt')
else:
install_requires = parse_requirements()
try:
# OpenCV installed via conda.
import cv2 # NOQA: F401
major, minor, *rest = cv2.__version__.split('.')
if int(major) < 3:
raise RuntimeError(
f'OpenCV >=3 is required but {cv2.__version__} is installed')
except ImportError:
# 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))

setup(
name='mmengine',
Expand Down