This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Patch to fix building on Win32/64 under VS 2010
Type: behavior Stage: resolved
Components: Distutils, Windows Versions: Python 3.4
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: THRlWiTi, cgohlke, christian.heimes, dstufft, eric.araujo, loewis, max.naumov, paul.moore, ralf.gommers, silverbacknet, steve.dower, theller, tim.golden, trent
Priority: normal Keywords: 3.3regression, patch

Created on 2012-10-21 17:56 by silverbacknet, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
msvc9manifest.diff silverbacknet, 2012-10-21 18:46
msvc9compilerpatch.diff max.naumov, 2014-03-17 15:07
Messages (20)
msg173464 - (view) Author: Silverback Networks (silverbacknet) Date: 2012-10-21 17:56
Once I got my broken environment fixed, this was the only thing that didn't work. The bug is that VS 2010 no longer creates a manifest by default, despite the documentation, and there are confirmation posts around the internet. /Manifest has to be forced starting with VS 2010. Here is a patch to fix that:

--- Lib/distutils/    2011-08-14 11:17:42.000000000 -0700
+++ Lib/distutils/    2012-10-21 10:38:42.257682200 -0700
@@ -411,10 +411,16 @@
                                           '/Z7', '/D_DEBUG']

         self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO']
+        if self.__version >= 10:
+            self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO', '/Manifest']
         if self.__version >= 7:
             self.ldflags_shared_debug = [
                 '/DLL', '/nologo', '/INCREMENTAL:no', '/DEBUG', '/pdb:None'
+            if self.__version >= 10:
+                self.ldflags_shared = [
+                '/DLL', '/nologo', '/INCREMENTAL:NO', '/DEBUG', '/pdb:None', '/Manifest'
+                ]
         self.ldflags_static = [ '/nologo']

         self.initialized = True
msg173465 - (view) Author: Silverback Networks (silverbacknet) Date: 2012-10-21 17:58
oops, add _debug on the second part of the patch.
msg173466 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-10-21 18:04
Can you please upload a proper patch files? It makes code review and applying the patch easier for us.
msg173469 - (view) Author: Silverback Networks (silverbacknet) Date: 2012-10-21 18:46
Sure. I got this patch from Mercurial, just in case, but it looks the same.
msg175676 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-11-16 10:48
Why did you put 3.2 into the version list? 3.2 doesn't use VS 2010.
msg210181 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2014-02-04 08:07
Is there any chance this can be included in Python 3.4? It would apparently allow numpy to be built with stock tools on Windows Python.
msg210190 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2014-02-04 09:59
Larry Hastings would have to rule on whether it could get into 3.4 at
this stage.

Paul: are you in a position to apply / test the patch? I've done no more
than glance at it but it looks, from the comments, as though it doesn't
apply cleanly.
msg210191 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2014-02-04 10:05
Unfortunately not really - it's the numpy guys that need this, so hopefully the original poster can comment.

I'll see if I can hand-patch the relevant files and do a pip install numpy to see if it fixes that specific scenario. I'll report back.

I've added Larry Hastings to the nosy list for his comments.
msg210192 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2014-02-04 10:11
Sigh. Looks like it doesn't fix the issue of building numpy - plus it doesn't apply cleanly. My apologies for the noise, I'll report the issues with the patch back on the numpy issue where I was told about this patch.
msg210193 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-02-04 10:19
I'm not sure I need to be on this issue.  As a rule, Windows build concerns for 3.4 are delegated to Martin von Lowis.
msg210195 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2014-02-04 10:29
Thanks, Larry. Martin's already nosy this issue, but really we need to
see if we have a viable patch before making decisions about 3.4. I'll
take you off the nosy list.
msg210222 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2014-02-04 12:59
Hm, what's the problem?
For me, the patch applies cleanly (in Python 3.4.0b3, 32-bit and 64-bit on Windows), and
  py -3.4(-32) -m pip install numpy
works correctly.  At least
  py -3.4(-32) -c "import numpy; print(numpy.__version__)"
prints "1.8.0".

This is with the newest pip (1.5.2).

I have the full version of visual studio 2010 installed.
msg210231 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2014-02-04 14:01
Maybe it's not applicable to 3.3 somehow, which is what I tried. I applied the patch to the distutils in the system installed Python, then ran pip install numpy from a virtualenv.

It's quite possible that a million things could have gone wrong in that process - but that's all I had time to check (I'm only really interested in this as a courtesy to the numpy people, who asked me to raise the bug on numpy, then directed me to this patch as a fix).
msg213874 - (view) Author: Max Naumov (max.naumov) * Date: 2014-03-17 15:07
Wouldn't this be more correct?
--- Lib/distutils/	2013-08-03T16:17:08+04:00
+++ Lib/distutils/	2014-03-17T18:36:50.078672+04:00
@@ -411,7 +411,11 @@
                                           '/Z7', '/D_DEBUG']
         self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO']
-        if self.__version >= 7:
+        if self.__version >= 10:
+            self.ldflags_shared = [
+                '/DLL', '/nologo', '/INCREMENTAL:NO', '/DEBUG', '/pdb:None', '/Manifest'
+                ]
+        elif self.__version >= 7:
             self.ldflags_shared_debug = [
                 '/DLL', '/nologo', '/INCREMENTAL:no', '/DEBUG', '/pdb:None'
msg213881 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2014-03-17 18:25
What is the procedure to test this patch? Under what circumstances exactly is it needed?
msg213882 - (view) Author: Max Naumov (max.naumov) * Date: 2014-03-17 18:33
It allows to install numpy on windows python 3.4. Just like the patch in the original post. Actually my patch is merely the original patch refactored.
msg221078 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-20 08:44
Can somebody reset the status to open please.
msg248433 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2015-08-11 23:25
I think this can now be closed as "out of date".
msg248434 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-08-11 23:38
It doesn't apply to 3.5 or later, so it's up to Martin whether he wants to apply it for 3.4. (I suspect not, but I'm not about to preempt his call.)
msg248470 - (view) Author: Ralf Gommers (ralf.gommers) Date: 2015-08-12 18:56
I'll note that in Numpy we have now worked around the issue (with, basically by monkeypatching distutils and doing:

    if '/MANIFEST' not in ldflags:

The bug report is still valid though; it should not be specific to numpy. A more detailed report of what was broken before and fixed by this patch would have been helpful. I cannot be sure that this is 100% correct because I don't have Windows+MSVC available, but it should be this:

- Take Python 3.4 installed from the .exe installer
- Create a new virtualenv and activate it
- pip install numpy==1.8.0   # this will fail
- apply the patch
- pip install numpy==1.8.0   # this will work

Furthermore I think that this is a duplicate of, which is also a valid bug report confirmed by multiple people (but closed as "not a bug"). 

Given that applying the patch is harmless and not applying it clearly does create problems for users, it would make sense to apply it. But honestly, given for how long the bug reports on 4431 were ignored, I'm not willing to spend much effort on this. So if no one else does either, this issue may indeed just as well be closed as outdated like Marc Lawrence suggests.
Date User Action Args
2022-04-11 14:57:37adminsetgithub: 60500
2019-09-11 13:09:37steve.dowersetstatus: open -> closed
resolution: out of date
stage: patch review -> resolved
2019-02-24 22:44:55BreamoreBoysetnosy: - BreamoreBoy
2015-08-12 18:56:48ralf.gommerssetmessages: + msg248470
2015-08-11 23:38:02steve.dowersetmessages: + msg248434
versions: - Python 3.5
2015-08-11 23:25:14BreamoreBoysetmessages: + msg248433
2014-07-04 22:30:20brian.curtinsetnosy: - brian.curtin
2014-07-04 05:00:49THRlWiTisetnosy: + THRlWiTi
2014-06-27 19:02:27zach.waresetcomponents: + Windows
2014-06-27 19:01:25zach.waresetstatus: languishing -> open
versions: + Python 3.5, - Python 3.3
nosy: + dstufft, eric.araujo, - zach.ware

components: + Distutils, - Build, Windows
type: compile error -> behavior
2014-06-20 08:44:45BreamoreBoysetnosy: + BreamoreBoy, zach.ware, steve.dower
messages: + msg221078
2014-03-17 18:33:42max.naumovsetmessages: + msg213882
2014-03-17 18:25:35loewissetmessages: + msg213881
2014-03-17 15:07:16max.naumovsetfiles: + msvc9compilerpatch.diff
nosy: + max.naumov
messages: + msg213874

2014-02-04 14:01:55paul.mooresetmessages: + msg210231
2014-02-04 12:59:25thellersetnosy: + theller
messages: + msg210222
2014-02-04 10:32:12tim.goldensetnosy: - larry
2014-02-04 10:29:17tim.goldensetmessages: + msg210195
2014-02-04 10:19:50larrysetmessages: + msg210193
2014-02-04 10:11:42paul.mooresetmessages: + msg210192
2014-02-04 10:05:38paul.mooresetnosy: + larry
messages: + msg210191
2014-02-04 09:59:03tim.goldensetmessages: + msg210190
2014-02-04 08:07:50paul.mooresetnosy: + paul.moore
messages: + msg210181
2014-02-04 07:51:55ralf.gommerssetnosy: + ralf.gommers
2013-11-17 14:23:16christian.heimessetstatus: open -> languishing
2013-08-30 00:52:28trentsetversions: - Python 3.2
2013-08-30 00:36:12trentsetnosy: + trent
2012-11-16 10:48:57loewissetmessages: + msg175676
2012-11-16 10:15:56cgohlkesetnosy: + cgohlke
2012-10-21 18:53:43pitrousetnosy: + loewis, tim.golden, brian.curtin
2012-10-21 18:46:08silverbacknetsetfiles: + msvc9manifest.diff
keywords: + patch
messages: + msg173469
2012-10-21 18:04:53christian.heimessetcomponents: + Windows
versions: - Python 3.1
keywords: + 3.3regression
nosy: + christian.heimes

messages: + msg173466
stage: patch review
2012-10-21 17:58:54silverbacknetsetmessages: + msg173465
2012-10-21 17:56:15silverbacknetcreate