Python packaging semantic versioning >= vs. ~= in requirements.txt

63 Views Asked by At

I have a general question about handling versions in requirements.txt of my package foo. I cannot decide if >= or ~= is better.

  • assume pandas~=1.3.3 in requirements.txt of my package foo
    • in this case, I can guarantee that tests and code of foo works correctly for pandas patches
    • problem: if there is a minor (or even major) change to 1.4.0 in pandas, a third package cannot use foo anymore with pandas==1.4.0. So I have to release foo again with pandas~=1.4.0. This means that I have to release constantly ...
  • assume pandas>=1.3.3 in my requirements.txt of my package foo
    • I thought the >= could solve the problem. With >=, foo can still be used. But ...
    • problem: this means that foo can even be used with major changes like pandas==2.1.1. I do not know if foo still works correctly. Probably the tests even fail but I won't notice ...

I am confused and I do not know what to do.

What is best practice?

Thanks!

0

There are 0 best solutions below