-
Notifications
You must be signed in to change notification settings - Fork 72
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
Ensure Windows SDK directories are not cleared when caller specifies include/library dirs #153
Conversation
Fully expecting some test breaks, btw, as it does change the inspectable values in This change should also let us enable cross-compiling through |
@jaraco You know I don't like pinging you directly on stuff, but I'd love to get this off my in-progress list before I take a couple weeks away :-) |
I welcome pings. Can I take a look at this Friday? |
It feels like this approach is papering over a design defect. From distutils' perspective (and I'd rather see a solution that involves re-designing CCompiler such that More importantly, if this bug has been lying around essentially since its inception, perhaps it would make sense to create a regression test to capture the flaw (missed expectation), especially since the change didn't break any tests. |
The design defect has been in This change handles that assumption by injecting the compilers directories later on, just before launching the compiler. They get added after any user directories, so nothing should break. At worst, the system directories will be added twice by everyone with workarounds (e.g. PyWin32). (I guess technically the worst is that some deliberately(!?) failing builds will start succeeding, but that's the point of bug fixes.) I'd love to completely rework all the compilers, but since that would break everyone's hacks, it can't really be in setuptools or distutils ;-) |
Any more thoughts on this one? I'm still not sure what a test would prove, and the path ordering should ensure that it can only affect builds that currently fail with missing header files. |
I notice that distutils/distutils/ccompiler.py Lines 233 to 241 in 1845a34
|
I'm working on writing a test for this change, but I can't even find where |
Yes, this is why my change makes it so that it doesn't ;-) "By default" behaves slightly differently on Windows, because the default ones are smuggled in through the environment, not automatically determined by the compiler itself. Since we wipe out the environment, we need to pass them along ourselves, and previously were doing it through
It definitely works. I can have a go at repro steps, but essentially what I'll try to do is create a .c file that includes something from the Windows SDK, and show that calling |
I'm close to a repro. It requires attempting to cross-compile and specifying |
So the repro without subclassing the command requires the Alternatively, subclassing
One thing that is missing from my patch that only impacts the include directories is, as you pointed out, Considering all the compiler classes use this for preprocessing but not compiling, and the method says it's for compiling, I assume this was an oversight and it should be changed for all of them. I'll update my PR with it for reference, but if we only want to enable it for MSVC then I'm not going to argue too strongly. Nobody else overrides it within distutils or setuptools currently. |
Today I stumbled on #166, where one of the extension building tests for Windows is failing to link. I wonder if that test somehow serves as a repro for this issue. Edit: No - the failure there was a bug in the test suite. |
In the bugfix/153-test branch, I've started work on a test to capture the failure. It doesn't fail yet because:
I'm thinking for the second issue to simply repeat the Steve, can you help by providing some minimal C file that one would expect to fail in this scenario? I'd be happy with one that just fails on Windows for now, but it'd be nice to have a comparable one for Unix (maybe that relies on libc?). Feel free to send a PR to that branch, or just post it here and I'll integrate it. |
Sure. I got it to fail with this c file:
This setup.py:
And then invoking as Changing the default platform is the easiest way to trigger this, though I've seen it in more complex cases where the compiler is made to initialize early or where paths are updated later. You won't see the same issue on other platforms because it only affects |
I believe I've replicated the failure in 71cffcb. |
Yeah, that ought to do it. I mainly avoided doing it that way because nobody "out there" does that - they always get caught by the more subtle cases. |
.. including the MSVC & SDK include dirs after compiler.initialize() Changes in pypa#153 broke compatibility, and used shadowed class variables unnecessarily in an odd manner hiding the MSVC dirs.
thus including the MSVC & SDK include dirs after compiler.initialize() Changes in pypa#153 broke compatibility (pywin32), used shadowed class variables unnecessarily in an odd manner and hided the MSVC dirs from decent public usage.
thus including the MSVC & SDK include dirs after compiler.initialize() Changes in pypa#153 broke compatibility (pywin32), used shadowed class variables unnecessarily in an odd manner and hided the MSVC dirs from decent public usage.
including the SDK include dirs after compiler.initialize() Changes in pypa#153 broke compatibility (pywin32), used shadowed class variables in an odd manner and hided the MSVC dirs from decent public access.
including the SDK dirs after compiler.initialize() Changes in pypa#153 broke compatibility (pywin32), used shadowed class variables in an odd manner and hided the MSVC dirs from public access.
including the SDK dirs after compiler.initialize() Changes in pypa#153 broke compatibility (pywin32), used shadowed class variables in an odd manner and conceiled the MSVC dirs from public access.
including the SDK dirs after compiler.initialize() Changes in pypa#153 broke compatibility (pywin32), used shadowed class variables in an odd manner and conceiled the MSVC dirs from public access.
including the SDK dirs after compiler.initialize() Changes in pypa#153 broke compatibility (pywin32), used shadowed class variables in an odd manner and conceiled the MSVC dirs from public access.
including the SDK dirs after compiler.initialize() Changes in pypa#153 broke compatibility (pywin32), used shadowed class variables in an odd manner and conceiled the MSVC dirs from public access.
This corrects a long-standing bug in the
_msvccompiler
implementation where the INCLUDE and LIB variables from the environment would be entirely overridden by--include-dirs
and--library-dirs
options (regardless of how they were passed). Instead, these should be appended after any user-specified directories. Overriding the_fix_*_args
methods handles this for all users of the class.This will make fixes such as what PyWin32 uses redundant.