Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97fa07c

Browse files
committed
VS2010 Support: Backport "Fixpython#13210. Port the Windows build from VS2008 to VS2010."
This commit is a partial backport ofpython/cpython@401f9f3. It wasoriginally designed to work with python-cmake-buildsystem.The following modules have NOT been backported:* Tools/msi* Tools/buildbot* PCBuild
1 parentca079a3 commit97fa07c

File tree

6 files changed

+46
-10
lines changed

6 files changed

+46
-10
lines changed

‎Lib/distutils/command/build_ext.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def finalize_options(self):
193193
# Append the source distribution include and library directories,
194194
# this allows distutils on windows to work in the source tree
195195
self.include_dirs.append(os.path.join(sys.exec_prefix,'PC'))
196-
ifMSVC_VERSION==9:
196+
ifMSVC_VERSION>=9:
197197
# Use the .lib files for the correct architecture
198198
ifself.plat_name=='win32':
199199
suffix=''

‎Lib/distutils/msvc9compiler.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,12 @@ def link(self,
662662
ifmfinfoisnotNone:
663663
mffilename,mfid=mfinfo
664664
out_arg='-outputresource:%s;%s'% (output_filename,mfid)
665-
try:
666-
self.spawn(['mt.exe','-nologo','-manifest',
667-
mffilename,out_arg])
668-
exceptDistutilsExecError,msg:
669-
raiseLinkError(msg)
665+
ifself.__version<10:
666+
try:
667+
self.spawn(['mt.exe','-nologo','-manifest',
668+
temp_manifest,out_arg])
669+
exceptPackagingExecErrorasmsg:
670+
raiseLinkError(msg)
670671
else:
671672
log.debug("skipping %s (up-to-date)",output_filename)
672673

‎PC/dl_nt.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ char dllVersionBuffer[16] = ""; // a private buffer
1818
HMODULEPyWin_DLLhModule=NULL;
1919
constchar*PyWin_DLLVersionString=dllVersionBuffer;
2020

21-
// Windows "Activation Context" work:
21+
#ifHAVE_SXS
22+
// Windows "Activation Context" work.
2223
// Our .pyd extension modules are generally built without a manifest (ie,
2324
// those included with Python and those built with a default distutils.
2425
// This requires we perform some "activation context" magic when loading our
@@ -29,6 +30,8 @@ const char *PyWin_DLLVersionString = dllVersionBuffer;
2930
// As an added complication, this magic only works on XP or later - we simply
3031
// use the existence (or not) of the relevant function pointers from kernel32.
3132
// See bug 4566 (http://python.org/sf/4566) for more details.
33+
// In Visual Studio 2010, side by side assemblies are no longer used by
34+
// default.
3235

3336
typedefBOOL (WINAPI*PFN_GETCURRENTACTCTX)(HANDLE*);
3437
typedefBOOL (WINAPI*PFN_ACTIVATEACTCTX)(HANDLE,ULONG_PTR*);
@@ -76,6 +79,8 @@ void _Py_DeactivateActCtx(ULONG_PTR cookie)
7679
OutputDebugString("Python failed to de-activate the activation context\n");
7780
}
7881

82+
#endif/* HAVE_SXS */
83+
7984
BOOLWINAPIDllMain (HANDLEhInst,
8085
ULONGul_reason_for_call,
8186
LPVOIDlpReserved)
@@ -87,17 +92,21 @@ BOOL WINAPI DllMain (HANDLE hInst,
8792
// 1000 is a magic number I picked out of the air. Could do with a #define, I spose...
8893
LoadString(hInst,1000,dllVersionBuffer,sizeof(dllVersionBuffer));
8994

95+
#ifHAVE_SXS
9096
// and capture our activation context for use when loading extensions.
9197
_LoadActCtxPointers();
9298
if (pfnGetCurrentActCtx&&pfnAddRefActCtx)
9399
if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext))
94100
if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext))
95101
OutputDebugString("Python failed to load the default activation context\n");
102+
#endif
96103
break;
97104

98105
caseDLL_PROCESS_DETACH:
106+
#ifHAVE_SXS
99107
if (pfnReleaseActCtx)
100108
(*pfnReleaseActCtx)(PyWin_DLLhActivationContext);
109+
#endif
101110
break;
102111
}
103112
return TRUE;

