Skip to content

Commit

Permalink
suport MIM (#224)
Browse files Browse the repository at this point in the history
* suport MIM

* remove demo
  • Loading branch information
GT9505 authored Jul 27, 2021
1 parent b0a8868 commit 010c423
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ ckpts
*.pkl.json
*.log.json
work_dirs/
mmtrack/.mim

# Pytorch
*.pth
Expand Down
8 changes: 3 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
include requirements/*.txt
include mmtrack/VERSION
include mmtrack/model-index.yml
include mmtrack/demo/*
recursive-include mmtrack/configs *.py *.yml
recursive-include mmtrack/tools *.sh *.py
include mmtrack/.mim/model-index.yml
recursive-include mmtrack/.mim/configs *.py *.yml
recursive-include mmtrack/.mim/tools *.sh *.py
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ and develop their own new video perception methods.
## Projects in OpenMMLab

- [MMCV](https://github.com/open-mmlab/mmcv): OpenMMLab foundational library for computer vision.
- [MIM](https://github.com/open-mmlab/mim): MIM Installs OpenMMLab Packages.
- [MMClassification](https://github.com/open-mmlab/mmclassification): OpenMMLab image classification toolbox and benchmark.
- [MMDetection](https://github.com/open-mmlab/mmdetection): OpenMMLab detection toolbox and benchmark.
- [MMDetection3D](https://github.com/open-mmlab/mmdetection3d): OpenMMLab's next-generation platform for general 3D object detection.
Expand Down
1 change: 1 addition & 0 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ MMTracking是一款开源项目,我们欢迎任何贡献和反馈。我们希
## OpenMMLab 的其他项目

- [MMCV](https://github.com/open-mmlab/mmcv):OpenMMLab计算机视觉基础库
- [MIM](https://github.com/open-mmlab/mim): MIM 是 OpenMMlab 项目、算法、模型的统一入口
- [MMClassification](https://github.com/open-mmlab/mmclassification):OpenMMLab图像分类工具箱与测试基准
- [MMDetection](https://github.com/open-mmlab/mmdetection):OpenMMLab目标检测工具箱与测试基准
- [MMDetection3D](https://github.com/open-mmlab/mmdetection3d):OpenMMLab新一代通用3D目标检测平台
Expand Down
53 changes: 53 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import os
import os.path as osp
import shutil
import sys
import warnings
from setuptools import find_packages, setup

import torch
Expand Down Expand Up @@ -124,7 +128,56 @@ def gen_packages_items():
return packages


def add_mim_extention():
"""Add extra files that are required to support MIM into the package.
These files will be added by creating a symlink to the originals if the
package is installed in `editable` mode (e.g. pip install -e .), or by
copying from the originals otherwise.
"""

# parse installment mode
if 'develop' in sys.argv:
# installed by `pip install -e .`
mode = 'symlink'
elif 'sdist' in sys.argv or 'bdist_wheel' in sys.argv:
# installed by `pip install .`
# or create source distribution by `python setup.py sdist`
mode = 'copy'
else:
return

filenames = ['tools', 'configs', 'model-index.yml']
repo_path = osp.dirname(__file__)
mim_path = osp.join(repo_path, 'mmtrack', '.mim')
os.makedirs(mim_path, exist_ok=True)

for filename in filenames:
if osp.exists(filename):
src_path = osp.join(repo_path, filename)
tar_path = osp.join(mim_path, filename)

if osp.isfile(tar_path) or osp.islink(tar_path):
os.remove(tar_path)
elif osp.isdir(tar_path):
shutil.rmtree(tar_path)

if mode == 'symlink':
src_relpath = osp.relpath(src_path, osp.dirname(tar_path))
os.symlink(src_relpath, tar_path)
elif mode == 'copy':
if osp.isfile(src_path):
shutil.copyfile(src_path, tar_path)
elif osp.isdir(src_path):
shutil.copytree(src_path, tar_path)
else:
warnings.warn(f'Cannot copy file {src_path}.')
else:
raise ValueError(f'Invalid mode {mode}')


if __name__ == '__main__':
add_mim_extention()
setup(
name='mmtrack',
version=get_version(),
Expand Down

0 comments on commit 010c423

Please sign in to comment.