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

bpo-40747: Make py_version_nodot 3_10 not 310 (PEP 641) #22858

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 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
4 changes: 2 additions & 2 deletions Doc/c-api/stable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ addition of a new field, or changing the type of a field, might not break the
API, but can break the ABI. As a consequence, extension modules need to be
recompiled for every Python release (although an exception is possible on Unix
when none of the affected interfaces are used). In addition, on Windows,
extension modules link with a specific pythonXY.dll and need to be recompiled to
link with a newer one.
extension modules link with a specific python3.X.dll and need to be recompiled
to link with a newer one.

Since Python 3.2, a subset of the API has been declared to guarantee a stable
ABI. Extension modules wishing to use this API (called "limited API") need to
Expand Down
2 changes: 1 addition & 1 deletion Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
html_static_path = ['tools/static']

# Output file base name for HTML help builder.
htmlhelp_basename = 'python' + release.replace('.', '')
htmlhelp_basename = 'python' + release

# Split the index
html_split_index = True
Expand Down
18 changes: 12 additions & 6 deletions Doc/extending/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ C++.

This chapter mentions a number of filenames that include an encoded Python
version number. These filenames are represented with the version number shown
as ``XY``; in practice, ``'X'`` will be the major version number and ``'Y'``
as ``X_Y``; in practice, ``'X'`` will be the major version number and ``'Y'``
will be the minor version number of the Python release you're working with. For
example, if you are using Python 2.2.1, ``XY`` will actually be ``22``.
example, if you are using Python 3.10.1, ``X_Y`` will actually be ``3_10``.


.. _win-cookbook:
Expand Down Expand Up @@ -109,17 +109,23 @@ Windows Python is built in Microsoft Visual C++; using other compilers may or
may not work (though Borland seems to). The rest of this section is MSVC++
specific.

When creating DLLs in Windows, you must pass :file:`pythonXY.lib` to the linker.
When creating DLLs in Windows, the linker expects to see the import library
:file:`pythonX_Y.lib` in order to find all the C-API functions available in
:file:`pythonX_Y.dll` (or in the case of universal c-extensions,
zooba marked this conversation as resolved.
Show resolved Hide resolved
:file:`pythonX.lib` and :file:`pythonX.dll` respectively. This is handled with
a pragma in :file:`pyconfig.h` so you do not need to add anything special in
your build.

To build two DLLs, spam and ni (which uses C functions found in spam), you could
use these commands::

cl /LD /I/python/include spam.c ../libs/pythonXY.lib
cl /LD /I/python/include ni.c spam.lib ../libs/pythonXY.lib
cl /LD /I/python/include spam.c
cl /LD /I/python/include ni.c spam.lib

The first command created three files: :file:`spam.obj`, :file:`spam.dll` and
:file:`spam.lib`. :file:`Spam.dll` does not contain any Python functions (such
as :c:func:`PyArg_ParseTuple`), but it does know how to find the Python code
thanks to :file:`pythonXY.lib`.
thanks to the pragma and linking to the proper import lib.

The second command created :file:`ni.dll` (and :file:`.obj` and :file:`.lib`),
which knows how to find the necessary functions from spam, and also from the
Expand Down
4 changes: 2 additions & 2 deletions Doc/faq/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Embedding the Python interpreter in a Windows app can be summarized as follows:
PyRun_SimpleString("import myApp"); // Import the shadow class.

5. There are two problems with Python's C API which will become apparent if you
use a compiler other than MSVC, the compiler used to build pythonNN.dll.
use a compiler other than MSVC, the compiler used to build python3.X.dll.

Problem 1: The so-called "Very High Level" functions that take FILE *
arguments will not work in a multi-compiler environment because each
Expand All @@ -239,7 +239,7 @@ Embedding the Python interpreter in a Windows app can be summarized as follows:
return _resultobj;

Alas, Py_None is a macro that expands to a reference to a complex data
structure called _Py_NoneStruct inside pythonNN.dll. Again, this code will
structure called _Py_NoneStruct inside python3.X.dll. Again, this code will
fail in a mult-compiler environment. Replace such code by:

.. code-block:: c
Expand Down
2 changes: 1 addition & 1 deletion Doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ if "%1" EQU "htmlhelp" (
cmd /S /C "%SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . "%BUILDDIR%\%1" %2 %3 %4 %5 %6 %7 %8 %9"

if "%1" EQU "htmlhelp" (
"%HTMLHELP%" "%BUILDDIR%\htmlhelp\python%DISTVERSION:.=%.hhp"
"%HTMLHELP%" "%BUILDDIR%\htmlhelp\python%DISTVERSION%.hhp"
rem hhc.exe seems to always exit with code 1, reset to 0 for less than 2
if not errorlevel 2 cmd /C exit /b 0
)
Expand Down
4 changes: 2 additions & 2 deletions Doc/using/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ directly accessed by end-users.
When extracted, the embedded distribution is (almost) fully isolated from the
user's system, including environment variables, system registry settings, and
installed packages. The standard library is included as pre-compiled and
optimized ``.pyc`` files in a ZIP, and ``python3.dll``, ``python37.dll``,
optimized ``.pyc`` files in a ZIP, and ``python3.dll``, ``python3.10.dll``,
``python.exe`` and ``pythonw.exe`` are all provided. Tcl/tk (including all
dependants, such as Idle), pip and the Python documentation are not included.

Expand Down Expand Up @@ -1030,7 +1030,7 @@ following advice will prevent conflicts with other installations:
environment variables, and also ignore :mod:`site` unless ``import site`` is
listed.

* If you are loading :file:`python3.dll` or :file:`python37.dll` in your own
* If you are loading :file:`python3.dll` or :file:`python3.10.dll` in your own
executable, explicitly call :c:func:`Py_SetPath` or (at least)
:c:func:`Py_SetProgramName` before :c:func:`Py_Initialize`.

Expand Down
11 changes: 11 additions & 0 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ Other Language Changes
:meth:`~object.__index__` method).
(Contributed by Serhiy Storchaka in :issue:`37999`.)

* The ``nodot`` version number has been changed to ``3_10`` for clarity
(:issue:`40747`)

New Modules
===========
Expand Down Expand Up @@ -295,6 +297,15 @@ Build Changes
* :mod:`sqlite3` requires SQLite 3.7.3 or higher.
(Contributed by Sergey Fedoseev and Erlend E. Aasland :issue:`40744`.)

* The main Python DLL on Windows is now named :file:`python3.10.dll` (previously
there was no dot between the two version numbers).

* The default installation directory on Windows is now named ``Python3_10`` or
``Python3_10-32`` (previously there was no underscore between the two version
numbers).

* The default standard library ZIP file is now named ``python3.10.zip`` on all
platforms (previously there was no dot between the two version numbers).


C API Changes
Expand Down
2 changes: 1 addition & 1 deletion Include/pythonrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
/* A function flavor is also exported by libpython. It is required when
libpython is accessed directly rather than using header files which defines
macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
export functions in pythonXX.dll. */
export functions in pythonX.X.dll. */
PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l);
PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
Expand Down
2 changes: 1 addition & 1 deletion Lib/distutils/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def finalize_options(self):
'dist_fullname': self.distribution.get_fullname(),
'py_version': py_version,
'py_version_short': '%d.%d' % sys.version_info[:2],
'py_version_nodot': '%d%d' % sys.version_info[:2],
'py_version_nodot': '%d_%d' % sys.version_info[:2],
'sys_prefix': prefix,
'prefix': prefix,
'sys_exec_prefix': exec_prefix,
Expand Down
2 changes: 1 addition & 1 deletion Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def _get_path(userbase):
version = sys.version_info

if os.name == 'nt':
ver_nodot = sys.winver.replace('.', '')
ver_nodot = sys.winver.replace('.', '_')
return f'{userbase}\\Python{ver_nodot}\\site-packages'

if sys.platform == 'darwin' and sys._framework:
Expand Down
4 changes: 2 additions & 2 deletions Lib/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

_PY_VERSION = sys.version.split()[0]
_PY_VERSION_SHORT = '%d.%d' % sys.version_info[:2]
_PY_VERSION_SHORT_NO_DOT = '%d%d' % sys.version_info[:2]
_PY_VERSION_SHORT_NO_DOT = '%d_%d' % sys.version_info[:2]
_PREFIX = os.path.normpath(sys.prefix)
_BASE_PREFIX = os.path.normpath(sys.base_prefix)
_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
Expand Down Expand Up @@ -545,7 +545,7 @@ def get_config_vars(*args):
# sys.abiflags may not be defined on all platforms.
_CONFIG_VARS['abiflags'] = ''
try:
_CONFIG_VARS['py_version_nodot_plat'] = sys.winver.replace('.', '')
_CONFIG_VARS['py_version_nodot_plat'] = sys.winver.replace('.', '_')
except AttributeError:
_CONFIG_VARS['py_version_nodot_plat'] = ''

Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,9 +1172,9 @@ def tmpdir_with_python(self):
tmpdir = os.path.realpath(tmpdir)

if MS_WINDOWS:
# Copy pythonXY.dll (or pythonXY_d.dll)
# Copy pythonX_Y.dll (or pythonX_Y_d.dll)
ver = sys.version_info
dll = f'python{ver.major}{ver.minor}'
dll = f'python{ver.major}_{ver.minor}'
dll3 = f'python{ver.major}'
if debug_build(sys.executable):
dll += '_d'
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ def test_osx_ext_suffix(self):
suffix = sysconfig.get_config_var('EXT_SUFFIX')
self.assertTrue(suffix.endswith('-darwin.so'), suffix)

def test_SOABI_consistency(self):
soabi = sysconfig.get_config_var('SOABI')
pynodot = sysconfig.get_config_var('py_version_nodot')
if soabi is not None:
soabi_pyver = soabi.split('-')[1]
self.assertTrue(soabi_pyver.startswith(pynodot))

