def coerce(cls, string):
        """Create a :class:`Requirement` object from a given package spec."""
        match = re.match(cls.spec_regex, string)
        if not match:
            raise InvalidRequirementSpecError("could not parse requirement")
        package = match.group(1)
        if all(match.group(2, 3)):
            version = "".join(match.group(2, 3))
        else:
            version = None
        return cls(package, version)
def exceptions_log_path(cls, for_pid=None, in_dir=None):
        """Get the path to either the shared or pid-specific fatal errors log file."""
        if for_pid is None:
            intermediate_filename_component = ""
        else:
            assert isinstance(for_pid, Pid)
            intermediate_filename_component = ".{}".format(for_pid)
        in_dir = in_dir or cls._log_dir
        return os.path.join(
            in_dir, ".pids", "exceptions{}.log".format(intermediate_filename_component)
        )