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 #20333

Closed
wants to merge 14 commits into from
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 @@ -267,7 +267,7 @@ def _get_path(userbase):
version = sys.version_info

if os.name == 'nt':
return f'{userbase}\\Python{version[0]}{version[1]}\\site-packages'
return f'{userbase}\\Python{version[0]}_{version[1]}\\site-packages'

if sys.platform == 'darwin' and sys._framework:
return f'{userbase}/lib/python/site-packages'
Expand Down
2 changes: 1 addition & 1 deletion 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
7 changes: 7 additions & 0 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,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``.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The PEP 425 python tag, taken from ``py_version_nodot``, adds a ``_`` so ``cp310`` is now ``cp3_10``.
The PEP 425 python tag, taken from ``py_version_nodot``, adds a ``_`` so ``cp310`` is now ``cp3_10``.
Patch by Matti Picus.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of the other blurbs in that directory have a contributor name.

Copy link
Member

Choose a reason for hiding this comment

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

That doesn't mean the other news entries are wrong. 😉 (And this is coming from the person who created this workflow, so I can say with certainty you can put your name in the news entry.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer not to, but won't stop you from commiting the change.

4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -15295,15 +15295,15 @@ $as_echo_n "checking ABIFLAGS... " >&6; }
$as_echo "$ABIFLAGS" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SOABI" >&5
$as_echo_n "checking SOABI... " >&6; }
SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
SOABI='cpython-'`echo $VERSION | tr "." "_"`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
$as_echo "$SOABI" >&6; }

# Release and debug (Py_DEBUG) ABI are compatible, but not Py_TRACE_REFS ABI
if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then
# Similar to SOABI but remove "d" flag from ABIFLAGS

ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
ALT_SOABI='cpython-'`echo $VERSION | tr -d "." "_"``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}

cat >>confdefs.h <<_ACEOF
#define ALT_SOABI "${ALT_SOABI}"
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4737,14 +4737,14 @@ AC_SUBST(SOABI)
AC_MSG_CHECKING(ABIFLAGS)
AC_MSG_RESULT($ABIFLAGS)
AC_MSG_CHECKING(SOABI)
SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
SOABI='cpython-'`echo $VERSION | tr -d "." "_"`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
AC_MSG_RESULT($SOABI)

# Release and debug (Py_DEBUG) ABI are compatible, but not Py_TRACE_REFS ABI
if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then
# Similar to SOABI but remove "d" flag from ABIFLAGS
AC_SUBST(ALT_SOABI)
ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
ALT_SOABI='cpython-'`echo $VERSION | tr -d "." "_"``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
Copy link
Member

Choose a reason for hiding this comment

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

On macOS, at least,

$  ./configure --with-pydebug
[...]
checking SOABI... cpython-3_10d-darwin
usage: tr [-Ccsu] string1 string2
       tr [-Ccu] -d string1
       tr [-Ccu] -s string1
       tr [-Ccu] -ds string1 string2
checking LDVERSION... $(VERSION)$(ABIFLAGS)
[...]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh. Strange it passes CI. Is the change on line 4740 also problematic? I cannot reproduce, could you try removing the " so that the "." "_" becomes . _

Copy link
Member

@ned-deily ned-deily May 28, 2020

Choose a reason for hiding this comment

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

The tr error doesn't cause the configure run to fail. It happens on the Linux CI runs, too: from the Github Ubuntu test:

676 checking SOABI... cpython-3_10d-x86_64-linux-gnu
677 tr: extra operand '_'
678 Only one string may be given when deleting without squeezing repeats.
679 Try 'tr --help' for more information.
680 checking LDVERSION... $(VERSION)$(ABIFLAGS)

(You don't see it in the log for the most recent Travis CI run because it appears that the build environment for the PR is cached and it didn't rerun configure.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed by removing the -d from the tr command. Checked it by rerunning autoconf to recreate configure from configure.am.

Copy link
Member

Choose a reason for hiding this comment

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

(FWIW the error makes sense: tr is either original replacement or -d original to delete)

AC_DEFINE_UNQUOTED(ALT_SOABI, "${ALT_SOABI}",
[Alternative SOABI used in debug build to load C extensions built in release mode])
fi
Expand Down