‎PC/msvcrtmodule.c‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#ifdef_MSC_VER
2626
#if_MSC_VER >=1500&&_MSC_VER<1600
2727
#include<crtassem.h>
28+
#elif_MSC_VER >=1600
29+
#include<crtversion.h>
2830
#endif
2931
#endif
3032

@@ -398,7 +400,7 @@ PyMODINIT_FUNC
398400
initmsvcrt(void)
399401
{
400402
intst;
401-
PyObject*d;
403+
PyObject*d,*version;
402404
PyObject*m=Py_InitModule("msvcrt",msvcrt_functions);
403405
if (m==NULL)
404406
return;
@@ -412,6 +414,7 @@ initmsvcrt(void)
412414
insertint(d,"LK_UNLCK",_LK_UNLCK);
413415

414416
/* constants for the crt versions */
417+
(void)st;
415418
#ifdef_VC_ASSEMBLY_PUBLICKEYTOKEN
416419
st=PyModule_AddStringConstant(m,"VC_ASSEMBLY_PUBLICKEYTOKEN",
417420
_VC_ASSEMBLY_PUBLICKEYTOKEN);
@@ -427,4 +430,14 @@ initmsvcrt(void)
427430
__LIBRARIES_ASSEMBLY_NAME_PREFIX);
428431
if (st<0)return;
429432
#endif
433+
434+
/* constants for the 2010 crt versions */
435+
#if defined(_VC_CRT_MAJOR_VERSION)&& defined (_VC_CRT_MINOR_VERSION)&& defined(_VC_CRT_BUILD_VERSION)&& defined(_VC_CRT_RBUILD_VERSION)
436+
version=PyUnicode_FromFormat("%d.%d.%d.%d",_VC_CRT_MAJOR_VERSION,
437+
_VC_CRT_MINOR_VERSION,
438+
_VC_CRT_BUILD_VERSION,
439+
_VC_CRT_RBUILD_VERSION);
440+
st=PyModule_AddObject(m,"CRT_ASSEMBLY_VERSION",version);
441+
if (st<0)returnNULL;
442+
#endif
430443
}

‎PC/pyconfig.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,19 @@ typedef int pid_t;
231231
#definehypot _hypot
232232
#endif
233233

234-
#endif/* _MSC_VER */
234+
/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/
235+
#if_MSC_VER >=1400&&_MSC_VER<1600
236+
#defineHAVE_SXS 1
237+
#endif
235238

236239
/* define some ANSI types that are not defined in earlier Win headers */
237-
#ifdefined(_MSC_VER)&&_MSC_VER >=1200
240+
#if_MSC_VER >=1200
238241
/* This file only exists in VC 6.0 or higher */
239242
#include<basetsd.h>
240243
#endif
241244

245+
#endif/* _MSC_VER */
246+
242247
/* ------------------------------------------------------------------------*/
243248
/* The Borland compiler defines __BORLANDC__ */
244249
/* XXX These defines are likely incomplete, but should be easy to fix. */

‎Python/dynload_win.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
#include<windows.h>
1313

1414
// "activation context" magic - see dl_nt.c...
15+
#ifHAVE_SXS
1516
externULONG_PTR_Py_ActivateActCtx();
1617
void_Py_DeactivateActCtx(ULONG_PTRcookie);
18+
#endif
1719

1820
conststructfiledescr_PyImport_DynLoadFiletab[]= {
1921
#ifdef_DEBUG
@@ -176,7 +178,9 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
176178
charpathbuf[260];
177179
LPTSTRdummy;
178180
unsignedintold_mode;
181+
#ifHAVE_SXS
179182
ULONG_PTRcookie=0;
183+
#endif
180184
/* We use LoadLibraryEx so Windows looks for dependent DLLs
181185
in directory of pathname first. However, Windows95
182186
can sometimes not work correctly unless the absolute
@@ -190,11 +194,15 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
190194
sizeof(pathbuf),
191195
pathbuf,
192196
&dummy)) {
197+
#ifHAVE_SXS
193198
ULONG_PTRcookie=_Py_ActivateActCtx();
199+
#endif
194200
/* XXX This call doesn't exist in Windows CE */
195201
hDLL=LoadLibraryEx(pathname,NULL,
196202
LOAD_WITH_ALTERED_SEARCH_PATH);
203+
#ifHAVE_SXS
197204
_Py_DeactivateActCtx(cookie);
205+
#endif
198206
}
199207

200208
/* restore old error mode settings */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp