mirror of https://github.com/python/cpython
#22980 Adds platform and version tags to .pyd files
This commit is contained in:
parent
09bd9ec9b3
commit
03a144bb6a
|
@ -2,9 +2,11 @@ from . import util as test_util
|
|||
machinery = test_util.import_importlib('importlib.machinery')
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
from test import support
|
||||
from distutils.util import get_platform
|
||||
from contextlib import contextmanager
|
||||
from .util import temp_module
|
||||
|
||||
|
@ -83,3 +85,25 @@ class WindowsRegistryFinderTests:
|
|||
(Frozen_WindowsRegistryFinderTests,
|
||||
Source_WindowsRegistryFinderTests
|
||||
) = test_util.test_both(WindowsRegistryFinderTests, machinery=machinery)
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith('win'), 'requires Windows')
|
||||
class WindowsExtensionSuffixTests:
|
||||
def test_tagged_suffix(self):
|
||||
suffixes = self.machinery.EXTENSION_SUFFIXES
|
||||
expected_tag = ".cp{0.major}{0.minor}-{1}.pyd".format(sys.version_info,
|
||||
re.sub('[^a-zA-Z0-9]', '_', get_platform()))
|
||||
try:
|
||||
untagged_i = suffixes.index(".pyd")
|
||||
except ValueError:
|
||||
untagged_i = suffixes.index("_d.pyd")
|
||||
expected_tag = "_d" + expected_tag
|
||||
|
||||
self.assertIn(expected_tag, suffixes)
|
||||
|
||||
# Ensure the tags are in the correct order
|
||||
tagged_i = suffixes.index(expected_tag)
|
||||
self.assertLess(tagged_i, untagged_i)
|
||||
|
||||
(Frozen_WindowsExtensionSuffixTests,
|
||||
Source_WindowsExtensionSuffixTests
|
||||
) = test_util.test_both(WindowsExtensionSuffixTests, machinery=machinery)
|
||||
|
|
|
@ -1584,6 +1584,9 @@ Windows
|
|||
- Issue #10747: Use versioned labels in the Windows start menu.
|
||||
Patch by Olive Kilburn.
|
||||
|
||||
- Issue #22980: .pyd files with a version and platform tag (for example,
|
||||
".cp35-win32.pyd") will now be loaded in preference to those without tags.
|
||||
|
||||
What's New in Python 3.4.0?
|
||||
===========================
|
||||
|
||||
|
|
|
@ -145,9 +145,11 @@ WIN32 is still required for the locale module.
|
|||
#if defined(_M_IA64)
|
||||
#define COMPILER _Py_PASTE_VERSION("64 bit (Itanium)")
|
||||
#define MS_WINI64
|
||||
#define PYD_PLATFORM_TAG "win_ia64"
|
||||
#elif defined(_M_X64) || defined(_M_AMD64)
|
||||
#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
|
||||
#define MS_WINX64
|
||||
#define PYD_PLATFORM_TAG "win_amd64"
|
||||
#else
|
||||
#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
|
||||
#endif
|
||||
|
@ -193,8 +195,10 @@ typedef _W64 int ssize_t;
|
|||
#if defined(MS_WIN32) && !defined(MS_WIN64)
|
||||
#if defined(_M_IX86)
|
||||
#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
|
||||
#define PYD_PLATFORM_TAG "win32"
|
||||
#elif defined(_M_ARM)
|
||||
#define COMPILER _Py_PASTE_VERSION("32 bit (ARM)")
|
||||
#define PYD_PLATFORM_TAG "win_arm"
|
||||
#else
|
||||
#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)")
|
||||
#endif
|
||||
|
|
|
@ -96,6 +96,10 @@
|
|||
|
||||
<!-- The name of the resulting pythonXY.dll (without the extension) -->
|
||||
<PyDllName>python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt)</PyDllName>
|
||||
|
||||
<!-- The version and platform tag to include in .pyd filenames -->
|
||||
<PydTag Condition="$(Platform) == 'Win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
|
||||
<PydTag Condition="$(Platform) == 'x64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Displays the calculated version info -->
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <ctype.h>
|
||||
|
||||
#include "importdl.h"
|
||||
#include "patchlevel.h"
|
||||
#include <windows.h>
|
||||
|
||||
// "activation context" magic - see dl_nt.c...
|
||||
|
@ -17,16 +18,28 @@ extern ULONG_PTR _Py_ActivateActCtx();
|
|||
void _Py_DeactivateActCtx(ULONG_PTR cookie);
|
||||
#endif
|
||||
|
||||
const char *_PyImport_DynLoadFiletab[] = {
|
||||
#ifdef _DEBUG
|
||||
"_d.pyd",
|
||||
#define PYD_DEBUG_SUFFIX "_d"
|
||||
#else
|
||||
".pyd",
|
||||
#define PYD_DEBUG_SUFFIX ""
|
||||
#endif
|
||||
|
||||
#define STRINGIZE2(x) #x
|
||||
#define STRINGIZE(x) STRINGIZE2(x)
|
||||
#ifdef PYD_PLATFORM_TAG
|
||||
#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" STRINGIZE(PY_MAJOR_VERSION) STRINGIZE(PY_MINOR_VERSION) "-" PYD_PLATFORM_TAG ".pyd"
|
||||
#else
|
||||
#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" STRINGIZE(PY_MAJOR_VERSION) STRINGIZE(PY_MINOR_VERSION) ".pyd"
|
||||
#endif
|
||||
|
||||
#define PYD_UNTAGGED_SUFFIX PYD_DEBUG_SUFFIX ".pyd"
|
||||
|
||||
const char *_PyImport_DynLoadFiletab[] = {
|
||||
PYD_TAGGED_SUFFIX,
|
||||
PYD_UNTAGGED_SUFFIX,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/* Case insensitive string compare, to avoid any dependencies on particular
|
||||
C RTL implementations */
|
||||
|
||||
|
|
Loading…
Reference in New Issue