1def make_string_pep440_compatible(raw_str):
2    """
3    pep440 only allows a subset of characters in the
4    version name:
5
6    - alphanumeric
7    - dots
8
9    this will restrict the string to that set.
10    """
11    final_chars = []
12    for r in raw_str:
13        if "a" <= r <= "z" or "A" <= r <= "Z" or "0" <= r <= "9" or r == ".":
14            final_chars.append(r)
15    return "".join(final_chars)
16