| 1 | See suggestion in https://github.com/bskinn/sphobjinv/issues/275
|
| 2 |
|
| 3 | This prevents the module from creating an ssl context upon import, when,
|
| 4 | during a build especially, a certificate file may not be present. Otherwise
|
| 5 | module import would fail.
|
| 6 |
|
| 7 | |
| 8 | |
| 9 | @@ -30,7 +30,6 @@ Sphinx |objects.inv| files.
|
| 10 | """
|
| 11 |
|
| 12 | import re
|
| 13 | -import ssl
|
| 14 | import urllib.request as urlrq
|
| 15 | from zlib import error as zlib_error
|
| 16 |
|
| 17 | @@ -218,8 +217,15 @@ class Inventory:
|
| 18 | #: zlib compression line for v2 |objects.inv| header
|
| 19 | header_zlib = "# The remainder of this file is compressed using zlib."
|
| 20 |
|
| 21 | - # Private class member for SSL context, since context creation is slow(?)
|
| 22 | - _sslcontext = ssl.create_default_context(cafile=certifi.where())
|
| 23 | + # Private class member for SSL context
|
| 24 | + _sslcontext_ = None
|
| 25 | +
|
| 26 | + @property
|
| 27 | + def _sslcontext(self):
|
| 28 | + import ssl
|
| 29 | + if not self._sslcontext_:
|
| 30 | + self._sslcontext_ = ssl.create_default_context(cafile=certifi.where())
|
| 31 | + return self._sslcontext_
|
| 32 |
|
| 33 | @property
|
| 34 | def count(self):
|