Skip to content

Commit e6a1f39

Browse files
committed
VS2015 Support: Backport "Issue python#22919: Windows build updated to support VC 14.0 (Visual Studio 2015), which will be used for the official 3.5 release."
This commit is a partial backport of python/cpython@65e4cb1. It was originally designed to work with python-cmake-buildsystem. This patch do not backport the define "timezone" as "_timezone" as it was done in Python 3.x. Keeping "timezone" is required in Python 2.7.x to avoid the following build issue ``error C2032: '__timezone': function cannot be member of struct '__timeb64'`` associated with `sys/timeb.h`. The need for `sys/timeb.h` was removed in Python 3.x in python/cpython@6fc4ade and python/cpython@0011124 but is still used in Python 2.7.x. The following modules have NOT been backported: * Lib/distutils/sysconfig * Modules/socketmodule.c .... : Not required since changes related to WSA have been introduced in Python 3.x (see python/cpython@6b4883d) * Tools/buildbot * PCBuild
1 parent 4988ea4 commit e6a1f39

File tree

8 files changed

+47
-29
lines changed

8 files changed

+47
-29
lines changed

Lib/ctypes/util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def _get_build_version():
1919
i = i + len(prefix)
2020
s, rest = sys.version[i:].split(" ", 1)
2121
majorVersion = int(s[:-2]) - 6
22+
if majorVersion >= 13:
23+
majorVersion += 1
2224
minorVersion = int(s[2:3]) / 10.0
2325
# I don't think paths are affected by minor version in version 6
2426
if majorVersion == 6:
@@ -36,8 +38,10 @@ def find_msvcrt():
3638
return None
3739
if version <= 6:
3840
clibname = 'msvcrt'
39-
else:
41+
elif version <= 13:
4042
clibname = 'msvcr%d' % (version * 10)
43+
else:
44+
clibname = 'appcrt%d' % (version * 10)
4145

4246
# If python was built with in debug mode
4347
import imp

Lib/distutils/command/build_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def finalize_options(self):
196196
if MSVC_VERSION >= 9:
197197
# Use the .lib files for the correct architecture
198198
if self.plat_name == 'win32':
199-
suffix = ''
199+
suffix = 'win32'
200200
else:
201201
# win-amd64 or win-ia64
202202
suffix = self.plat_name[4:]

Lib/distutils/msvc9compiler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ def get_build_version():
182182
i = i + len(prefix)
183183
s, rest = sys.version[i:].split(" ", 1)
184184
majorVersion = int(s[:-2]) - 6
185+
if majorVersion >= 13:
186+
# v13 was skipped and should be v14
187+
majorVersion += 1
185188
minorVersion = int(s[2:3]) / 10.0
186189
# I don't think paths are affected by minor version in version 6
187190
if majorVersion == 6:

Lib/distutils/msvccompiler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ def get_build_version():
164164
i = i + len(prefix)
165165
s, rest = sys.version[i:].split(" ", 1)
166166
majorVersion = int(s[:-2]) - 6
167+
if majorVersion >= 13:
168+
# v13 was skipped and should be v14
169+
majorVersion += 1
167170
minorVersion = int(s[2:3]) / 10.0
168171
# I don't think paths are affected by minor version in version 6
169172
if majorVersion == 6:

Modules/posixmodule.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,33 @@ _PyInt_FromDev(PY_LONG_LONG v)
553553
/* The actual size of the structure is determined at runtime.
554554
* Only the first items must be present.
555555
*/
556+
557+
#if _MSC_VER >= 1900
558+
559+
typedef struct {
560+
CRITICAL_SECTION lock;
561+
intptr_t osfhnd;
562+
__int64 startpos;
563+
char osfile;
564+
} my_ioinfo;
565+
566+
#define IOINFO_L2E 6
567+
#define IOINFO_ARRAYS 128
568+
569+
#else
570+
556571
typedef struct {
557572
intptr_t osfhnd;
558573
char osfile;
559574
} my_ioinfo;
560575

561-
extern __declspec(dllimport) char * __pioinfo[];
562576
#define IOINFO_L2E 5
563-
#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
564577
#define IOINFO_ARRAYS 64
578+
579+
#endif
580+
581+
extern __declspec(dllimport) char * __pioinfo[];
582+
#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
565583
#define _NHANDLE_ (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)
566584
#define FOPEN 0x01
567585
#define _NO_CONSOLE_FILENO (intptr_t)-2

