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

Add an informative __main__.py #620

Merged
merged 9 commits into from
May 13, 2017
Merged

Add an informative __main__.py #620

merged 9 commits into from
May 13, 2017

Conversation

hynek
Copy link
Contributor

@hynek hynek commented Apr 20, 2017

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
Copy link

codecov bot commented Apr 20, 2017

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
Copy link
Contributor Author

hynek commented Apr 20, 2017

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?

Copy link
Contributor

@alexwlchan alexwlchan left a comment

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
Copy link
Contributor Author

hynek commented Apr 20, 2017

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

@alex
Copy link
Member

alex commented Apr 20, 2017

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

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

wot = """\
Copy link
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.



if __name__ != "__main__":
raise ImportError("This module can't be imported.")
Copy link
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

wot = """\
pyOpenSSL: {pyopenssl}
cryptography: {cryptography}
OpenSSL: {openssl}
Copy link
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
Copy link
Contributor Author

hynek commented Apr 21, 2017

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
Copy link
Contributor Author

hynek commented Apr 25, 2017

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

Copy link
Member

@alex alex left a comment

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
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
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