-
Notifications
You must be signed in to change notification settings - Fork 71
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
MSVC & SDK dirs suddenly hidden from compiler.include_dirs #174
Comments
Thanks kxrob for the report, and specifically for what's needed. I think I understand now. I'm unsure why the initialization is deferred, but the include/lib dirs are dependent on the I think I agree that a compiler should expose the include/lib dirs as they would resolve when compiling, rather than hiding them in _fix_compiler_args. And maybe they shouldn't be stored in class attributes, but that's an implementation detail if we can expose the full set through an API. |
Are you going to do the same for gcc? Because I bet you're not ;) Hiding the default arguments is just trying to give both gcc and MSVC an equivalent API. If that API is "distutils knows what the default compiler paths will be", you'll likely need to do more work to extract those paths from gcc to provide them. Otherwise, you're just entrenching different APIs for different platforms. The pywin32 need for this part of the API was to work around the underlying issue, which is now fixed. With the fix in place, they don't need it anymore. (They were also previously using it to guess where certain other headers and libraries might be, but that logic is wrong and I already replaced it with a more robust option that doesn't rely on being able to read out the runtime include/lib dirs.) |
I don't think its about knowing all that behind the curtain for abstract reasons - but simple knowing what the MSVC / gcc ... is fed with by distutils.
Well, the _fixup_sdk_dirs() and its digging mechanism
Well, actually your own (!) last changes there introduced, not removed the inspection of And there may be many other reasons for other users to simply know "how the cow is fed" . Why hide important things? Besides: You also introduced another maybe competing mechanism (
There are many platform specific functions in standard Python - and needed. But generally trying to make it as similar as practically possible. pywin32 of course needs to do Windows specific things - but still produce distutils / Python compatible extensions, wheels, ... |
Yep. How do you think I knew where setuptools needed to be fixed, and also that the bit I added would stop working after it was fixed upstream? I'm not magic, I'm just trying to be both the cause and the solution! 😆
It's not competing - it's correct. The ATLMFC redistributable libraries are separate from UCRT and WinSDK, which is what vcvarsall will configure by default. You can't find them by looking in a fixed relative directory from the headers, though that did work for a number of versions of Visual Studio. It doesn't work any more.
Except Under the current change, it's far simpler. |
There doesn't seem to be a warning comment at that code position and/or hint for resolution, your mhammond/pywin32#1897 says: I haven't tried, but I believe the code in your setup.py will still work, and none of the asserts will trigger. So you may not notice anything at all ...
But in case its compatible, are those dirs usually near the corresponding VC? Did not see anything else so far. And had no problem so far as long as the ATL stuff was clicked for installation.
In the end distutils should do the "probably best" / offical base search, whatever it is, and pywin32 probably just follow without (1st priority) risking a completely incompatible dir for ATL. So I guess it should remain a goal to get rid of a completely independent search mechanism "from bottom up" - just do some search from a distutils provided start?
It just inherits and exports the empty list - trivially. And in a similar use case as above: the extra makefile sub-project for gcc e.g. could be fed the same way.
With an independent often incompatible search mechanism again? That would be back to square one. |
You're correct. I was not explicitly planning to do the same, in part because it's not obvious to me what that would entail. It seems to me the difference here is that gcc infers the default libs for the platform but Windows requires them to be supplied explicitly. If so, then the path to convergence is for distutils to supply those defaults. I was not intending to extract those and present them for a downstream consumer. What I do believe is valuable to convey is "what behavior does distutils add" or "how does distutils configure a compile operation", so a consumer could reasonably infer how an operation (compile, link) is going to behave on any platform. |
What you probably want is to add a new setuptools feature to allow running an arbitrary command as if it's the compiler (same environment, basically). It's already inherited a number of helper methods for certain types of commands (static lib, preprocess, etc.), but adding a new one for any command would satisfy the need for building Scintilla, and could also be implemented consistently across all platforms. Jason owns distutils now as far as I'm concerned, but I'd expect it to be deprecated across the board now with the intent to merge all the functionality into setuptools APIs over the next couple of years (and likely tidy some up along the way). That's why I say it's probably a setuptools feature. |
One day soon you will have a problem, because I encountered the problem while cross-compiling for a platform that you don't support yet 😉 With the fixes I contributed (and the later fixes for the distutils change), it'll be trivial for you to support Windows ARM64 devices once you decide it's worthwhile (hopefully during CPython 3.11, which has an ARM64 installer). But I acknowledge that you likely haven't seen that issue before, even though I think that's due to luck rather than any intentional design on the part of the MSVC installer.
As I mentioned above, setuptools may choose to expose more information or access to the compilation environment. But distutils never did it on purpose (and never provided enough to be accurate, unless you got lucky, as you apparently have been), and it's unlikely to get new features to provide it now. In this particular case, you'd only get a mismatch if the build was going to fail anyway, so nothing breaks that was already working. But the point is true that in more complex cases, there may be components installed in a newer VS instance that "shadow" the one that included MSVC and cause problems. It won't be ATLMFC though (which has a dependency on MSVC in VS). |
#153 broke the
pywin32
builds by incompatibly hiding the MSVC & SDK dirs fromcompiler_instance.include_dirs
- and decent public access at all. Same for libs.The problem happened at
https://github.com/mhammond/pywin32/blob/fc69a1ecc150a13433a7a71d61bac52a5f3df42b/setup.py#L695
/ mhammond/pywin32@fc69a1e) ( @zooba )
(And further problems would also occur later in
_why_cant_build_extension()
at least.)The VC & SDK dirs are needed for inspection in complex projects.
At best in a compatible way again.
#153 uses (hidden) class vars
compiler_instance.__class__.include_dirs
which though are set only after instance.initialize() .PR #172 (tested with pywin32) suggests a potential way of solution and tests - see further comments and commit comments there.
Without solution, strange application code / workarounds like this would be required:
https://github.com/mhammond/pywin32/blob/b52884ae5417fd2f857007ae1c74d4f753591d36/setup.py#L688
mhammond/pywin32@b52884a
mhammond/pywin32#1936
The text was updated successfully, but these errors were encountered: