pyca/cryptography — pull request #1257 by xolox (2014-07-11 23:06:42+00:00)
Title: Work around for side effects in setup.py script

As reported in https://github.com/pyca/cryptography/issues/1253 I ran into problems with `setup_requires` and related magic in the `setup.py` script of the cryptography package. Thanks to your comments in https://github.com/pyca/cryptography/issues/1253 I now understand why `setup.py` does what it does and why this is required (the `cffi` package requires it to build extension modules).

As suggested by @dstufft I went source diving setuptools and distutils, unfortunately I came back disappointed and without a solution. Because I'd like to help make things better and not just complain I decided to try a different route in getting https://github.com/pyca/cryptography/issues/1253 resolved: I looked for other projects with similar problems. Fairly quickly I ran into https://github.com/pypa/pip/issues/25 which describes almost the same issue and suggests a solution to the problem. That solution was implemented for SciPy (see [their setup.py script](https://github.com/scipy/scipy/blob/master/setup.py)) and it seems to work well for them.

I implemented the same solution in the `setup.py` script of the cryptography package and would like you to review and hopefully merge this minor change. It may be a bit pragmatic but it completely avoids the problem reported in https://github.com/pyca/cryptography/issues/1253 so if you ask me it's definitely worth it. I've tested creating a source distribution of the cryptography package and installing that and with the changes it works fine and as I originally expected it to: During pip's metadata discovery phase it doesn't do anything funky, only once pip invokes `python setup.py install` are the `setup_requires` dependencies installed and the extension modules compiled.

Thanks for your time and for the comments in https://github.com/pyca/cryptography/issues/1253.