diff --git a/README.md b/README.md index 143012e771c5ad01ffb094774a286e93b32515f0..a7e66fa9f28499154778a46c2f20f7eb240759c3 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,11 @@ If you use the Habitat platform in your research, please cite the following [tec cd habitat-api pip install -e . ``` - +The command above will install only habitat core API. To include habitat_baselines along with all additional requirements, use the command below instead: +```bash +cd habitat-api +python setup.py develop --all # install habitat and habitat_baselines +``` 2. Install `habitat-sim` from [github repo](https://github.com/facebookresearch/habitat-sim). 3. Download the [test scenes data](http://dl.fbaipublicfiles.com/habitat/habitat-test-scenes.zip) and extract `data` folder in zip to `habitat-api/data/` where `habitat-api/` is the github repository folder. diff --git a/habitat_baselines/README.md b/habitat_baselines/README.md index 2229a8f7ce6ec277802d7adad9a36e6b6c120e92..57a2a72980a92143b02eff154585096e9c3a8c94 100644 --- a/habitat_baselines/README.md +++ b/habitat_baselines/README.md @@ -1,5 +1,12 @@ baselines ============================== +### Installation + +The `habitat_baselines` sub-package is NOT included upon installation by default. To install `habitat_baselines`, use the following command instead: +```bash +python setup.py develop --all +``` +This will also install additional requirements for each sub-module in `habitat_baselines/`, which are specified in `requirements.txt` files located in the sub-module directory. ### Reinforcement Learning (RL) diff --git a/habitat_baselines/rl/requirements.txt b/habitat_baselines/rl/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..c6c6cdd782fd8bcd1188d736e617cff2002be87a --- /dev/null +++ b/habitat_baselines/rl/requirements.txt @@ -0,0 +1 @@ +torch=1.1.0 diff --git a/habitat_baselines/slambased/requirements.txt b/habitat_baselines/slambased/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/setup.py b/setup.py index f3b2e5d5bce80a64cd4ffc29c5929a2185e2c272..bec05a1f77d9fc9513df2b46dc04c722250aeb25 100644 --- a/setup.py +++ b/setup.py @@ -4,10 +4,12 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. +import glob import os.path import sys - import setuptools +from setuptools.command.develop import develop as DefaultDevelopCommand +from setuptools.command.install import install as DefaultInstallCommand sys.path.insert(0, os.path.join(os.path.dirname(__file__), "habitat")) from version import VERSION # noqa @@ -26,13 +28,63 @@ DESCRIPTION = "habitat: a suite for embodied agent tasks and benchmarks" LONG_DESCRIPTION = readme AUTHOR = "Facebook AI Research" LICENSE = license -REQUIREMENTS = (reqs.strip().split("\n"),) +REQUIREMENTS = reqs.strip().split("\n") +BASELINE_PATH = ["habitat_baselines", "habitat_baselines.*"] +DEFAULT_EXCLUSION = ["test", "examples"] +FULL_REQUIREMENTS = set() +# collect requirements.txt file in all subdirectories +for file_name in glob.glob("**/requirements.txt", recursive=True): + with open(file_name) as f: + reqs = f.read() + FULL_REQUIREMENTS.update(reqs.strip().split("\n")) + + +class OptionedCommand: + """ + Generic Command class that takes extra user options and modifies + arguments in setuptools.setup() accordingly. + Though OptionedCommand inherits directly from object, it assumes + inheritance from DefaultDevelopCommand or DefaultInstallCommand, as it + overrides methods from those two classes. + """ + + user_options = [("all", None, "include habitat_baselines in installation")] + + def initialize_options(self): + super().initialize_options() + self.all = None + + def run(self): + if not self.all: # install core only + DEFAULT_EXCLUSION.extend(BASELINE_PATH) + self.distribution.packages = setuptools.find_packages( + exclude=DEFAULT_EXCLUSION + ) + # self.distribution accesses arguments of setup() in main() + else: # install all except test and examples + self.distribution.install_requires = FULL_REQUIREMENTS + super().run() + + +class InstallCommand(OptionedCommand, DefaultInstallCommand): + user_options = ( + getattr(DefaultInstallCommand, "user_options", []) + + OptionedCommand.user_options + ) + + +class DevelopCommand(OptionedCommand, DefaultDevelopCommand): + user_options = ( + getattr(DefaultDevelopCommand, "user_options", []) + + OptionedCommand.user_options + ) + if __name__ == "__main__": setuptools.setup( name=DISTNAME, install_requires=REQUIREMENTS, - packages=setuptools.find_packages(), + packages=setuptools.find_packages(exclude=DEFAULT_EXCLUSION), version=VERSION, description=DESCRIPTION, long_description=LONG_DESCRIPTION, @@ -41,4 +93,5 @@ if __name__ == "__main__": setup_requires=["pytest-runner"], tests_require=["pytest"], include_package_data=True, + cmdclass={"install": InstallCommand, "develop": DevelopCommand}, )