mirror of
https://github.com/certbot/certbot.git
synced 2026-07-31 18:34:41 +02:00
Do not require mock in Python 3 in certbot module (#7895)
Part of #7886. This PR conditionally installs mock in `certbot/setup.py` based on setuptools version and python version, when possible. It then updates `certbot` tests to use `unittest.mock` when `mock` isn't available. * Conditionally install mock in certbot * use unittest.mock when third-party mock isn't available in certbot * Add type:ignores because of https://github.com/python/mypy/issues/1153 * error when trying to build wheels with old setuptools
This commit is contained in:
+10
-2
@@ -47,7 +47,6 @@ install_requires = [
|
||||
# 1.1.0+ is required to avoid the warnings described at
|
||||
# https://github.com/certbot/josepy/issues/13.
|
||||
'josepy>=1.1.0',
|
||||
'mock',
|
||||
'parsedatetime>=1.3', # Calendar.parseDT
|
||||
'pyrfc3339',
|
||||
'pytz',
|
||||
@@ -62,7 +61,8 @@ install_requires = [
|
||||
# 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
|
||||
if StrictVersion(setuptools_version) >= StrictVersion('36.2'):
|
||||
setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2'))
|
||||
if setuptools_known_environment_markers:
|
||||
install_requires.append(pywin32_req + " ; sys_platform == 'win32'")
|
||||
elif 'bdist_wheel' in sys.argv[1:]:
|
||||
raise RuntimeError('Error, you are trying to build certbot wheels using an old version '
|
||||
@@ -73,6 +73,14 @@ elif os.name == 'nt':
|
||||
# setuptools, pywin32 will not be specified as a dependency.
|
||||
install_requires.append(pywin32_req)
|
||||
|
||||
if setuptools_known_environment_markers:
|
||||
install_requires.append('mock ; python_version < "3.3"')
|
||||
elif 'bdist_wheel' in sys.argv[1:]:
|
||||
raise RuntimeError('Error, you are trying to build certbot wheels using an old version '
|
||||
'of setuptools. Version 36.2+ of setuptools is required.')
|
||||
elif sys.version_info < (3,3):
|
||||
install_requires.append('mock')
|
||||
|
||||
dev_extras = [
|
||||
'coverage',
|
||||
'ipdb',
|
||||
|
||||
Reference in New Issue
Block a user