Permalink
Browse files

Move the cryptography package into a src/ subdirectory

Due to differences in how py.test determines which module to ``import``
the test suite actually runs against the cryptography which is in the
*current* directory instead of the cryptography which is installed. The
problem essentially boils down to when there is a tests/__init__.py then
py.test adds the current directory to the front of the sys.path, causing
it to take precedence over the installed location.

This means that running the tests relies on the implicit compile
that CFFI does instead of testing against what people will actually
be runnning, which is the module compiled by setup.py.
  • Loading branch information...
dstufft committed Nov 8, 2014
1 parent d9f137d commit c62a78c015cf7aeb0c05bce82ef14cd86fe0b0fc
Showing with 11 additions and 5 deletions.
  1. +1 −1 .coveragerc
  2. +1 −1 MANIFEST.in
  3. +1 −1 docs/conf.py
  4. +8 −2 setup.py
  5. 0 { → src}/cryptography/__about__.py
  6. 0 { → src}/cryptography/__init__.py
  7. 0 { → src}/cryptography/exceptions.py
  8. 0 { → src}/cryptography/fernet.py
  9. 0 { → src}/cryptography/hazmat/__init__.py
  10. 0 { → src}/cryptography/hazmat/backends/__init__.py
  11. 0 { → src}/cryptography/hazmat/backends/commoncrypto/__init__.py
  12. 0 { → src}/cryptography/hazmat/backends/commoncrypto/backend.py
  13. 0 { → src}/cryptography/hazmat/backends/commoncrypto/ciphers.py
  14. 0 { → src}/cryptography/hazmat/backends/commoncrypto/hashes.py
  15. 0 { → src}/cryptography/hazmat/backends/commoncrypto/hmac.py
  16. 0 { → src}/cryptography/hazmat/backends/interfaces.py
  17. 0 { → src}/cryptography/hazmat/backends/multibackend.py
  18. 0 { → src}/cryptography/hazmat/backends/openssl/__init__.py
  19. 0 { → src}/cryptography/hazmat/backends/openssl/backend.py
  20. 0 { → src}/cryptography/hazmat/backends/openssl/ciphers.py
  21. 0 { → src}/cryptography/hazmat/backends/openssl/cmac.py
  22. 0 { → src}/cryptography/hazmat/backends/openssl/dsa.py
  23. 0 { → src}/cryptography/hazmat/backends/openssl/ec.py
  24. 0 { → src}/cryptography/hazmat/backends/openssl/hashes.py
  25. 0 { → src}/cryptography/hazmat/backends/openssl/hmac.py
  26. 0 { → src}/cryptography/hazmat/backends/openssl/rsa.py
  27. 0 { → src}/cryptography/hazmat/backends/openssl/utils.py
  28. 0 { → src}/cryptography/hazmat/bindings/__init__.py
  29. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/__init__.py
  30. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/binding.py
  31. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/cf.py
  32. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/common_cryptor.py
  33. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/common_digest.py
  34. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/common_hmac.py
  35. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/common_key_derivation.py
  36. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/secimport.py
  37. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/secitem.py
  38. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/seckey.py
  39. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/seckeychain.py
  40. 0 { → src}/cryptography/hazmat/bindings/commoncrypto/sectransform.py
  41. 0 { → src}/cryptography/hazmat/bindings/openssl/__init__.py
  42. 0 { → src}/cryptography/hazmat/bindings/openssl/aes.py
  43. 0 { → src}/cryptography/hazmat/bindings/openssl/asn1.py
  44. 0 { → src}/cryptography/hazmat/bindings/openssl/bignum.py
  45. 0 { → src}/cryptography/hazmat/bindings/openssl/binding.py
  46. 0 { → src}/cryptography/hazmat/bindings/openssl/bio.py
  47. 0 { → src}/cryptography/hazmat/bindings/openssl/cmac.py
  48. 0 { → src}/cryptography/hazmat/bindings/openssl/cms.py
  49. 0 { → src}/cryptography/hazmat/bindings/openssl/conf.py
  50. 0 { → src}/cryptography/hazmat/bindings/openssl/crypto.py
  51. 0 { → src}/cryptography/hazmat/bindings/openssl/dh.py
  52. 0 { → src}/cryptography/hazmat/bindings/openssl/dsa.py
  53. 0 { → src}/cryptography/hazmat/bindings/openssl/ec.py
  54. 0 { → src}/cryptography/hazmat/bindings/openssl/ecdh.py
  55. 0 { → src}/cryptography/hazmat/bindings/openssl/ecdsa.py
  56. 0 { → src}/cryptography/hazmat/bindings/openssl/engine.py
  57. 0 { → src}/cryptography/hazmat/bindings/openssl/err.py
  58. 0 { → src}/cryptography/hazmat/bindings/openssl/evp.py
  59. 0 { → src}/cryptography/hazmat/bindings/openssl/hmac.py
  60. 0 { → src}/cryptography/hazmat/bindings/openssl/nid.py
  61. 0 { → src}/cryptography/hazmat/bindings/openssl/objects.py
  62. 0 { → src}/cryptography/hazmat/bindings/openssl/opensslv.py
  63. 0 { → src}/cryptography/hazmat/bindings/openssl/osrandom_engine.py
  64. 0 { → src}/cryptography/hazmat/bindings/openssl/pem.py
  65. 0 { → src}/cryptography/hazmat/bindings/openssl/pkcs12.py
  66. 0 { → src}/cryptography/hazmat/bindings/openssl/pkcs7.py
  67. 0 { → src}/cryptography/hazmat/bindings/openssl/rand.py
  68. 0 { → src}/cryptography/hazmat/bindings/openssl/rsa.py
  69. 0 { → src}/cryptography/hazmat/bindings/openssl/ssl.py
  70. 0 { → src}/cryptography/hazmat/bindings/openssl/x509.py
  71. 0 { → src}/cryptography/hazmat/bindings/openssl/x509_vfy.py
  72. 0 { → src}/cryptography/hazmat/bindings/openssl/x509name.py
  73. 0 { → src}/cryptography/hazmat/bindings/openssl/x509v3.py
  74. 0 { → src}/cryptography/hazmat/bindings/utils.py
  75. 0 { → src}/cryptography/hazmat/primitives/__init__.py
  76. 0 { → src}/cryptography/hazmat/primitives/asymmetric/__init__.py
  77. 0 { → src}/cryptography/hazmat/primitives/asymmetric/dsa.py
  78. 0 { → src}/cryptography/hazmat/primitives/asymmetric/ec.py
  79. 0 { → src}/cryptography/hazmat/primitives/asymmetric/padding.py
  80. 0 { → src}/cryptography/hazmat/primitives/asymmetric/rsa.py
  81. 0 { → src}/cryptography/hazmat/primitives/ciphers/__init__.py
  82. 0 { → src}/cryptography/hazmat/primitives/ciphers/algorithms.py
  83. 0 { → src}/cryptography/hazmat/primitives/ciphers/base.py
  84. 0 { → src}/cryptography/hazmat/primitives/ciphers/modes.py
  85. 0 { → src}/cryptography/hazmat/primitives/cmac.py
  86. 0 { → src}/cryptography/hazmat/primitives/constant_time.py
  87. 0 { → src}/cryptography/hazmat/primitives/hashes.py
  88. 0 { → src}/cryptography/hazmat/primitives/hmac.py
  89. 0 { → src}/cryptography/hazmat/primitives/interfaces.py
  90. 0 { → src}/cryptography/hazmat/primitives/kdf/__init__.py
  91. 0 { → src}/cryptography/hazmat/primitives/kdf/hkdf.py
  92. 0 { → src}/cryptography/hazmat/primitives/kdf/pbkdf2.py
  93. 0 { → src}/cryptography/hazmat/primitives/padding.py
  94. 0 { → src}/cryptography/hazmat/primitives/serialization.py
  95. 0 { → src}/cryptography/hazmat/primitives/src/constant_time.c
  96. 0 { → src}/cryptography/hazmat/primitives/src/constant_time.h
  97. 0 { → src}/cryptography/hazmat/primitives/twofactor/__init__.py
  98. 0 { → src}/cryptography/hazmat/primitives/twofactor/hotp.py
  99. 0 { → src}/cryptography/hazmat/primitives/twofactor/totp.py
  100. 0 { → src}/cryptography/utils.py
