-
Notifications
You must be signed in to change notification settings - Fork 2.2k
tests: avoid putting build products into source directory #2353
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
Conversation
a18c888
to
4346b25
Compare
Current problems: Everything works, except on Windows, where I get: Python 2.7:
Python 3.5 and 3.6:
Python 3.7 is fine. (I'm also taking advantage of this to test a few extra configurations, but not related to the actual PR) |
64905ff
to
cbe4a90
Compare
Further debugging: There’s a hack in the Python 2.7 can’t import anything from Python 3.5 and 3.6 produce Python 2.7:
Python 3.5 and 3.6:
|
e8fbe72
to
e98c607
Compare
d47a8db
to
4b7aa3c
Compare
I'm not totally sure what I fixed to make this start working, but it's working perfectly now after rebasing on my latest fixes. |
I've added a warning if the source directory is dirty with previous output files (the first time you build with this, you'll likely have a dirty source directory from previous runs). |
87d64f0
to
64094c6
Compare
Hi @Henriii, supporting proper out-of-tree builds sounds great to me, and those changes all look good to me. I would consider it important that no warning is generated when pybind11 is used (via add_subdirectory) by another project, and that user/project chooses to do an in-tree build. (But my understanding from reading the code is that no warning is generated in that case) An aside question: do you know what CMake's policy regarding in-tree builds is? I vaguely remember seeing a deprecation warning at some point, which seemed a bit pushy (In-tree builds are perfectly OK in some cases) Thanks, |
Yes, this is only for when this is the main project. As a subproject, it's up to the implementer of that project, not us. We didn't add anything to the source directory in those cases, so no change there :) (just our own testing)
As far as I know, it will always be 100% up to the package authors. Many packages do manually disable in-source builds, or generate warnings, but there are some cases where it's easier/simpler, and CMake itself isn't going to stop supporting those. |
As @rwgk has noted, and as sometimes comes up on the Gitter, pybind11 doesn't respect build and source separation - it dumps the test binaries into the source directories, meaning you can't have multiple build directories at once; or, at least, you have to recompile each time you want to change directories (which eliminates the main reason to have build directories in the first place). This does some cleanup, and makes sure that the source directories do not get artifacts! Only one Python file is copied in; the rest is done via PyTest config.
Also added a warning if someone tries an in-place build, which is a bad idea in general, and should be avoided.