class MakefileTests(unittest.TestCase):

@unittest.skipIf(sys.platform.startswith('win'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The PEP 425 python tag, taken from ``py_version_nodot``, adds a ``_`` so ``cp310`` is now ``cp3_10``.
2 changes: 1 addition & 1 deletion Modules/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ calculate_zip_path(PyCalculatePath *calculate)

/* Path: <platlibdir> / "pythonXY.zip" */
wchar_t *path = joinpath2(calculate->platlibdir,
L"python" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION)
L"python" Py_STRINGIFY(PY_MAJOR_VERSION) L"." Py_STRINGIFY(PY_MINOR_VERSION)
L".zip");
if (path == NULL) {
return _PyStatus_NO_MEMORY();
Expand Down
4 changes: 2 additions & 2 deletions PC/bdist_wininst/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -1683,10 +1683,10 @@ SelectPythonDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
&py_major, &py_minor);
if (result == 2) {
#ifdef _DEBUG
wsprintf(pythondll, "python%d%d_d.dll",
wsprintf(pythondll, "python%d_%d_d.dll",
py_major, py_minor);
#else
wsprintf(pythondll, "python%d%d.dll",
wsprintf(pythondll, "python%d_%d.dll",
py_major, py_minor);
#endif
}
Expand Down
8 changes: 4 additions & 4 deletions PC/getpathp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
This describes how sys.path is formed on Windows. It describes the
functionality, not the implementation (ie, the order in which these
are actually fetched is different). The presence of a python._pth or
pythonXY._pth file alongside the program overrides these rules - see
python3.X._pth file alongside the program overrides these rules - see
below.

* Python always adds an empty entry at the start, which corresponds
Expand Down Expand Up @@ -40,8 +40,8 @@

If a '._pth' file exists adjacent to the executable with the same base name
(e.g. python._pth adjacent to python.exe) or adjacent to the shared library
(e.g. python36._pth adjacent to python36.dll), it is used in preference to
the above process. The shared library file takes precedence over the
(e.g. python3.10._pth adjacent to python3.10.dll), it is used in preference
to the above process. The shared library file takes precedence over the
executable. The path file must contain a list of paths to add to sys.path,
one per line. Each path is relative to the directory containing the file.
Blank lines and comments beginning with '#' are permitted.
Expand Down Expand Up @@ -1112,7 +1112,7 @@ _Py_CheckPython3(void)
}
python3_checked = 1;

/* If there is a python3.dll next to the python3y.dll,
/* If there is a python3.dll next to the python3.x.dll,
use that DLL */
if (!get_dllpath(py3path)) {
reduce(py3path);
Expand Down
8 changes: 4 additions & 4 deletions PC/layout/support/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def _get_suffix(field4):
VER_FIELD3 = VER_MICRO << 8 | VER_FIELD4
VER_DOT = "{}.{}".format(VER_MAJOR, VER_MINOR)

PYTHON_DLL_NAME = "python{}{}.dll".format(VER_MAJOR, VER_MINOR)
PYTHON_DLL_NAME = "python{}_{}.dll".format(VER_MAJOR, VER_MINOR)
PYTHON_STABLE_DLL_NAME = "python{}.dll".format(VER_MAJOR)
PYTHON_ZIP_NAME = "python{}{}.zip".format(VER_MAJOR, VER_MINOR)
PYTHON_PTH_NAME = "python{}{}._pth".format(VER_MAJOR, VER_MINOR)
PYTHON_ZIP_NAME = "python{}_{}.zip".format(VER_MAJOR, VER_MINOR)
PYTHON_PTH_NAME = "python{}_{}._pth".format(VER_MAJOR, VER_MINOR)

PYTHON_CHM_NAME = "python{}{}{}{}.chm".format(
PYTHON_CHM_NAME = "python{}_{}{}{}.chm".format(
VER_MAJOR, VER_MINOR, VER_MICRO, VER_SUFFIX
)
4 changes: 2 additions & 2 deletions PC/pyconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
file in their Makefile (other compilers are
generally taken care of by distutils.) */
# if defined(_DEBUG)
# pragma comment(lib,"python310_d.lib")
# pragma comment(lib,"python3.10_d.lib")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn’t it be better to consistently use _ everywhere? Then no one has to think which to use.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other platforms already use dots in the equivalent filename. We decided on consistency there (though if I can't fix the crashes, we may roll back this part entirely and just change packaging stuff).

# elif defined(Py_LIMITED_API)
# pragma comment(lib,"python3.lib")
# else
# pragma comment(lib,"python310.lib")
# pragma comment(lib,"python3.10.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
Expand Down
81 changes: 0 additions & 81 deletions PC/readme.txt

This file was deleted.

30 changes: 0 additions & 30 deletions PC/testpy.py

This file was deleted.

Loading