1. PyPA
  2. Python Packaging Authority Projects
  3. PyPI Metadata Formats
  4. Issues
Issue #47 resolved

Exact Comparison Escape Hatch

Donald Stufft
created an issue

Should we have an escape comparison escape hatch? Something that says "exactly this string" and allows someone to install a version which has a PEP 440 incompatible version?

I'm not sure of a good syntax for it, originally I thought about overloading == and maybe != but now I'm less sure about that as I think it adds extra complication to the implementation and to the understanding of those specifiers.

However the only other idea that I can think of is something like === and !== which are gross, but less gross I think than overloading == and !=.

Comments (11)

  1. Donald Stufft reporter

    Thinking about this more, !== doesn't make much sense because it's basically the default behavior. If you can't parse a version with PEP 440 you shouldn't install it. So that leaves just === for "bypass PEP 440 and install this exact version". I think that's reasonableish.

  2. Donald Stufft reporter

    Here the implementation of this: https://github.com/dstufft/packaging/commit/1f7577b1817ee981db1afdbfc38b27553e1a1755

    Notable things:

    • It works for both valid PEP 440 and invalid PEP 440, allowing bypassing the local version stuff if someone desires as well.
    • It should be even more discouraged than == since it doesn't even allow local versions.
    • There is no reflexive !== since the default action should be to ignore non compliant versions.
    • It is case insensitive to match all of the other operators
  3. Donald Stufft reporter

    The problem with is is that it mandates spaces which we currently don't do on any of the other specifiers (and we normalize them to remove the spaces). We could do it but it feels kinda strange to have one require spaces but none of the others require it.

  4. Nick Coghlan

    Direct references ("from") will also require a preceding space, so I think it's OK to make the rule the same as Python's - the preceding whitespace can be omitted only if it doesn't make the tokenisation ambiguous.

    Alternatively, we could make the tokens "=from" and "=is". It's a little odd, but avoids the whitespace issue. If we did that, the compatible version operator should likely also be switched to "=≈" so we're consistent in having the four definitions of various degrees of equivalence start with "=".

  5. Nick Coghlan

    Ah, right - I forgot about the switch to "@" for direct references. In that case, I don't currently have a better suggestion than "===".

    Relative to the other operands it's more "arbitrary equality" than "strict equality", though - it allows arbitrary version specifiers, rather than requiring strict compliance with the specified format.

  6. Donald Stufft reporter

    I don't particularly care what the name is :) I called it strict because it also allows you to say "1.0.0, not 1.0 or 1, or 1.0+foobar3" but arbitrary or any other thing is fine with me too.

  7. Log in to comment