Modules/timemodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,15 +710,15 @@ inittimezone(PyObject *m) {
710710
#ifdef PYOS_OS2
711711
PyModule_AddIntConstant(m, "timezone", _timezone);
712712
#else /* !PYOS_OS2 */
713-
PyModule_AddIntConstant(m, "timezone", timezone);
713+
PyModule_AddIntConstant(m, "timezone", _timezone);
714714
#endif /* PYOS_OS2 */
715715
#ifdef HAVE_ALTZONE
716716
PyModule_AddIntConstant(m, "altzone", altzone);
717717
#else
718718
#ifdef PYOS_OS2
719719
PyModule_AddIntConstant(m, "altzone", _timezone-3600);
720720
#else /* !PYOS_OS2 */
721-
PyModule_AddIntConstant(m, "altzone", timezone-3600);
721+
PyModule_AddIntConstant(m, "altzone", _timezone-3600);
722722
#endif /* PYOS_OS2 */
723723
#endif
724724
PyModule_AddIntConstant(m, "daylight", daylight);

PC/bdist_wininst/install.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ static void CenterWindow(HWND hwnd)
11841184

11851185
#include <prsht.h>
11861186

1187-
BOOL CALLBACK
1187+
INT_PTR CALLBACK
11881188
IntroDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
11891189
{
11901190
LPNMHDR lpnm;
@@ -1533,7 +1533,7 @@ SCHEME *GetScheme(int major, int minor)
15331533
return old_scheme;
15341534
}
15351535

1536-
BOOL CALLBACK
1536+
INT_PTR CALLBACK
15371537
SelectPythonDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
15381538
{
15391539
LPNMHDR lpnm;
@@ -1835,7 +1835,7 @@ static void CloseLogfile(void)
18351835
fclose(logfile);
18361836
}
18371837

1838-
BOOL CALLBACK
1838+
INT_PTR CALLBACK
18391839
InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
18401840
{
18411841
LPNMHDR lpnm;
@@ -1990,7 +1990,7 @@ InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
19901990
}
19911991

19921992

1993-
BOOL CALLBACK
1993+
INT_PTR CALLBACK
19941994
FinishedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
19951995
{
19961996
LPNMHDR lpnm;
@@ -2166,23 +2166,6 @@ BOOL NeedAutoUAC()
21662166
return TRUE;
21672167
}
21682168

2169-
// Returns TRUE if the platform supports UAC.
2170-
BOOL PlatformSupportsUAC()
2171-
{
2172-
// Note that win2k does seem to support ShellExecute with 'runas',
2173-
// but does *not* support IsUserAnAdmin - so we just pretend things
2174-
// only work on XP and later.
2175-
BOOL bIsWindowsXPorLater;
2176-
OSVERSIONINFO winverinfo;
2177-
winverinfo.dwOSVersionInfoSize = sizeof(winverinfo);
2178-
if (!GetVersionEx(&winverinfo))
2179-
return FALSE; // something bad has gone wrong
2180-
bIsWindowsXPorLater =
2181-
( (winverinfo.dwMajorVersion > 5) ||
2182-
( (winverinfo.dwMajorVersion == 5) && (winverinfo.dwMinorVersion >= 1) ));
2183-
return bIsWindowsXPorLater;
2184-
}
2185-
21862169
// Spawn ourself as an elevated application. On failure, a message is
21872170
// displayed to the user - but this app will always terminate, even
21882171
// on error.
@@ -2238,15 +2221,15 @@ int DoInstall(void)
22382221

22392222
// See if we need to do the Vista UAC magic.
22402223
if (strcmp(user_access_control, "force")==0) {
2241-
if (PlatformSupportsUAC() && !MyIsUserAnAdmin()) {
2224+
if (!MyIsUserAnAdmin()) {
22422225
SpawnUAC();
22432226
return 0;
22442227
}
22452228
// already admin - keep going
22462229
} else if (strcmp(user_access_control, "auto")==0) {
22472230
// Check if it looks like we need UAC control, based
22482231
// on how Python itself was installed.
2249-
if (PlatformSupportsUAC() && !MyIsUserAnAdmin() && NeedAutoUAC()) {
2232+
if (!MyIsUserAnAdmin() && NeedAutoUAC()) {
22502233
SpawnUAC();
22512234
return 0;
22522235
}

PC/pyconfig.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ typedef int pid_t;
231231
#define hypot _hypot
232232
#endif
233233

234+
/* VS 2015 defines these names with a leading underscore */
235+
#if _MSC_VER >= 1900
236+
// #define timezone _timezone
237+
#define daylight _daylight
238+
#define tzname _tzname
239+
#endif
240+
234241
/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/
235242
#if _MSC_VER >= 1400 && _MSC_VER < 1600
236243
#define HAVE_SXS 1

0 commit comments

Comments
 (0)