@@ -1,7 +1,7 @@
[run]
branch = True
source =
cryptography/
cryptography
tests/

[report]
@@ -7,7 +7,7 @@ include LICENSE.BSD
include README.rst

recursive-include docs *
recursive-include cryptography/hazmat/primitives/src *.c *.h
recursive-include src/cryptography/hazmat/primitives/src *.c *.h
prune docs/_build
recursive-include tests *.py
recursive-exclude vectors *
@@ -87,7 +87,7 @@

base_dir = os.path.join(os.path.dirname(__file__), os.pardir)
about = {}
with open(os.path.join(base_dir, "cryptography", "__about__.py")) as f:
with open(os.path.join(base_dir, "src", "cryptography", "__about__.py")) as f:
exec(f.read(), about)

version = release = about["__version__"]
@@ -27,9 +27,14 @@


base_dir = os.path.dirname(__file__)
src_dir = os.path.join(base_dir, "src")

# When executing the setup.py, we need to be able to import ourselves, this
# means that we need to add the src/ directory to the sys.path.
sys.path.insert(0, src_dir)

about = {}
with open(os.path.join(base_dir, "cryptography", "__about__.py")) as f:
with open(os.path.join(src_dir, "cryptography", "__about__.py")) as f:
exec(f.read(), about)


@@ -324,7 +329,8 @@ def run_tests(self):
"Topic :: Security :: Cryptography",
],

packages=find_packages(exclude=["tests", "tests.*"]),
package_dir={"": "src"},
packages=find_packages(where="src", exclude=["tests", "tests.*"]),
include_package_data=True,

install_requires=requirements,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c62a78c

Please sign in to comment.