-
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
Move the cryptography package into a src/ subdirectory #1468
Conversation
To be clearer, this essentially "fixes" the problem by making it so that there is no top level |
Test PASSed. |
Test PASSed. |
Eep. Is there really no other way to do this? It feels like a pretty obscure solution. |
When I did this for dstufft/http11 I couldn't figure out a better way. It doesn't feel very clean I agree :( |
Why do we need this if we're removing implicit compile? Shouldn't that get rid of the stuff in the top level directory? |
I explained it here: #1467 (comment) but essentially the way pytest works it means |
Important to note, that the way pytest works also means that currently we are not testing against an installed copy of cryptography, but against a checkout. This means that if our |
Sorry, if installation succeeds, why can't it locate the compiled module? On Fri Nov 07 2014 at 10:16:08 PM Donald Stufft notifications@github.com
|
Because installing cryptography within tox puts the installed copy of cryptography, along with the compiled module in |
IOW we have two copies of |
What happens if you delete the On Fri Nov 07 2014 at 10:26:13 PM Donald Stufft notifications@github.com
|
I believe (I'd need to test it) that we'll correctly use the installed copy of cryptography without needing to shuffle it into a I remember trying that before with http11 (and it was my original solution) until I started running into issues with it. I think the above were the issues I ran into. I can try it again to see if my memory is correct but it'll be a little bit as I'm about to step out for 20 minutes or so. |
Ok, if you could try that out it'd be great. If not, I wonder if we should On Fri Nov 07 2014 at 10:35:26 PM Donald Stufft notifications@github.com
|
FWIW, we never do "from tests", we always do "from ." for imports there, so On Fri Nov 07 2014 at 10:35:26 PM Donald Stufft notifications@github.com
|
Test PASSed. |
Yea it is, If my understanding is correct I'm not sure if it's reasonably avoidable. I think it adds I'm back now, going to be testing that. |
Yea so I'm correct you can't do relative imports without the
|
This now needs a rebase. I'd like to hear what other folks think about this. I'm not wild about it, but there don't really seem to be any other alternatives :-/ |
Rebased. With this there should now be a single compile step taken no matter what situation we're in. The implicit compiles should be completely gone from any installed situation. The implicit compile is still enabled in the code though, so bugs could still cause one to happen. |
Test PASSed. |
In the past we've resisted putting the tests inside the cryptography package itself (although we've had some users, especially in the distro packaging world, request this). Would moving tests to |
Someone would have to check, but I think yes, it owuld. |
It might, it depends on if if py.test will discover the tests inside the installed directory or inside the current directory. Let me try it. |
No difference, if I move the tests to |
One other possible solution is to disallow relative imports in the tests, which would mean that all files have to be self contained and all of the utility stuff has to live inside the cryptography project. |
The |
Do you think testing against the installed copy is the right way to do On Sat Nov 08 2014 at 5:40:58 PM Donald Stufft notifications@github.com
|
I think testing against an installed copy is going to give you results which are most likely to reflect the real world. In particular it's the best way to find bugs in your packaging where your installation commands succeed (defined as exiting with a We automate the With the above, we lower the chance of something going undetected, though it's still technically possible through bugs or just edge cases. Whether we care is a trade off question. |
#1470 has the |
Before I can render a final opinion on this, I'd like to think about how the overall tree would/should look. Specifically, where should we put vectors and maybe other in-tree backends. |
Probably anything that is going to be installable should be inside the |
Right, what's teh right way to handle the vectors On Tue Nov 11 2014 at 10:32:25 PM Donald Stufft notifications@github.com
|
I don't really think there's a better way then how we're handling it unless we wanted to move everything down a level and have I think I said it at the time, but I'm personally (still?) of the opinion that vecotrs should really live in their own repository. |
I am OK with this in principle. I think vectors should live within src too for now. |
So you think it should be |
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.
When using coverage.py with a project installed into site-packages instead of in the current directory you end up with paths like .tox/py34/lib/python3.4/site-packages/cryptography/__init__.py which is less than ideal (and may cause issues when aggregating coverage over multiple versions of Python). Switching coverage.py into parallel-mode will have it write a .coverage.* file instead of a .coverage file, which can then be "combined" into a .coverage file using coverage combine. When coverage.py does the combine step it will collapse the .tox/*/lib/python*/site-packages/cryptography paths into src/cryptography.
I rebased this, and included a fix for coverage so instead of it reporting paths like |
Test PASSed. |
One thing to note: If this gets merged and people have problems where coverage information doesn't show up, they should make sure they don't have an empty |
Just to be clear on the implications of this, my WIP scrypt backend will live in |
Does it use the top level |
No, it's a self-contained package ala vectors. |
Oh I see, it's another thing like vectors, no that wouldn't move into Unrelated, if we're going to keep adding more separate packages to this repository instead of putting each package in it's own repository, then we should do something like:
I also am pretty down on cramming all of these packages into the same repository. It sort of made sense with the vectors because the only reason vectors was a separate package was to make the tarball download smaller, however in general I think it's a pretty subpar way to organize things. |
👍 LGTM |
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.
This should also cause the tests to run a little bit faster as something like
tox -e py34
currently compiles everything 3 times instead of only once like it should. This PR will drop this down to 2 times.