-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(exp,tools): support installation for pip (#1020)
- Loading branch information
1 parent
dd5700c
commit 12d0df1
Showing
5 changed files
with
86 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding:utf-8 -*- | ||
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved. | ||
|
||
# This file is used for package installation and find default exp file | ||
|
||
import importlib | ||
import sys | ||
from pathlib import Path | ||
|
||
_EXP_PATH = Path(__file__).resolve().parent.parent.parent.parent / "exps" / "default" | ||
|
||
if _EXP_PATH.is_dir(): | ||
# This is true only for in-place installation (pip install -e, setup.py develop), | ||
# where setup(package_dir=) does not work: https://github.com/pypa/setuptools/issues/230 | ||
|
||
class _ExpFinder(importlib.abc.MetaPathFinder): | ||
|
||
def find_spec(self, name, path, target=None): | ||
if not name.startswith("yolox.exp.default"): | ||
return | ||
project_name = name.split(".")[-1] + ".py" | ||
target_file = _EXP_PATH / project_name | ||
if not target_file.is_file(): | ||
return | ||
return importlib.util.spec_from_file_location(name, target_file) | ||
|
||
sys.meta_path.append(_ExpFinder()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding:utf-8 -*- | ||
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved. | ||
|
||
# This file is used for package installation. Script of train/eval/export will be available. | ||
|
||
import importlib | ||
import sys | ||
from pathlib import Path | ||
|
||
_TOOLS_PATH = Path(__file__).resolve().parent.parent.parent / "tools" | ||
|
||
if _TOOLS_PATH.is_dir(): | ||
# This is true only for in-place installation (pip install -e, setup.py develop), | ||
# where setup(package_dir=) does not work: https://github.com/pypa/setuptools/issues/230 | ||
|
||
class _PathFinder(importlib.abc.MetaPathFinder): | ||
|
||
def find_spec(self, name, path, target=None): | ||
if not name.startswith("yolox.tools."): | ||
return | ||
project_name = name.split(".")[-1] + ".py" | ||
target_file = _TOOLS_PATH / project_name | ||
if not target_file.is_file(): | ||
return | ||
return importlib.util.spec_from_file_location(name, target_file) | ||
|
||
sys.meta_path.append(_PathFinder()) |