Python pip._internal.exceptions.PreviousBuildDirError() Examples

The following are 1 code examples of pip._internal.exceptions.PreviousBuildDirError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pip._internal.exceptions , or try the search function .
Example #1
Source File: req_command.py    From rules_pip with MIT License 5 votes vote down vote up
def with_cleanup(func):
    # type: (Any) -> Any
    """Decorator for common logic related to managing temporary
    directories.
    """
    def configure_tempdir_registry(registry):
        # type: (TempDirectoryTypeRegistry) -> None
        for t in KEEPABLE_TEMPDIR_TYPES:
            registry.set_delete(t, False)

    def wrapper(self, options, args):
        # type: (RequirementCommand, Values, List[Any]) -> Optional[int]
        assert self.tempdir_registry is not None
        if options.no_clean:
            configure_tempdir_registry(self.tempdir_registry)

        try:
            return func(self, options, args)
        except PreviousBuildDirError:
            # This kind of conflict can occur when the user passes an explicit
            # build directory with a pre-existing folder. In that case we do
            # not want to accidentally remove it.
            configure_tempdir_registry(self.tempdir_registry)
            raise

    return wrapper