Skip to content
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

Added some more Microsoft compilers to Lib/distutils and a fix to adjust the majorVersion for VS2015 #120

Merged
merged 2 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Lib/distutils/cygwinccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ def get_msvcr():
elif msc_ver == '1500':
# VS2008 / MSVC 9.0
return ['msvcr90']
elif msc_ver == '1600':
# VS2010 / MSVC 10.0
return ['msvcr100']
elif msc_ver == '1700':
# VS2012 / MSVC 11.0
return ['msvcr110']
elif msc_ver == '1800':
# VS2013 / MSVC 12.0
return ['msvcr120']
elif msc_ver == '1900':
# VS2015 / MSVC 14.0
return ['vcruntime140']
else:
raise ValueError("Unknown MS Compiler version %s " % msc_ver)

Expand Down
4 changes: 4 additions & 0 deletions Lib/distutils/msvc9compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ def get_build_version():
s, rest = sys.version[i:].split(" ", 1)
majorVersion = int(s[:-2]) - 6
minorVersion = int(s[2:3]) / 10.0

# There is no majorVersion of 13 (VS2013 == 1800, and VS2015 == 1900)
if majorVersion == 13: majorVersion = 14

# I don't think paths are affected by minor version in version 6
if majorVersion == 6:
minorVersion = 0
Expand Down
4 changes: 4 additions & 0 deletions Lib/distutils/msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ def get_build_version():
s, rest = sys.version[i:].split(" ", 1)
majorVersion = int(s[:-2]) - 6
minorVersion = int(s[2:3]) / 10.0

# There is no majorVersion of 13 (VS2013 == 1800, and VS2015 == 1900)
if majorVersion == 13: majorVersion = 14

# I don't think paths are affected by minor version in version 6
if majorVersion == 6:
minorVersion = 0
Expand Down
58 changes: 56 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

#include "Python.h"
#include "structseq.h"
#ifndef MS_WINDOWS
#ifdef MS_WINDOWS
#include <Windows.h>
#else
#include "posixmodule.h"
#endif

Expand Down Expand Up @@ -282,6 +284,14 @@ extern int lstat(const char *, struct stat *);
#define pclose _pclose
#endif /* _MSC_VER */

#if !defined(SEP)
#ifdef MS_WINDOWS
#define SEP "\\"
#else
#define SEP "/"
#endif
#endif

#if defined(PYCC_VACPP) && defined(PYOS_OS2)
#include <io.h>
#endif /* OS2 */
Expand Down Expand Up @@ -533,8 +543,48 @@ _PyInt_FromDev(PY_LONG_LONG v)
# define _PyInt_FromDev PyInt_FromLong
#endif

#if defined _MSC_VER && _MSC_VER >= 1700
void
_PyInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved)
{
}

int
_PyVerify_fd(int fd)
{
HANDLE hFd;
_invalid_parameter_handler oldHandler;

oldHandler = _set_invalid_parameter_handler(_PyInvalidParameterHandler);

#if defined _MSC_VER && _MSC_VER >= 1400
hFd = _get_osfhandle(fd);
if (hFd == INVALID_HANDLE_VALUE)
goto fail;
if ((fd < 0) || _isatty(fd))
goto fail;

// FIXME: ensure that file descriptor is open too
_set_invalid_parameter_handler(oldHandler);
return 1;

fail:
_set_invalid_parameter_handler(oldHandler);
return 0;
}

static int
_PyVerify_fd_dup2(int fd1, int fd2)
{
_invalid_parameter_handler oldHandler;

if (!_PyVerify_fd(fd1))
return 0;
if (fd2 < 0)
return 0;
return 1;
}

#elif defined _MSC_VER && _MSC_VER >= 1400
/* Microsoft CRT in VS2005 and higher will verify that a filehandle is
* valid and raise an assertion if it isn't.
* Normally, an invalid fd is likely to be a C program error and therefore
Expand Down Expand Up @@ -5377,6 +5427,10 @@ win32_popen4(PyObject *self, PyObject *args)
return f;
}

#if !defined(SEP)
#define SEP "\\"
#endif

static BOOL
_PyPopenCreateProcess(char *cmdstring,
HANDLE hStdin,
Expand Down
4 changes: 4 additions & 0 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ time_clock(PyObject *self, PyObject *unused)
#endif /* HAVE_CLOCK */

#if defined(MS_WINDOWS) && !defined(__BORLANDC__)
#include <time.h>
#define timezone _timezone
#define daylight _daylight
#define tzname _tzname
/* Due to Mark Hammond and Tim Peters */
static PyObject *
time_clock(PyObject *self, PyObject *unused)
Expand Down