Skip to content

Commit

Permalink
[fix] phoc build during setup.py (#285)
Browse files Browse the repository at this point in the history
Summary:
- Also specifies the exact variation for detectron weights
- Builds the cphoc extension properly in setup.py
Pull Request resolved: #285

Reviewed By: vedanuj

Differential Revision: D21835564

Pulled By: apsdehal

fbshipit-source-id: 6ecc71fb008c4ca82064d02556b546486df08752
  • Loading branch information
apsdehal authored and facebook-github-bot committed Jun 2, 2020
1 parent 3734880 commit 7f3692f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion mmf/modules/encoders.py
Expand Up @@ -53,7 +53,7 @@ def __init__(
bias_file = os.path.join(model_data_dir, bias_file)

if not PathManager.exists(bias_file) or not PathManager.exists(weights_file):
download_path = download_pretrained_model("detectron")
download_path = download_pretrained_model("detectron.vmb_weights")
weights_file = get_absolute_path(os.path.join(download_path, "fc7_w.pkl"))
bias_file = get_absolute_path(os.path.join(download_path, "fc7_b.pkl"))

Expand Down
19 changes: 6 additions & 13 deletions setup.py
Expand Up @@ -6,7 +6,6 @@
import os
import platform
import re
import shutil
from glob import glob

import setuptools
Expand Down Expand Up @@ -97,16 +96,6 @@ def fetch_package_data():
return data_files


class BuildExt(build_ext):
def run(self):
build_ext.run(self)
cphoc_lib = glob(os.path.join("build", "lib.*", "cphoc.*"))[0]
copy_path = os.path.join(
"mmf", "utils", "phoc", cphoc_lib.split(os.path.sep)[-1]
)
shutil.copy(cphoc_lib, copy_path)


DISTNAME = "mmf"
DESCRIPTION = "mmf: a modular framework for vision and language multimodal \
research."
Expand All @@ -119,8 +108,12 @@ def run(self):
# Need to exclude folders in tests as well so as they don't create an extra package
# If something from tools is regularly used consider converting it into a cli command
EXCLUDES = ("data", "docs", "tests", "tests.*", "tools", "tools.*")
CMD_CLASS = {"build_ext": BuildExt}
EXT_MODULES = [Extension("cphoc", sources=["mmf/utils/phoc/src/cphoc.c"], language="c")]
CMD_CLASS = {"build_ext": build_ext}
EXT_MODULES = [
Extension(
"mmf.utils.phoc.cphoc", sources=["mmf/utils/phoc/src/cphoc.c"], language="c"
)
]

if "READTHEDOCS" in os.environ:
# Don't build extensions when generating docs
Expand Down

0 comments on commit 7f3692f

Please sign in to comment.