From 9efa989d096fad71e8b0889cbe5f4a287eee0e46 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 15:11:25 -0700 Subject: A tox thing which attempts to check for errors (should be failing now) --- .travis.yml | 1 + tox.ini | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index defcd77b..f68d5ff6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: 2.7 env: + - TOX_ENV=cffi - TOX_ENV=py26 - TOX_ENV=py27 - TOX_ENV=py32 diff --git a/tox.ini b/tox.ini index 4d17ebe8..0b7acd66 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27,pypy,py32,py33,docs,pep8 +envlist = cffi,py26,py27,pypy,py32,py33,docs,pep8 [testenv] deps = @@ -7,6 +7,14 @@ deps = pretend commands = py.test --cov=cryptography/ --cov=tests/ +[testenv:cffi] +basepython = python2.7 +install_command = +setenv = + CFLAGS="-Wall -Wconversion -Wpedantic -Werror" +commands = + python -c "import cryptography.bindings.openssl" + [testenv:docs] deps = sphinx basepython = python2.7 -- cgit v1.2.3 From 1a2b774be6c554c9c4533341f9386cc644d7de1b Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 15:13:43 -0700 Subject: This isn't useful --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 0b7acd66..3ae8cfe8 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,6 @@ commands = py.test --cov=cryptography/ --cov=tests/ [testenv:cffi] basepython = python2.7 -install_command = setenv = CFLAGS="-Wall -Wconversion -Wpedantic -Werror" commands = -- cgit v1.2.3 From 0745587dc174adba539ab555da72bcaa0b21cd85 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 15:56:16 -0700 Subject: Try without this --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 3ae8cfe8..b198943f 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ commands = py.test --cov=cryptography/ --cov=tests/ [testenv:cffi] basepython = python2.7 setenv = - CFLAGS="-Wall -Wconversion -Wpedantic -Werror" + CFLAGS="-Wall -Wconversion -Werror" commands = python -c "import cryptography.bindings.openssl" -- cgit v1.2.3 From 89b4cc0454209b132400582f081ac1929d6b94c5 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 16:09:07 -0700 Subject: Software. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b198943f..9c1aade6 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ commands = py.test --cov=cryptography/ --cov=tests/ [testenv:cffi] basepython = python2.7 setenv = - CFLAGS="-Wall -Wconversion -Werror" + CFLAGS=-Wall -Wconversion -Wpedantic -Werror commands = python -c "import cryptography.bindings.openssl" -- cgit v1.2.3 From ca110d6412cb226f49d960b1eba7fe01ca3c80cf Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 16:18:09 -0700 Subject: Remove --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 9c1aade6..7d73fcef 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ commands = py.test --cov=cryptography/ --cov=tests/ [testenv:cffi] basepython = python2.7 setenv = - CFLAGS=-Wall -Wconversion -Wpedantic -Werror + CFLAGS=-Wall -Wconversion -Werror commands = python -c "import cryptography.bindings.openssl" -- cgit v1.2.3 From e63f0c1bea8ee0c3986a92026493109f62bb3f05 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 16:44:18 -0700 Subject: We can't compile cffi itself with warnings --- tox.ini | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 7d73fcef..b4b20ec4 100644 --- a/tox.ini +++ b/tox.ini @@ -9,10 +9,9 @@ commands = py.test --cov=cryptography/ --cov=tests/ [testenv:cffi] basepython = python2.7 -setenv = - CFLAGS=-Wall -Wconversion -Werror commands = - python -c "import cryptography.bindings.openssl" + git clean -x -f -d + CFLAGS="-Wall -Wconversion -Werror" python -c "import cryptography.bindings.openssl" [testenv:docs] deps = sphinx -- cgit v1.2.3 From 479cc0902e0243b59284145932e73ce0ea2ecf09 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 16:54:39 -0700 Subject: Do this always --- cryptography/bindings/openssl/api.py | 3 ++- tox.ini | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index d648d491..5b58c775 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -41,7 +41,8 @@ class API(object): self.lib = self.ffi.verify( source="\n".join(includes), - libraries=["crypto"] + libraries=["crypto"], + extra_compile_args=["-Wall", "-Werror", "-Wpedantic", "-Wconversion"] ) self.lib.OpenSSL_add_all_algorithms() diff --git a/tox.ini b/tox.ini index b4b20ec4..4d17ebe8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = cffi,py26,py27,pypy,py32,py33,docs,pep8 +envlist = py26,py27,pypy,py32,py33,docs,pep8 [testenv] deps = @@ -7,12 +7,6 @@ deps = pretend commands = py.test --cov=cryptography/ --cov=tests/ -[testenv:cffi] -basepython = python2.7 -commands = - git clean -x -f -d - CFLAGS="-Wall -Wconversion -Werror" python -c "import cryptography.bindings.openssl" - [testenv:docs] deps = sphinx basepython = python2.7 -- cgit v1.2.3 From a52219710bd9032ddafd8000afdaf05927aaa6a6 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 16:56:55 -0700 Subject: Different flags --- cryptography/bindings/openssl/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 5b58c775..2850f24a 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -42,7 +42,10 @@ class API(object): self.lib = self.ffi.verify( source="\n".join(includes), libraries=["crypto"], - extra_compile_args=["-Wall", "-Werror", "-Wpedantic", "-Wconversion"] + extra_compile_args=[ + "-Qunused-arguments", "-Wno-deprecated", + "-Wall", "-Werror", "-Wpedantic", "-Wconversion" + ] ) self.lib.OpenSSL_add_all_algorithms() -- cgit v1.2.3 From 3727881c4d69201dc51803c40b01efe321df3bd7 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 16:58:52 -0700 Subject: Some comments --- cryptography/bindings/openssl/api.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 2850f24a..49edc92e 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -43,7 +43,12 @@ class API(object): source="\n".join(includes), libraries=["crypto"], extra_compile_args=[ - "-Qunused-arguments", "-Wno-deprecated", + # Disabled because on stock OS X there is an "-mno-fused-madd" + # which is ignored. + "-Qunused-arguments", + # All of OpenSSL is deprecated on OS X, so we ignore this. + "-Wno-deprecated", + # Be very loud about everything else "-Wall", "-Werror", "-Wpedantic", "-Wconversion" ] ) -- cgit v1.2.3 From d7eb42875412655da819f9aeec67f16fbe617e75 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 17:41:01 -0700 Subject: I removed this --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f68d5ff6..defcd77b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: python python: 2.7 env: - - TOX_ENV=cffi - TOX_ENV=py26 - TOX_ENV=py27 - TOX_ENV=py32 -- cgit v1.2.3 From 85681a380776e62a140eb127a5dcd11de8d45af8 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 17:45:39 -0700 Subject: only pass these on OS X --- cryptography/bindings/openssl/api.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 49edc92e..6de5445d 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -39,18 +39,21 @@ class API(object): self.ffi.cdef(module.FUNCTIONS) includes.append(module.INCLUDES) + extra_compile_args = [ + # Be very loud about everything else + "-Wall", "-Werror", "-Wpedantic", "-Wconversion" + ] + if sys.platform == "darwin": + # All of OpenSSL is deprecated on OS X, so we ignore this. + extra_compile_args.append("-Wno-deprecated") + # Disabled because on stock OS X there is an "-mno-fused-madd" + # which is ignored. + extra_compile_args.append("-Qunused-arguments") + self.lib = self.ffi.verify( source="\n".join(includes), libraries=["crypto"], - extra_compile_args=[ - # Disabled because on stock OS X there is an "-mno-fused-madd" - # which is ignored. - "-Qunused-arguments", - # All of OpenSSL is deprecated on OS X, so we ignore this. - "-Wno-deprecated", - # Be very loud about everything else - "-Wall", "-Werror", "-Wpedantic", "-Wconversion" - ] + extra_compile_args=extra_compile_args, ) self.lib.OpenSSL_add_all_algorithms() -- cgit v1.2.3 From 6742ba8df7969ccc3fc7a2720269fdad4cf483da Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 17:52:23 -0700 Subject: A flag too far --- cryptography/bindings/openssl/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 6de5445d..1bb1f65c 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -41,7 +41,7 @@ class API(object): extra_compile_args = [ # Be very loud about everything else - "-Wall", "-Werror", "-Wpedantic", "-Wconversion" + "-Wall", "-Werror", "-Wconversion" ] if sys.platform == "darwin": # All of OpenSSL is deprecated on OS X, so we ignore this. -- cgit v1.2.3 From 818bcb7a7f8bd6c496c42e953ecc474dedd0096c Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 17:55:11 -0700 Subject: Everything but shut some off --- cryptography/bindings/openssl/api.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 1bb1f65c..1dfae28d 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -41,7 +41,14 @@ class API(object): extra_compile_args = [ # Be very loud about everything else - "-Wall", "-Werror", "-Wconversion" + "-Wall", "-Werror", "-Weverything", + + "-Wno-unused-parameter", + "-Wno-unused-macros", + "-Wno-missing-prototypes", + "-Wno-missing-field-initializers", + "-Wno-unreachable-code", + "-Wno-padded", ] if sys.platform == "darwin": # All of OpenSSL is deprecated on OS X, so we ignore this. -- cgit v1.2.3 From a4688e23bd92fbed535b8e4fd2859b42641a8f3c Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 18:00:36 -0700 Subject: Give up --- cryptography/bindings/openssl/api.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 1dfae28d..a8cf545c 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -41,14 +41,7 @@ class API(object): extra_compile_args = [ # Be very loud about everything else - "-Wall", "-Werror", "-Weverything", - - "-Wno-unused-parameter", - "-Wno-unused-macros", - "-Wno-missing-prototypes", - "-Wno-missing-field-initializers", - "-Wno-unreachable-code", - "-Wno-padded", + "-Werror", "-Wconversion", ] if sys.platform == "darwin": # All of OpenSSL is deprecated on OS X, so we ignore this. -- cgit v1.2.3 From 32ecb669c6b0c3b5eed25121f977d9bd9e983662 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 18:09:24 -0700 Subject: Try without this --- cryptography/bindings/openssl/api.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index a8cf545c..f4e5ab3d 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -39,10 +39,8 @@ class API(object): self.ffi.cdef(module.FUNCTIONS) includes.append(module.INCLUDES) - extra_compile_args = [ - # Be very loud about everything else - "-Werror", "-Wconversion", - ] + # Be very loud about everything else + extra_compile_args = ["-Werror"] if sys.platform == "darwin": # All of OpenSSL is deprecated on OS X, so we ignore this. extra_compile_args.append("-Wno-deprecated") -- cgit v1.2.3 From 90cde04460e3b3c30eb58b95778c0208ff5c429e Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 30 Sep 2013 20:40:38 -0500 Subject: Added a EVP_CIPHER_CTX_init() call * In OpenSSL when you alloc an EVP_CIPHER_CTX you must then init it (which just zeroes the allocated memory). If you do not then it is possible for things to kerplode when passing the uninitialized context to EVP_EncryptInit_ex(). This patch fixes that. --- cryptography/bindings/openssl/api.py | 2 ++ cryptography/bindings/openssl/evp.py | 1 + 2 files changed, 3 insertions(+) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index d648d491..28437576 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -56,6 +56,8 @@ class API(object): def create_block_cipher_context(self, cipher, mode): ctx = self.ffi.new("EVP_CIPHER_CTX *") + res = self.lib.EVP_CIPHER_CTX_init(ctx) + assert res != 0 ctx = self.ffi.gc(ctx, self.lib.EVP_CIPHER_CTX_cleanup) # TODO: compute name using a better algorithm ciphername = "{0}-{1}-{2}".format( diff --git a/cryptography/bindings/openssl/evp.py b/cryptography/bindings/openssl/evp.py index 8d2230fd..0bc5cffc 100644 --- a/cryptography/bindings/openssl/evp.py +++ b/cryptography/bindings/openssl/evp.py @@ -35,4 +35,5 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *, unsigned char *, int *); int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *); const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *); int EVP_CIPHER_block_size(const EVP_CIPHER *); +void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *); """ -- cgit v1.2.3 From 144ed67b6b3026f5eb130cdfcba6d699bb5a0b37 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 1 Oct 2013 14:45:13 +0100 Subject: Add a dev requirements file --- requirements-dev.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 requirements-dev.txt diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..28b11bea --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,8 @@ +-e . +enum +six +sphinx +tox +pytest +cffi +pretend -- cgit v1.2.3 From 0d9bb14f40c7903aac5be58ff40aa1f813876ead Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 1 Oct 2013 16:17:24 +0100 Subject: some narrative documentation explaining how to set up a development environment --- docs/contributing.rst | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ requirements-dev.txt | 9 +++--- 2 files changed, 85 insertions(+), 5 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index b4c72ba4..4f089fed 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -73,8 +73,89 @@ So, specifically: - No blank line at the end. - Use Sphinx parameter/attribute documentation `syntax`_. +Development +----------- + +Working on ``cryptography`` requires the installation of a small number of +development dependencies. +The list of development dependencies can be found in ``requirements-dev.txt``. +We recommend that you install these using ``virtualenv`` and ``pip``. +The following example shows how to create a ``cryptography`` development +environment on Linux: + +.. code-block:: sh + + cd ~/projects + git clone git@github.com:/cryptography.git + cd cryptography + mkdir -p ~/.virtualenvs/cryptography + virtualenv --no-site-packages ~/.virtualenvs/cryptography + source ~/.virtualenvs/cryptography/bin/activate + pip install -r requirements-dev.txt + pip install -e . + +You are now ready to run the tests and build the documentation. +Those steps are described in the next sections. + +Testing +------- + +``cryptography`` unit tests are found in the ``tests`` directory. +They are designed to be run using `pytest`_ as follows + +.. code-block:: sh + + py.test tests + ... + 4294 passed in 15.24 seconds + +This runs the tests with the default Python interpreter. + +You can also verify that the tests pass on other supported Python interpreters. +For this we use ``tox``, which will automatically create a ``virtualenv`` for +each supported Python version and run the tests. +Here is an example: + +.. code-block:: sh + + tox -l + ... + py33 + + tox -e py33 + ... + py33: commands succeeded + congratulations :) + +``tox`` can also be used to build the ``cryptography`` documentation. +That is described in the next section. + +Building Documentation +---------------------- + +``cryptography`` documentation is stored in the ``docs`` directory. +It is written in ``ReST`` and built using ``sphinx``. + +The simplest way to build the documentation is to use ``tox``. +The following example shows how to build the documentation using ``tox``: + +.. code-block:: sh + + tox -e doc + ... + py33: commands succeeded + congratulations :) + +The HTML documentation can now be found in the ``docs/_build/html`` +sub-directory. + +.. code-block:: sh + + firefox docs/_build/html/index.html + .. _`GitHub`: https://github.com/alex/cryptography .. _`our mailing list`: https://mail.python.org/mailman/listinfo/cryptography-dev .. _`PEP 8`: http://www.peps.io/8/ .. _`syntax`: http://sphinx-doc.org/domains.html#info-field-lists +.. _`pytest`: http://pytest.org diff --git a/requirements-dev.txt b/requirements-dev.txt index 28b11bea..b09707b8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,7 @@ --e . -enum +cffi +flake8 +pretend +pytest-cov six sphinx tox -pytest -cffi -pretend -- cgit v1.2.3 From c3d1eb5eda5bb18109c7a401b062730489be2367 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 1 Oct 2013 16:29:07 +0100 Subject: add some more links --- docs/contributing.rst | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index 4f089fed..a77ed849 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -79,7 +79,7 @@ Development Working on ``cryptography`` requires the installation of a small number of development dependencies. The list of development dependencies can be found in ``requirements-dev.txt``. -We recommend that you install these using ``virtualenv`` and ``pip``. +We recommend that you install these using `virtualenv`_ and `pip`_. The following example shows how to create a ``cryptography`` development environment on Linux: @@ -112,7 +112,7 @@ They are designed to be run using `pytest`_ as follows This runs the tests with the default Python interpreter. You can also verify that the tests pass on other supported Python interpreters. -For this we use ``tox``, which will automatically create a ``virtualenv`` for +For this we use `tox`_, which will automatically create a `virtualenv`_ for each supported Python version and run the tests. Here is an example: @@ -127,23 +127,23 @@ Here is an example: py33: commands succeeded congratulations :) -``tox`` can also be used to build the ``cryptography`` documentation. +`tox`_ can also be used to build the ``cryptography`` documentation. That is described in the next section. Building Documentation ---------------------- ``cryptography`` documentation is stored in the ``docs`` directory. -It is written in ``ReST`` and built using ``sphinx``. +It is written in `ReST`_ and built using `sphinx`_. -The simplest way to build the documentation is to use ``tox``. -The following example shows how to build the documentation using ``tox``: +The simplest way to build the documentation is to use `tox`_. +The following example demonstrates how: .. code-block:: sh tox -e doc ... - py33: commands succeeded + docs: commands succeeded congratulations :) The HTML documentation can now be found in the ``docs/_build/html`` @@ -158,4 +158,9 @@ sub-directory. .. _`our mailing list`: https://mail.python.org/mailman/listinfo/cryptography-dev .. _`PEP 8`: http://www.peps.io/8/ .. _`syntax`: http://sphinx-doc.org/domains.html#info-field-lists -.. _`pytest`: http://pytest.org +.. _`pytest`: https://pypi.python.org/pypi/pytest +.. _`tox`: https://pypi.python.org/pypi/tox +.. _`virtualenv`: https://pypi.python.org/pypi/virtualenv +.. _`pip`: https://pypi.python.org/pypi/pip +.. _`sphinx`: https://pypi.python.org/pypi/sphinx +.. _`ReST`: http://docutils.sourceforge.net/rst.html -- cgit v1.2.3 From 30176cedde60094f011c7b55f58d1d83d54cc5ed Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 1 Oct 2013 10:05:47 -0700 Subject: Rewrite this comment --- cryptography/bindings/openssl/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index f4e5ab3d..58885ab7 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -39,7 +39,7 @@ class API(object): self.ffi.cdef(module.FUNCTIONS) includes.append(module.INCLUDES) - # Be very loud about everything else + # Turn any warnings into an error extra_compile_args = ["-Werror"] if sys.platform == "darwin": # All of OpenSSL is deprecated on OS X, so we ignore this. -- cgit v1.2.3 From 12169b1ebe1aa672def8abf38959d27f51be00fb Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 1 Oct 2013 19:44:41 +0100 Subject: call it dev-requirements.txt --- dev-requirements.txt | 7 +++++++ requirements-dev.txt | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 dev-requirements.txt delete mode 100644 requirements-dev.txt diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 00000000..b09707b8 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,7 @@ +cffi +flake8 +pretend +pytest-cov +six +sphinx +tox diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index b09707b8..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,7 +0,0 @@ -cffi -flake8 -pretend -pytest-cov -six -sphinx -tox -- cgit v1.2.3 From 40cde82b2e3e4f791f9d7d931b8c926da1eaca07 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 1 Oct 2013 20:20:15 +0100 Subject: Address review comments. Better headings. More documentation build options --- docs/contributing.rst | 97 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 37 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index a77ed849..0f5cdfac 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -73,39 +73,34 @@ So, specifically: - No blank line at the end. - Use Sphinx parameter/attribute documentation `syntax`_. -Development ------------ +Development Environment +----------------------- Working on ``cryptography`` requires the installation of a small number of development dependencies. -The list of development dependencies can be found in ``requirements-dev.txt``. -We recommend that you install these using `virtualenv`_ and `pip`_. -The following example shows how to create a ``cryptography`` development -environment on Linux: +These are listed in ``dev-requirements.txt`` +and they can be installed in a `virtualenv`_ using `pip`_. +Once you've installed the dependencies, +install ``cryptography`` in ``editable`` mode. For example: .. code-block:: sh - cd ~/projects - git clone git@github.com:/cryptography.git - cd cryptography - mkdir -p ~/.virtualenvs/cryptography - virtualenv --no-site-packages ~/.virtualenvs/cryptography - source ~/.virtualenvs/cryptography/bin/activate - pip install -r requirements-dev.txt - pip install -e . + # Create a virtualenv and activate it + pip install --requirement dev-requirements.txt + pip install --editable . You are now ready to run the tests and build the documentation. -Those steps are described in the next sections. -Testing -------- +Running Tests +------------- -``cryptography`` unit tests are found in the ``tests`` directory. -They are designed to be run using `pytest`_ as follows +``cryptography`` unit tests are found in the ``tests/`` directory. +and are designed to be run using `pytest`_. +`pytest`_ will discover the tests automatically, so all you have to do is: .. code-block:: sh - py.test tests + py.test ... 4294 passed in 15.24 seconds @@ -113,31 +108,30 @@ This runs the tests with the default Python interpreter. You can also verify that the tests pass on other supported Python interpreters. For this we use `tox`_, which will automatically create a `virtualenv`_ for -each supported Python version and run the tests. -Here is an example: +each supported Python version and run the tests. For example: .. code-block:: sh - tox -l + tox ... - py33 - - tox -e py33 - ... - py33: commands succeeded - congratulations :) + ERROR: py26: InterpreterNotFound: python2.6 + py27: commands succeeded + ERROR: pypy: InterpreterNotFound: pypy + ERROR: py32: InterpreterNotFound: python3.2 + py33: commands succeeded + docs: commands succeeded + pep8: commands succeeded -`tox`_ can also be used to build the ``cryptography`` documentation. -That is described in the next section. +You may not have all the required Python versions installed, +in which case you will see one or more ``InterpreterNotFound`` errors. Building Documentation ---------------------- -``cryptography`` documentation is stored in the ``docs`` directory. -It is written in `ReST`_ and built using `sphinx`_. +``cryptography`` documentation is stored in the ``docs/`` directory. +It is written in `Restructured Text`_ and rendered using `sphinx`_. -The simplest way to build the documentation is to use `tox`_. -The following example demonstrates how: +The simplest way to build the documentation is to use `tox`_. For example: .. code-block:: sh @@ -146,13 +140,42 @@ The following example demonstrates how: docs: commands succeeded congratulations :) -The HTML documentation can now be found in the ``docs/_build/html`` +The HTML documentation can now be found in the ``docs/_build/html/`` sub-directory. .. code-block:: sh firefox docs/_build/html/index.html +You can also build non-HTML documentation and run various documentation tests +by running ``make`` in the ``docs/`` directory. +Just type ``make`` to see the available options: + +.. code-block:: sh + + make + ... + Please use `make ' where is one of + html to make standalone HTML files + dirhtml to make HTML files named index.html in directories + singlehtml to make a single large HTML file + pickle to make pickle files + json to make JSON files + htmlhelp to make HTML files and a HTML help project + qthelp to make HTML files and a qthelp project + devhelp to make HTML files and a Devhelp project + epub to make an epub + latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + latexpdf to make LaTeX files and run them through pdflatex + text to make text files + man to make manual pages + texinfo to make Texinfo files + info to make Texinfo files and run them through makeinfo + gettext to make PO message catalogs + changes to make an overview of all changed/added/deprecated items + linkcheck to check all external links for integrity + doctest to run all doctests embedded in the documentation (if enabled) + .. _`GitHub`: https://github.com/alex/cryptography .. _`our mailing list`: https://mail.python.org/mailman/listinfo/cryptography-dev @@ -163,4 +186,4 @@ sub-directory. .. _`virtualenv`: https://pypi.python.org/pypi/virtualenv .. _`pip`: https://pypi.python.org/pypi/pip .. _`sphinx`: https://pypi.python.org/pypi/sphinx -.. _`ReST`: http://docutils.sourceforge.net/rst.html +.. _`Restructured Text`: http://docutils.sourceforge.net/rst.html -- cgit v1.2.3 From 548a46e8e974572f0fe3ac5cad36fb1f132d5f62 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 1 Oct 2013 20:58:31 +0100 Subject: remove install dependencies --- dev-requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index b09707b8..01030e87 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,5 @@ -cffi flake8 pretend pytest-cov -six sphinx tox -- cgit v1.2.3 From 7d4ca1efc4a353023613aa20a2ddfd657939f31b Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 1 Oct 2013 21:10:45 +0100 Subject: address dreids review comments --- docs/contributing.rst | 48 +++++++----------------------------------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index 0f5cdfac..8007e6b6 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -86,8 +86,8 @@ install ``cryptography`` in ``editable`` mode. For example: .. code-block:: sh # Create a virtualenv and activate it - pip install --requirement dev-requirements.txt - pip install --editable . + $ pip install --requirement dev-requirements.txt + $ pip install --editable . You are now ready to run the tests and build the documentation. @@ -100,7 +100,7 @@ and are designed to be run using `pytest`_. .. code-block:: sh - py.test + $ py.test ... 4294 passed in 15.24 seconds @@ -112,7 +112,7 @@ each supported Python version and run the tests. For example: .. code-block:: sh - tox + $ tox ... ERROR: py26: InterpreterNotFound: python2.6 py27: commands succeeded @@ -131,50 +131,16 @@ Building Documentation ``cryptography`` documentation is stored in the ``docs/`` directory. It is written in `Restructured Text`_ and rendered using `sphinx`_. -The simplest way to build the documentation is to use `tox`_. For example: +Use `tox`_ to build the documentation. For example: .. code-block:: sh - tox -e doc + $ tox -e docs ... docs: commands succeeded congratulations :) -The HTML documentation can now be found in the ``docs/_build/html/`` -sub-directory. - -.. code-block:: sh - - firefox docs/_build/html/index.html - -You can also build non-HTML documentation and run various documentation tests -by running ``make`` in the ``docs/`` directory. -Just type ``make`` to see the available options: - -.. code-block:: sh - - make - ... - Please use `make ' where is one of - html to make standalone HTML files - dirhtml to make HTML files named index.html in directories - singlehtml to make a single large HTML file - pickle to make pickle files - json to make JSON files - htmlhelp to make HTML files and a HTML help project - qthelp to make HTML files and a qthelp project - devhelp to make HTML files and a Devhelp project - epub to make an epub - latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - latexpdf to make LaTeX files and run them through pdflatex - text to make text files - man to make manual pages - texinfo to make Texinfo files - info to make Texinfo files and run them through makeinfo - gettext to make PO message catalogs - changes to make an overview of all changed/added/deprecated items - linkcheck to check all external links for integrity - doctest to run all doctests embedded in the documentation (if enabled) +The HTML documentation index can now be found at ``docs/_build/html/index.html`` .. _`GitHub`: https://github.com/alex/cryptography -- cgit v1.2.3 From 166cbd3947cd4416fe7b48f1525853563cd1125f Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 1 Oct 2013 13:30:29 -0700 Subject: Reflow some paragraphs in the contributing docs --- docs/contributing.rst | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index 8007e6b6..9dd14c23 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -77,11 +77,9 @@ Development Environment ----------------------- Working on ``cryptography`` requires the installation of a small number of -development dependencies. -These are listed in ``dev-requirements.txt`` -and they can be installed in a `virtualenv`_ using `pip`_. -Once you've installed the dependencies, -install ``cryptography`` in ``editable`` mode. For example: +development dependencies. These are listed in ``dev-requirements.txt`` and they +can be installed in a `virtualenv`_ using `pip`_. Once you've installed the +dependencies, install ``cryptography`` in ``editable`` mode. For example: .. code-block:: sh @@ -94,9 +92,9 @@ You are now ready to run the tests and build the documentation. Running Tests ------------- -``cryptography`` unit tests are found in the ``tests/`` directory. -and are designed to be run using `pytest`_. -`pytest`_ will discover the tests automatically, so all you have to do is: +``cryptography`` unit tests are found in the ``tests/`` directory and are +designed to be run using `pytest`_. `pytest`_ will discover the tests +automatically, so all you have to do is: .. code-block:: sh @@ -122,14 +120,14 @@ each supported Python version and run the tests. For example: docs: commands succeeded pep8: commands succeeded -You may not have all the required Python versions installed, -in which case you will see one or more ``InterpreterNotFound`` errors. +You may not have all the required Python versions installed, in which case you +will see one or more ``InterpreterNotFound`` errors. Building Documentation ---------------------- -``cryptography`` documentation is stored in the ``docs/`` directory. -It is written in `Restructured Text`_ and rendered using `sphinx`_. +``cryptography`` documentation is stored in the ``docs/`` directory. It is +written in `reStructured Text`_ and rendered using `Sphinx`_. Use `tox`_ to build the documentation. For example: @@ -152,4 +150,4 @@ The HTML documentation index can now be found at ``docs/_build/html/index.html`` .. _`virtualenv`: https://pypi.python.org/pypi/virtualenv .. _`pip`: https://pypi.python.org/pypi/pip .. _`sphinx`: https://pypi.python.org/pypi/sphinx -.. _`Restructured Text`: http://docutils.sourceforge.net/rst.html +.. _`reStructured Text`: http://docutils.sourceforge.net/rst.html -- cgit v1.2.3 From dccaf36474ab55c6530d8fb5d8df07546d1f21f1 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 2 Oct 2013 10:10:28 -0700 Subject: Move to a saner approach --- cryptography/bindings/openssl/api.py | 16 +++++----------- cryptography/bindings/openssl/evp.py | 7 +++++-- cryptography/bindings/openssl/opensslv.py | 3 +++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 58885ab7..f9c75e64 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -32,26 +32,20 @@ class API(object): def __init__(self): self.ffi = cffi.FFI() includes = [] + functions = [] for name in self._modules: __import__("cryptography.bindings.openssl." + name) module = sys.modules["cryptography.bindings.openssl." + name] self.ffi.cdef(module.TYPES) self.ffi.cdef(module.FUNCTIONS) - includes.append(module.INCLUDES) + self.ffi.cdef(module.MACROS) - # Turn any warnings into an error - extra_compile_args = ["-Werror"] - if sys.platform == "darwin": - # All of OpenSSL is deprecated on OS X, so we ignore this. - extra_compile_args.append("-Wno-deprecated") - # Disabled because on stock OS X there is an "-mno-fused-madd" - # which is ignored. - extra_compile_args.append("-Qunused-arguments") + functions.append(module.FUNCTIONS) + includes.append(module.INCLUDES) self.lib = self.ffi.verify( - source="\n".join(includes), + source="\n".join(includes + functions), libraries=["crypto"], - extra_compile_args=extra_compile_args, ) self.lib.OpenSSL_add_all_algorithms() diff --git a/cryptography/bindings/openssl/evp.py b/cryptography/bindings/openssl/evp.py index 8d2230fd..740f125e 100644 --- a/cryptography/bindings/openssl/evp.py +++ b/cryptography/bindings/openssl/evp.py @@ -27,12 +27,15 @@ FUNCTIONS = """ void OpenSSL_add_all_algorithms(); const EVP_CIPHER *EVP_get_cipherbyname(const char *); int EVP_EncryptInit_ex(EVP_CIPHER_CTX *, const EVP_CIPHER *, ENGINE *, - unsigned char *, unsigned char *); + const unsigned char *, const unsigned char *); int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *, int); int EVP_EncryptUpdate(EVP_CIPHER_CTX *, unsigned char *, int *, - unsigned char *, int); + const unsigned char *, int); int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *, unsigned char *, int *); int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *); const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *); int EVP_CIPHER_block_size(const EVP_CIPHER *); """ + +MACROS = """ +""" diff --git a/cryptography/bindings/openssl/opensslv.py b/cryptography/bindings/openssl/opensslv.py index 9b2db270..d1a1b3e6 100644 --- a/cryptography/bindings/openssl/opensslv.py +++ b/cryptography/bindings/openssl/opensslv.py @@ -21,3 +21,6 @@ static char *const OPENSSL_VERSION_TEXT; FUNCTIONS = """ """ + +MACROS = """ +""" -- cgit v1.2.3 From 678149022b84ce275489afef4edf84a34a3074c1 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 2 Oct 2013 10:21:17 -0700 Subject: Added an explanatory comment --- cryptography/bindings/openssl/api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index f9c75e64..93863b31 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -43,6 +43,14 @@ class API(object): functions.append(module.FUNCTIONS) includes.append(module.INCLUDES) + # We include functions here so that if we got any of their definitions + # wrong, the underlying C compiler will explode. In C you are allowed + # to re-declare a function if it has the same signature. That is: + # int foo(int); + # int foo(int); + # is legal, but the following will fail to compile: + # int foo(int); + # int foo(short); self.lib = self.ffi.verify( source="\n".join(includes + functions), libraries=["crypto"], -- cgit v1.2.3