Skip to content

Add an informative __main__.py#620

Merged
reaperhulk merged 9 commits into
pyca:masterfrom
hynek:master
May 13, 2017
Merged

Add an informative __main__.py#620
reaperhulk merged 9 commits into
pyca:masterfrom
hynek:master

Conversation

@hynek

@hynek hynek commented Apr 20, 2017

Copy link
Copy Markdown
Contributor

Give users an easy way to figure out what versions they're running.

These questions come up with every bug.

Give users an easy way to figure out what versions they're running.
@codecov

codecov Bot commented Apr 20, 2017

Copy link
Copy Markdown

Codecov Report

Merging #620 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #620      +/-   ##
==========================================
+ Coverage   96.78%   96.79%   +<.01%     
==========================================
  Files          16       18       +2     
  Lines        5628     5642      +14     
  Branches      392      393       +1     
==========================================
+ Hits         5447     5461      +14     
  Misses        121      121              
  Partials       60       60
Impacted Files Coverage Δ
src/OpenSSL/debug.py 100% <100%> (ø)
tests/test_debug.py 100% <100%> (ø)
tests/test_util.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7706e14...a81358d. Read the comment docs.

@hynek

hynek commented Apr 20, 2017

Copy link
Copy Markdown
Contributor Author

FTR, on my computer the output looks like this:

➤ python -m OpenSSL
pyOpenSSL: 17.1.0.dev0
cryptography: 1.7.2
OpenSSL: OpenSSL 1.0.2k  26 Jan 2017
Python: /Users/hynek/.virtualenvs/pyopenssl/bin/python
Python version: 2.7.13 (default, Dec 26 2016, 08:37:46)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
Platform: darwin
sys.path: ['', '/Users/hynek/.virtualenvs/pyopenssl/lib/python27.zip', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/plat-darwin', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/plat-mac', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/lib-tk', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/lib-old', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/lib-dynload', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7/plat-darwin', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7/lib-tk', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7/plat-mac', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/site-packages', '/Users/hynek/Projects/pyopenssl/src']

That should be helpful when pinning down packaging problems.

Opinions?

@alexwlchan alexwlchan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth a note in CONTRIBUTING.rst suggesting that users include the output in their bug report?

@hynek

hynek commented Apr 20, 2017

Copy link
Copy Markdown
Contributor Author

I would even add a bug template…BUT: not before it’s released?

@alex

alex commented Apr 20, 2017

Copy link
Copy Markdown
Member

-m OpenSSL is way too generic a name for this; maybe -m OpenSSL.debug or something.

Comment thread src/OpenSSL/__main__.py Outdated
if __name__ != "__main__":
raise ImportError("This module can't be imported.")

wot = """\

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what "wot" means, please use a real variable name.

Comment thread src/OpenSSL/__main__.py Outdated


if __name__ != "__main__":
raise ImportError("This module can't be imported.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should go in a main function which is invoked in the __main__ block, that way it can be tested in memory

Comment thread src/OpenSSL/__main__.py Outdated
wot = """\
pyOpenSSL: {pyopenssl}
cryptography: {cryptography}
OpenSSL: {openssl}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to distinguish between the linked version of OpenSSL and the compiled-against version.

@hynek

hynek commented Apr 21, 2017

Copy link
Copy Markdown
Contributor Author

I wasn’t quite sure what you meant with linked/compiled? I’ve added the OpenSSL the Python ist compiled against, since that is occasionally useful too:

pyOpenSSL: 17.1.0.dev0
cryptography: 1.7.2
cryptography's OpenSSL: OpenSSL 1.0.2k  26 Jan 2017
Pythons's OpenSSL: OpenSSL 1.0.2k  26 Jan 2017
Python executable: /Users/hynek/.virtualenvs/pyopenssl/bin/python
Python version: 2.7.13 (default, Dec 26 2016, 08:37:46)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
Platform: darwin
sys.path: ['', '/Users/hynek/.virtualenvs/pyopenssl/lib/python27.zip', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/plat-darwin', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/plat-mac', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/lib-tk', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/lib-old', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/lib-dynload', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7/plat-darwin', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7/lib-tk', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7/plat-mac', '/Users/hynek/.pyenv/versions/2.7.13/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/hynek/.virtualenvs/pyopenssl/lib/python2.7/site-packages', '/Users/hynek/Projects/pyopenssl/src']

@hynek

hynek commented Apr 25, 2017

Copy link
Copy Markdown
Contributor Author

I’ve add the cffi version which is (not only) interesting for #622.

@alex alex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, besides this LGTM

@@ -0,0 +1,36 @@
from __future__ import print_function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be a package, just debug.py is sufficient.

@reaperhulk

Copy link
Copy Markdown
Member

When @alex said linked vs compiled he meant that when cryptography is compiled the OpenSSL headers are used to determine version. You can obtain the version that was seen during the compile phase with _util.lib.OPENSSL_VERSION_TEXT. The version that is actually loaded by the dynamic linker is obtained via the mechanism you already have in this PR. The reason it's interesting to see both is that sometimes people install cryptography/pyOpenSSL and then upgrade OpenSSL. This can occasionally cause problems and that makes it useful to see the mismatch

@reaperhulk reaperhulk merged commit d52975c into pyca:master May 13, 2017
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants