Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG+1] Simplify version reporting #3946

Merged
merged 2 commits into from Aug 10, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 7 additions & 19 deletions scrapy/utils/versions.py
@@ -1,8 +1,10 @@
import platform
import sys

import cryptography
import cssselect
import lxml.etree
import OpenSSL
import parsel
import twisted
import w3lib
Expand All @@ -13,38 +15,24 @@
def scrapy_components_versions():
lxml_version = ".".join(map(str, lxml.etree.LXML_VERSION))
libxml2_version = ".".join(map(str, lxml.etree.LIBXML_VERSION))
try:
w3lib_version = w3lib.__version__
except AttributeError:
w3lib_version = "<1.14.3"
try:
import cryptography
cryptography_version = cryptography.__version__
except ImportError:
cryptography_version = "unknown"

return [
("Scrapy", scrapy.__version__),
("lxml", lxml_version),
("libxml2", libxml2_version),
("cssselect", cssselect.__version__),
("parsel", parsel.__version__),
("w3lib", w3lib_version),
("w3lib", w3lib.__version__),
("Twisted", twisted.version.short()),
("Python", sys.version.replace("\n", "- ")),
("pyOpenSSL", _get_openssl_version()),
("cryptography", cryptography_version),
("cryptography", cryptography.__version__),
("Platform", platform.platform()),
]


def _get_openssl_version():
try:
import OpenSSL
openssl = OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION)\
.decode('ascii', errors='replace')
# pyOpenSSL 0.12 does not expose openssl version
except AttributeError:
openssl = 'Unknown OpenSSL version'

openssl = OpenSSL.SSL.SSLeay_version(
OpenSSL.SSL.SSLEAY_VERSION
).decode('ascii', errors='replace')
elacuesta marked this conversation as resolved.
Show resolved Hide resolved
return '{} ({})'.format(OpenSSL.version.__version__, openssl)