-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Work around for side effects in setup.py script #1257
Conversation
Disables setup_requires and related magic for setup.py commands clean, egg_info and sdist and the options --version and --help. See also #1253
Can one of the admins verify this patch? |
ok to test |
return dict(setup_requires=requirements, | ||
cmdclass=dict(build=CFFIBuild, | ||
install=CFFIInstall, | ||
test=PyTest)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still reviewing this patch and thinking about it (going to be doing that for a while :-)). But two small notes:
- Could you make this function take
argv
as an argument and passsys.argv
to it? - House style would be to write this as:
return {
"setup_requires": requirements,
"cmdclass": {
"build": CFFIBuild,
"install": CFFIInstall,
"test": PyTest,
}
}
So I'm going to have to do a little bit of source diving to make sure I grok the side effects of this. One thing I would like to see is instead of just silently not overriding the |
Test PASSed. |
Test PASSed. |
Test FAILed. |
Thanks for the feedback so far! Some questions:
|
It looks like Jenkins just pointed out to me that I have some work to do... |
Hmm, I was afraid of that: It looks like distutils / setuptools always calls |
I think 2705e80 should resolve the problem pointed out by Jenkins, but let's see if Jenkins actually agrees with me. |
Test FAILed. |
The tests now pass on all but one platform: freebsd92 + py27. I don't really understand the failure though, there's no traceback or anything similar. It almost seems like a false negative. |
On Fri, Jul 11, 2014 at 5:56 PM, Peter Odding notifications@github.com
"I disapprove of what you say, but I will defend to the death your right to |
@alex wrote:
Thanks for the confirmation. I'll wait for Travis to process all of my commits (given the test suite of the cryptography package I guess this may take a while :-). I previously wrote:
This was bothering me so I fixed it in 9e34c14 by including a white list of arguments and 'shallow parsing' However I can imagine you would find this last commit overkill. If needed I can remove this commit or change it according to your feedback. |
1 similar comment
Test PASSed. |
"free command or option.") | ||
|
||
|
||
class DummyCFFIBuild(CFFIBuild): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this subclass CFFIBuild
and then not use it's finalize_options
? Seems like this should just subclass build
and then not have a finalize_options
method? Same for the other classes.
I believe if this PR works and gets merged in it will fix the problem pointed out in #716 as well. |
I thought it was an elegant way not to repeat the name of the superclass. I'll change it.
Yes it should fix that issue. |
Except that I was repeating the name of the superclass anyway (in the |
Test FAILed. |
Just checked the Jenkins test failures, these all seem to be timeouts on a specific test node. So far all tests on Travis CI are passing. |
I was testing the change suggested by me in this pull request and noticed that it's not finished yet; it doesn't actually work for pip's metadata discovery phase! This is because of the command line (magic) that pip uses:
Two things make this incompatible with the pull request as implemented:
The second one can be fixed by adding support for recognizing the
The
Although I've seen this behavior of the Python command line interpreter before, I'm not actually sure why or how it happens. I'll return here with a solution. I'm not sure we're going to like it, but I'm interested to see if it's possible to compensate for the problems caused by Update: Okay fixing the issue wasn't that exciting :-). A colleague of mine pointed out that |
… discovery) Fixes a bug in 9e34c14 as described in #1257 (comment)
I just pushed my (hopefully) final commit to this pull request. With the latest commit included the @alex, @dstufft: If there is anything else I can do to get this pull request merged please let me know! Thanks for the reviews / feedback so far. I needed this patch for version 0.5.2 so I wrote a small shell script that downloads a cryptography source distribution archive from PyPI, unpacks it, applies the patch (downloaded from GitHub) and repacks the source distribution as a tar archive so that it can be uploaded to a private PyPI mirror (e.g. devpi-server). I tested this with 0.5.2 and the patch applies with minimal offset and works as intended. Here's the shell script: #!/bin/bash -e
VERSION=0.5.2
BASENAME=cryptography-$VERSION
ARCHIVE=$BASENAME.tar.gz
TEMPDIR=$(mktemp --directory)
cd $TEMPDIR
wget https://pypi.python.org/packages/source/c/cryptography/$ARCHIVE
wget https://github.com/pyca/cryptography/pull/1257.diff
tar xf $ARCHIVE
patch -d $BASENAME -p 1 < 1257.diff
find $BASENAME -type d -name __pycache__ -print0 | xargs -0 rm -R
tar czf /tmp/$ARCHIVE $BASENAME
echo -e "\nFinished patching source distribution:"
ls -lh /tmp/$ARCHIVE |
Test FAILed. |
Okay I should have seen that coming, it failed on PEP-8 violations. Fixed now. |
Test FAILed. |
Merge conflicts here :-( Besides that, @dstufft can I ask you to review this? |
… discovery) Fixes a bug in 9e34c14 as described in pyca#1257 (comment)
closing in favor of #1366 (a rebase of this). |
Thanks @alex and @dstufft for the reviews, feedback and merging and thanks to @reaperhulk for rebasing this so it could be merged! I'm glad cryptography's |
As reported in #1253 I ran into problems with
setup_requires
and related magic in thesetup.py
script of the cryptography package. Thanks to your comments in #1253 I now understand whysetup.py
does what it does and why this is required (thecffi
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 #1253 resolved: I looked for other projects with similar problems. Fairly quickly I ran into pypa/pip#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) 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 #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 invokespython setup.py install
are thesetup_requires
dependencies installed and the extension modules compiled.Thanks for your time and for the comments in #1253.