diff --git a/.gitignore b/.gitignore index 71c1f98e08..e5af472dfd 100644 --- a/.gitignore +++ b/.gitignore @@ -116,6 +116,7 @@ data work_dirs/ exps/ *~ +mmdet3d/.mim # Pytorch *.pth diff --git a/MANIFEST.in b/MANIFEST.in index 8f154c2afe..7b9cae69d7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,5 @@ -include mmdet3d/model-index.yml +include mmdet3d/.mim/model-index.yml include requirements/*.txt -recursive-include mmdet3d/configs *.py *.yml -recursive-include mmdet3d/tools *.sh *.py -recursive-include mmdet3d/ops *.cpp *.cu *.h *.cc -recursive-include mmdet3d/demo *.png *.jpg *.bin *.pkl *.py +recursive-include mmdet3d/.mim/ops *.cpp *.cu *.h *.cc +recursive-include mmdet3d/.mim/configs *.py *.yml +recursive-include mmdet3d/.mim/tools *.sh *.py diff --git a/README.md b/README.md index 0327438b30..c671c89f17 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ We wish that the toolbox and benchmark could serve the growing research communit ## 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 next-generation platform for general 3D object detection. diff --git a/README_zh-CN.md b/README_zh-CN.md index 4b60de0e41..f1114774af 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -146,6 +146,7 @@ MMDetection3D 是一款由来自不同高校和企业的研发人员共同参与 ## 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 目标检测平台 diff --git a/setup.cfg b/setup.cfg index c2b6d98937..8b615d27cf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,6 +8,6 @@ line_length = 79 multi_line_output = 0 known_standard_library = setuptools known_first_party = mmdet,mmseg,mmdet3d -known_third_party = cv2,indoor3d_util,load_scannet_data,lyft_dataset_sdk,m2r,matplotlib,mmcv,nuimages,numba,numpy,nuscenes,pandas,plyfile,pycocotools,pyquaternion,pytest,recommonmark,scannet_utils,scipy,seaborn,shapely,skimage,tensorflow,terminaltables,torch,trimesh,waymo_open_dataset +known_third_party = cv2,imageio,indoor3d_util,load_scannet_data,lyft_dataset_sdk,m2r,matplotlib,mmcv,nuimages,numba,numpy,nuscenes,pandas,plyfile,pycocotools,pyquaternion,pytest,recommonmark,scannet_utils,scipy,seaborn,shapely,skimage,tensorflow,terminaltables,torch,trimesh,waymo_open_dataset no_lines_before = STDLIB,LOCALFOLDER default_section = THIRDPARTY diff --git a/setup.py b/setup.py index e458ec2736..e0d80c8a6c 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,11 @@ from setuptools import find_packages, setup import os +import shutil +import sys import torch +import warnings +from os import path as osp from torch.utils.cpp_extension import (BuildExtension, CppExtension, CUDAExtension) @@ -135,7 +139,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, 'mmdet3d', '.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='mmdet3d', version=get_version(),