def build(self):
        """Builds the app in the app's environment.

        Only builds if the build is out-of-date and is non-empty.
        Builds in 3 stages: requirements, dev requirements, and app.
        pip is used to install requirements, and setup.py is used to
        install the app itself.

        Raises:
            ValidationError if the app fails to build.
        """

        if self.exists:
            self._build(
                'requirements',
                self.requirements_last_modified,
                'pip install -U -r %s' % self.requirements_file
            )
            try:
                self._build(
                    'requirements (dev)',
                    self.dev_requirements_last_modified,
                    'pip install -U -r %s' % self.dev_requirements_file
                )
            except Exception as e:
                if 'No such file' not in str(e):
                    raise e
                self.stdout.write(
                    style.yellow('Could not find dev requirements')
                )
            try:
                self._build(
                    'requirements (local)',
                    self.local_requirements_last_modified,
                    'pip install -U -r %s' % self.local_requirements_file
                )
            except Exception as e:
                if 'No such file' not in str(e):
                    raise e
                self.stdout.write(
                    style.yellow('Could not find local requirements')
                )
            self._build(
                'application',
                self.setup_last_modified,
                'python %s develop' % self.setup_file
            )