Skip to content

Commit

Permalink
tree-wide: use LooseVersion instead of StrictVersion (certbot#8081)
Browse files Browse the repository at this point in the history
According to `distutils/version.py`, StrictVersion is pretty strict in
what version numbers to accept:

> A version number consists of two or three dot-separated numeric
> components, with an optional "pre-release" tag on the end.  The
> pre-release tag consists of the letter 'a' or 'b' followed by a number.

This assumption already fails for some pretty basic python libraries
itself, like setuptools, also available in `46.1.3.post20200610`, a
completely valid version number according to
https://www.python.org/dev/peps/pep-0440/#post-releases.

There doesn't seem to be a particular reason on why StrictVersion has
been used here, so let's use LooseVersion, to be compatible with these
versions.

Co-authored-by: Adrien Ferrand <[email protected]>
  • Loading branch information
flokli and adferrand authored Jun 19, 2020
1 parent db064a4 commit 25e79e4
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 40 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Authors
* [Felix Schwarz](https://github.com/FelixSchwarz)
* [Felix Yan](https://github.com/felixonmars)
* [Filip Ochnik](https://github.com/filipochnik)
* [Florian Klink](https://github.com/flokli)
* [Francois Marier](https://github.com/fmarier)
* [Frank](https://github.com/Frankkkkk)
* [Frederic BLANC](https://github.com/fblanc)
Expand Down
4 changes: 2 additions & 2 deletions acme/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand Down Expand Up @@ -27,7 +27,7 @@
'six>=1.9.0', # needed for python_2_unicode_compatible
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-apache/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -19,7 +19,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-ci/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand Down Expand Up @@ -26,7 +26,7 @@
# However environment markers are supported only with setuptools >= 36.2.
# So this dependency is not added for old Linux distributions with old setuptools,
# in order to allow these systems to build certbot from sources.
if StrictVersion(setuptools_version) >= StrictVersion('36.2'):
if LooseVersion(setuptools_version) >= LooseVersion('36.2'):
install_requires.append("pywin32>=224 ; sys_platform == 'win32'")
elif 'bdist_wheel' in sys.argv[1:]:
raise RuntimeError('Error, you are trying to build certbot wheels using an old version '
Expand Down
4 changes: 2 additions & 2 deletions certbot-compatibility-test/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -15,7 +15,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-cloudflare/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -18,7 +18,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-cloudxns/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -18,7 +18,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-digitalocean/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -19,7 +19,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-dnsimple/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import os
import sys

Expand All @@ -25,7 +25,7 @@
raise RuntimeError('Unset EXCLUDE_CERTBOT_DEPS when building wheels '
'to include certbot dependencies.')

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-dnsmadeeasy/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -18,7 +18,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-gehirn/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -17,7 +17,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-google/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -21,7 +21,7 @@
'httplib2'
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-linode/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -17,7 +17,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-luadns/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -18,7 +18,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-nsone/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -18,7 +18,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-ovh/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -18,7 +18,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-rfc2136/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -18,7 +18,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-route53/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -18,7 +18,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-dns-sakuracloud/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -17,7 +17,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
4 changes: 2 additions & 2 deletions certbot-nginx/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import sys

from setuptools import __version__ as setuptools_version
Expand All @@ -19,7 +19,7 @@
'zope.interface',
]

setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append('mock ; python_version < "3.3"')
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down
3 changes: 3 additions & 0 deletions certbot/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Certbot adheres to [Semantic Versioning](https://semver.org/).
### Fixed

* Cloudflare API Tokens may now be restricted to individual zones.
* Don't use `StrictVersion`, but `LooseVersion` to check version requirements with setuptools,
to fix some packaging issues with libraries respecting PEP404 for version string,
with doesn't match `StrictVersion` requirements.

More details about these changes can be found on our GitHub repo.

Expand Down
4 changes: 2 additions & 2 deletions certbot/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codecs
from distutils.version import StrictVersion
from distutils.version import LooseVersion
import os
import re
import sys
Expand Down Expand Up @@ -61,7 +61,7 @@ def read_file(filename, encoding='utf8'):
# So this dependency is not added for old Linux distributions with old setuptools,
# in order to allow these systems to build certbot from sources.
pywin32_req = 'pywin32>=227' # do not forget to edit pywin32 dependency accordingly in windows-installer/construct.py
setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
if setuptools_known_environment_markers:
install_requires.append(pywin32_req + " ; sys_platform == 'win32'")
elif 'bdist_wheel' in sys.argv[1:]:
Expand Down

0 comments on commit 25e79e4

Please sign in to comment.