[PATCH] [WIP] gnu: Add python-3.11.

  • Open
  • quality assurance status badge
Details
5 participants
  • Andreas Enge
  • John Kehayias
  • Lars-Dominik Braun
  • Tanguy Le Carrour
  • Simon Tournier
Owner
unassigned
Submitted by
Tanguy Le Carrour
Severity
normal
T
T
Tanguy Le Carrour wrote on 21 Dec 2022 16:32
(address . guix-patches@gnu.org)(name . Tanguy Le Carrour)(address . tanguy@bioneland.org)
20221221153230.27764-1-tanguy@bioneland.org
Hi Guix!

I'm currently working on packaging Python 3.11. It seems to produce a
working `python3`, but there's still a lot I have to work on!

I had to copy/paste 3 snippets (see `TODO`) just to modify a few lines in them.
The problem might come from the fact that this package definition
inherits from `python-3.9` that itself inherits from `python-2`.
Might also be because I'm still (really) bad at writing scheme/guile code! ^_^'

This leads me to my first question: wouldn't it be better to write a "fresh"
package definition not inheriting from `python-2` (deprecated since 2020) and
`python-3.9` (soon to be replaced)?

Another question would be: should I first write a package definition for
`python-3.10` so we have it in the history and one could use the time
machine to install it?

Any help or advice would be highly appreciated!

Best regards,
Tanguy

* gnu/packages/python.scm (python-3.11): New variable.
---
.../patches/python-3.11-fix-tests.patch | 418 ++++++++++++++++++
gnu/packages/python.scm | 118 ++++-
2 files changed, 535 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/python-3.11-fix-tests.patch

Toggle diff (411 lines)
diff --git a/gnu/packages/patches/python-3.11-fix-tests.patch b/gnu/packages/patches/python-3.11-fix-tests.patch
new file mode 100644
index 0000000000..f160968a27
--- /dev/null
+++ b/gnu/packages/patches/python-3.11-fix-tests.patch
@@ -0,0 +1,418 @@
+From f0698133e7d6c353a3e6ae0fc62e57ba558a9bc0 Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Date: Wed, 28 Oct 2020 22:55:05 -0400
+Subject: [PATCH] Skip problematic Python 3 tests in Guix.
+
+A subset of the hunks in this patch is tracked upstream at
+https://bugs.python.org/issue38845, which was contributed by Tanguy Le
+Carrour <tanguy@bioneland.org>.
+---
+ Lib/ctypes/test/test_callbacks.py | 3 +++
+ Lib/ctypes/test/test_find.py | 1 +
+ Lib/ctypes/test/test_libc.py | 3 +++
+ Lib/distutils/tests/test_archive_util.py | 2 ++
+ Lib/distutils/tests/test_sdist.py | 1 +
+ Lib/test/_test_multiprocessing.py | 2 ++
+ Lib/test/test_asyncio/test_base_events.py | 2 ++
+ Lib/test/test_generators.py | 1 +
+ Lib/test/test_pathlib.py | 3 +--
+ Lib/test/test_pdb.py | 4 ++--
+ Lib/test/test_regrtest.py | 2 ++
+ Lib/test/test_resource.py | 1 +
+ Lib/test/test_shutil.py | 2 ++
+ Lib/test/test_signal.py | 4 ++++
+ Lib/test/test_socket.py | 8 ++++++++
+ Lib/test/test_spwd.py | 6 ++----
+ Lib/test/test_tarfile.py | 9 ++++++---
+ Lib/test/test_threading.py | 3 +++
+ Lib/test/test_unicodedata.py | 1 +
+ Tools/scripts/run_tests.py | 2 +-
+ 20 files changed, 48 insertions(+), 12 deletions(-)
+
+diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
+index d8e9c5a760..94fc5929c9 100644
+--- a/Lib/ctypes/test/test_callbacks.py
++++ b/Lib/ctypes/test/test_callbacks.py
+@@ -5,6 +5,7 @@ from test import support
+ from ctypes import *
+ from ctypes.test import need_symbol
+ import _ctypes_test
++import platform
+
+ class Callbacks(unittest.TestCase):
+ functype = CFUNCTYPE
+@@ -178,6 +179,8 @@ class SampleCallbacksTestCase(unittest.TestCase):
+
+ self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
+
++ @unittest.skipIf(platform.machine() in ['mips64'],
++ "This test fails on this platform")
+ def test_issue_8959_a(self):
+ from ctypes.util import find_library
+ libc_path = find_library("c")
+diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
+index 92ac1840ad..c8eb75dedd 100644
+--- a/Lib/ctypes/test/test_find.py
++++ b/Lib/ctypes/test/test_find.py
+@@ -116,6 +116,7 @@ class FindLibraryLinux(unittest.TestCase):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
+ self.assertNotEqual(find_library('c'), None)
+
++ @unittest.skipIf(True, "ldconfig is not used on Guix")
+ def test_find_library_with_ld(self):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
+ unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
+diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
+index 56285b5ff8..c088ab3db8 100644
+--- a/Lib/ctypes/test/test_libc.py
++++ b/Lib/ctypes/test/test_libc.py
+@@ -2,6 +2,7 @@ import unittest
+
+ from ctypes import *
+ import _ctypes_test
++import platform
+
+ lib = CDLL(_ctypes_test.__file__)
+
+@@ -17,6 +18,8 @@ class LibTest(unittest.TestCase):
+ import math
+ self.assertEqual(lib.my_sqrt(2.0), math.sqrt(2.0))
+
++ @unittest.skipIf(platform.machine() in ['mips64'],
++ "This test fails on this platform")
+ def test_qsort(self):
+ comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
+ lib.my_qsort.argtypes = c_void_p, c_size_t, c_size_t, comparefunc
+diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py
+index e9aad0e40f..8bbaa51ee5 100644
+--- a/Lib/distutils/tests/test_archive_util.py
++++ b/Lib/distutils/tests/test_archive_util.py
+@@ -333,6 +333,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
+ self.assertEqual(os.path.basename(res), 'archive.tar.xz')
+ self.assertEqual(self._tarinfo(res), self._created_files)
+
++ @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
+ def test_make_archive_owner_group(self):
+ # testing make_archive with owner and group, with various combinations
+ # this works even if there's not gid/uid support
+@@ -362,6 +363,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
+
+ @unittest.skipUnless(ZLIB_SUPPORT, "Requires zlib")
+ @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
++ @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
+ def test_tarfile_root_owner(self):
+ tmpdir = self._create_files()
+ base_name = os.path.join(self.mkdtemp(), 'archive')
+diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
+index 23db126959..6e2329df7d 100644
+--- a/Lib/distutils/tests/test_sdist.py
++++ b/Lib/distutils/tests/test_sdist.py
+@@ -443,6 +443,7 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
+ "The tar command is not found")
+ @unittest.skipIf(find_executable('gzip') is None,
+ "The gzip command is not found")
++ @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
+ def test_make_distribution_owner_group(self):
+ # now building a sdist
+ dist, cmd = self.get_cmd()
+diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
+index e47905c863..31a5a9c308 100644
+--- a/Lib/test/_test_multiprocessing.py
++++ b/Lib/test/_test_multiprocessing.py
+@@ -1577,6 +1577,7 @@ class _TestCondition(BaseTestCase):
+ if pid is not None:
+ os.kill(pid, signal.SIGINT)
+
++ @unittest.skipIf(True, "This fails for unknown reasons on Guix")
+ def test_wait_result(self):
+ if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
+ pid = os.getpid()
+@@ -3905,6 +3906,7 @@ class _TestSharedMemory(BaseTestCase):
+ sms.close()
+
+ @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
+ # bpo-36368: protect SharedMemoryManager server process from
+ # KeyboardInterrupt signals.
+diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
+index 533d5cc7f5..c4f860cc3b 100644
+--- a/Lib/test/test_asyncio/test_base_events.py
++++ b/Lib/test/test_asyncio/test_base_events.py
+@@ -1341,6 +1341,8 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
+ self._test_create_connection_ip_addr(m_socket, False)
+
+ @patch_socket
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_create_connection_service_name(self, m_socket):
+ m_socket.getaddrinfo = socket.getaddrinfo
+ sock = m_socket.socket.return_value
+diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
+index 3bf1522808..04bac8a7db 100644
+--- a/Lib/test/test_generators.py
++++ b/Lib/test/test_generators.py
+@@ -33,6 +33,7 @@ class SignalAndYieldFromTest(unittest.TestCase):
+ else:
+ return "FAILED"
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
+ def test_raise_and_yield_from(self):
+ gen = self.generator1()
+ gen.send(None)
+diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
+index 3da35710b9..5404f9193d 100644
+--- a/Lib/test/test_pathlib.py
++++ b/Lib/test/test_pathlib.py
+@@ -2408,10 +2408,7 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
+ self.assertEqual(given, expect)
+ self.assertEqual(set(p.rglob("FILEd*")), set())
+
+- @unittest.skipUnless(hasattr(pwd, 'getpwall'),
+- 'pwd module does not expose getpwall()')
+- @unittest.skipIf(sys.platform == "vxworks",
+- "no home directory on VxWorks")
++ @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
+ def test_expanduser(self):
+ P = self.cls
+ support.import_module('pwd')
+diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
+index 8016f81e5a..10190486b4 100644
+--- a/Lib/test/test_pdb.py
++++ b/Lib/test/test_pdb.py
+@@ -1219,11 +1219,11 @@ def test_pdb_issue_20766():
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 1: <built-in function default_int_handler>
++ pdb 1: Handlers.SIG_IGN
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 2: <built-in function default_int_handler>
++ pdb 2: Handlers.SIG_IGN
+ """
+
+
+diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
+index a77638b10a..2069b349a8 100644
+--- a/Lib/test/test_regrtest.py
++++ b/Lib/test/test_regrtest.py
+@@ -811,6 +811,7 @@ class ArgsTestCase(BaseTestCase):
+ output = self.run_tests('--fromfile', filename)
+ self.check_executed_tests(output, tests)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_interrupted(self):
+ code = TEST_INTERRUPTED
+ test = self.create_test('sigint', code=code)
+@@ -828,6 +829,7 @@ class ArgsTestCase(BaseTestCase):
+ % (self.TESTNAME_REGEX, len(tests)))
+ self.check_line(output, regex)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_slowest_interrupted(self):
+ # Issue #25373: test --slowest with an interrupted test
+ code = TEST_INTERRUPTED
+diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
+index e5ece5284c..5299e54507 100644
+--- a/Lib/test/test_resource.py
++++ b/Lib/test/test_resource.py
+@@ -148,6 +148,7 @@ class ResourceTest(unittest.TestCase):
+
+ @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
+ @support.requires_linux_version(2, 6, 36)
++ @unittest.skipIf(True, "Bug: the PermissionError is not raised")
+ def test_prlimit(self):
+ self.assertRaises(TypeError, resource.prlimit)
+ self.assertRaises(ProcessLookupError, resource.prlimit,
+diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
+index e19af64be0..1b893df6fa 100644
+--- a/Lib/test/test_shutil.py
++++ b/Lib/test/test_shutil.py
+@@ -1427,6 +1427,7 @@ class TestArchives(BaseTest, unittest.TestCase):
+ base_name = os.path.join(tmpdir, 'archive')
+ self.assertRaises(ValueError, make_archive, base_name, 'xxx')
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ def test_make_archive_owner_group(self):
+ # testing make_archive with owner and group, with various combinations
+@@ -1455,6 +1456,7 @@ class TestArchives(BaseTest, unittest.TestCase):
+ self.assertTrue(os.path.isfile(res))
+
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+ def test_tarfile_root_owner(self):
+diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
+index 45553a6a42..55623f01a3 100644
+--- a/Lib/test/test_signal.py
++++ b/Lib/test/test_signal.py
+@@ -78,7 +78,8 @@ class PosixTests(unittest.TestCase):
+ self.assertLess(len(s), signal.NSIG)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
+ @support.requires_subprocess()
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers exit via SIGINT."""
+ process = subprocess.run(
+@@ -128,7 +129,8 @@ class WindowsSignalTests(unittest.TestCase):
+ signal.signal(7, handler)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
+ @support.requires_subprocess()
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
+ # We don't test via os.kill(os.getpid(), signal.CTRL_C_EVENT) here
+@@ -1245,6 +1247,7 @@ class StressTest(unittest.TestCase):
+
+ class RaiseSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_sigint(self):
+ with self.assertRaises(KeyboardInterrupt):
+ signal.raise_signal(signal.SIGINT)
+@@ -1275,6 +1278,7 @@ class RaiseSignalTest(unittest.TestCase):
+
+ class PidfdSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @unittest.skipUnless(
+ hasattr(signal, "pidfd_send_signal"),
+ "pidfd support not built in",
+diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
+index aefba4f397..6c89f558d5 100755
+--- a/Lib/test/test_socket.py
++++ b/Lib/test/test_socket.py
+@@ -1009,6 +1009,8 @@ class GeneralModuleTests(unittest.TestCase):
+ if not fqhn in all_host_names:
+ self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
+
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_host_resolution(self):
+ for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:
+ self.assertEqual(socket.gethostbyname(addr), addr)
+@@ -1140,6 +1142,8 @@ class GeneralModuleTests(unittest.TestCase):
+ self.assertWarns(DeprecationWarning, socket.ntohs, k)
+ self.assertWarns(DeprecationWarning, socket.htons, k)
+
++ @unittest.skipUnless(os.path.exists("/etc/services"),
++ "getservbyname uses /etc/services, which is not in the chroot")
+ def testGetServBy(self):
+ eq = self.assertEqual
+ # Find one service that exists, then check all the related interfaces.
+@@ -1489,6 +1493,8 @@ class GeneralModuleTests(unittest.TestCase):
+ raise
+ self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ def testGetaddrinfo(self):
+ try:
+ socket.getaddrinfo('localhost', 80)
+@@ -1571,6 +1577,8 @@ class GeneralModuleTests(unittest.TestCase):
+ # only IP addresses are allowed
+ self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ @unittest.skipUnless(support.is_resource_enabled('network'),
+ 'network is not enabled')
+ def test_idna(self):
+diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
+index 07793c84c8..fec672bcbe 100644
+--- a/Lib/test/test_spwd.py
++++ b/Lib/test/test_spwd.py
+@@ -5,8 +5,7 @@ from test import support
+ spwd = support.import_module('spwd')
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
+- 'root privileges required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdRoot(unittest.TestCase):
+
+ def test_getspall(self):
+@@ -56,8 +55,7 @@ class TestSpwdRoot(unittest.TestCase):
+ self.assertRaises(TypeError, spwd.getspnam, bytes_name)
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
+- 'non-root user required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdNonRoot(unittest.TestCase):
+
+ def test_getspnam_exception(self):
+diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
+index 29cde91bf7..8d0f20e8bf 100644
+--- a/Lib/test/test_tarfile.py
++++ b/Lib/test/test_tarfile.py
+@@ -2607,9 +2607,12 @@ def root_is_uid_gid_0():
+ import pwd, grp
+ except ImportError:
+ return False
+- if pwd.getpwuid(0)[0] != 'root':
+- return False
+- if grp.getgrgid(0)[0] != 'root':
++ try:
++ if pwd.getpwuid(0)[0] != 'root':
++ return False
++ if grp.getgrgid(0)[0] != 'root':
++ return False
++ except KeyError:
+ return False
+ return True
+
+diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
+index c21cdf8eb7..6c9d575032 100644
+--- a/Lib/test/test_threading.py
++++ b/Lib/test/test_threading.py
+@@ -1398,5 +1398,6 @@ class MiscTestCase(unittest.TestCase):
+ signal.signal(signum, handler)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_subthread(self):
+ # Calling start_new_thread with a function that executes interrupt_main
+ # should raise KeyboardInterrupt upon completion.
+@@ -1409,6 +1410,8 @@ class InterruptMainTests(unittest.TestCase):
+ t.join()
+ t.join()
+
++
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_mainthread(self):
+ # Make sure that if interrupt_main is called in main thread that
+ # KeyboardInterrupt is raised instantly.
+diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
+index b552d2bd17..28b1144e15 100644
+--- a/Lib/test/test_unicodedata.py
++++ b/Lib/test/test_unicodedata.py
+@@ -309,6 +309,7 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
+ self.assertEqual(len(lines), 1,
+ r"\u%.4x should not be a linebreak" % i)
+
++@requires_resource('network')
+ class NormalizationTest(unittest.TestCase):
+ @staticmethod
+ def check_version(testfile):
+diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
+index bcfa5e943b..1f2484971b 100644
+--- a/Tools/scripts/run_
This message was truncated. Download the full message here.
S
S
Simon Tournier wrote on 6 Jan 2023 18:36
(name . Tanguy Le Carrour)(address . tanguy@bioneland.org)
877cxzh8ez.fsf@gmail.com
Hi Tanguy,

On Wed, 21 Dec 2022 at 16:32, Tanguy Le Carrour <tanguy@bioneland.org> wrote:

Toggle quote (4 lines)
> This leads me to my first question: wouldn't it be better to write a "fresh"
> package definition not inheriting from `python-2` (deprecated since 2020) and
> `python-3.9` (soon to be replaced)?

Yes, it would be nice to have Python 3 as the package definition. And
maybe Python 2 as inheriting from Python 3. :-)

Toggle quote (4 lines)
> Another question would be: should I first write a package definition
> for `python-3.10` so we have it in the history and one could use the
> time machine to install it?

Well, it appears to me fine to jump from 3.9 to 3.11 dropping 3.10.


Cheers,
simon
T
T
Tanguy LE CARROUR wrote on 9 Jan 2023 16:59
167327999599.20007.5827702388142340079@localhost
Hi Simon,

Believe it or not, I sent the patch before I went on vacation and… I kind
of forgot about it! ?


Quoting Simon Tournier (2023-01-06 18:36:36)
Toggle quote (9 lines)
> On Wed, 21 Dec 2022 at 16:32, Tanguy Le Carrour <tanguy@bioneland.org> wrote:
>
> > This leads me to my first question: wouldn't it be better to write a "fresh"
> > package definition not inheriting from `python-2` (deprecated since 2020) and
> > `python-3.9` (soon to be replaced)?
>
> Yes, it would be nice to have Python 3 as the package definition. And
> maybe Python 2 as inheriting from Python 3. :-)

I'm not saying that we should do the same but… Debian is dropping
support for Python 2 in the next release [1].



Toggle quote (6 lines)
> > Another question would be: should I first write a package definition
> > for `python-3.10` so we have it in the history and one could use the
> > time machine to install it?
>
> Well, it appears to me fine to jump from 3.9 to 3.11 dropping 3.10.

You know what they say, who can do more can do less! ?

Regards,

--
Tanguy
A
A
Andreas Enge wrote on 13 Mar 2023 00:35
Python 3.10 in core-updates
(address . 60240@debbugs.gnu.org)
ZA5hu77ADv4KJIw6@jurong
Hello Tanguy,

core-updates has Python 3.10.7, so you may wish to base your work on this
branch and submit it once the branch has been merged.

There python@3 still inherits from python2@2. But since it overwrites all
interesting fields, I think it would make sense to write a package definition
"from scratch" by copying fields such as home-page etc.

Good luck with packaging!

Andreas
J
J
John Kehayias wrote on 19 Feb 22:27 +0100
(name . Tanguy LE CARROUR)(address . tanguy@bioneland.org)
875xyk9mbc.fsf@protonmail.com
Hello,

I was curious about python 3.11 and dug up this issue so I thought I
would check in (CC'ing python-team and original people on the thread).

A link for a refresher: https://issues.guix.gnu.org/60240

On Mon, Mar 13, 2023 at 12:35 AM, Andreas Enge wrote:

Toggle quote (6 lines)
> Hello Tanguy,
>
> core-updates has Python 3.10.7, so you may wish to base your work on this
> branch and submit it once the branch has been merged.
>

Yes, we have and default to python-3.10 in master but it would be great
to have python-3.11. We could add this as "python-next" and start seeing
what packages can build with 3.11 before deciding if/when to switch
over.

Tanguy: have you tried your patch recently at all? Can we base it off of
3.10 and have a working 3.11 from what you started?

Thanks!
John

Toggle quote (7 lines)
> There python@3 still inherits from python2@2. But since it overwrites all
> interesting fields, I think it would make sense to write a package definition
> "from scratch" by copying fields such as home-page etc.
>
> Good luck with packaging!
>
> Andreas
T
T
Tanguy LE CARROUR wrote on 20 Feb 15:18 +0100
(name . John Kehayias)(address . john.kehayias@protonmail.com)
170843870653.26771.12370877944061551668@bioneland.org
Hi John,

Sorry for taking so long to reply, but... I was hiding under my desk...
ashamed to have forgotten this ticket! ?

Thanks for the reminder!


Quoting John Kehayias (2024-02-19 22:27:48)
Toggle quote (5 lines)
> A link for a refresher: https://issues.guix.gnu.org/60240
> On Mon, Mar 13, 2023 at 12:35 AM, Andreas Enge wrote:
> > core-updates has Python 3.10.7, so you may wish to base your work on this
> > branch and submit it once the branch has been merged.

I totally missed/forgot-to-answer-to Andreas’ message! **Rude!** ?
Sooo-sooorry!


Toggle quote (5 lines)
> Yes, we have and default to python-3.10 in master but it would be great
> to have python-3.11. We could add this as "python-next" and start seeing
> what packages can build with 3.11 before deciding if/when to switch
> over.

Actually, a year or so after, it would be great to have python-3.12! ?


Toggle quote (3 lines)
> Tanguy: have you tried your patch recently at all? Can we base it off of
> 3.10 and have a working 3.11 from what you started?

… at all! ?
I’ll try to work on that tomorrow!

--
Tanguy
T
T
Tanguy Le Carrour wrote on 21 Feb 13:13 +0100
[PATCH v2] gnu: Add python-3.12 and python-next.
(address . 60240@debbugs.gnu.org)
4832d706e706ced5aa8a52f1b63b1e676ea5fd3d.1708516654.git.tanguy@bioneland.org
Hi Guix,

Sorry it took me so long —thanks again John for the reminder!—, but I
eventually made it! I have a Python 3.12.2 running on my computer.

I created a brand new package definition for it, not inheriting from
`python-2`. I actually copied/pasted the `python-2` package definition,
removed what was specific to Python 2 and then copied over the things
specific to Python 3 from the `python-3.10` package definition.

There are still things here and there that I’m not happy with, though:
- skipping `test_pdb_issue_20766` doesn’t seem to work, so I modified
the expected output;
- I use the old style for `native-inputs`, for I was not sure how to
make the new style work with a `local-file`;
- I left the `(@ (gnu packages compression) zip)`, even though I’m not
sur why it’s better than "just" `zip`;
- When I apply the patch I get whitespace errors, but I don’t know how
those whitespace were introduced and how to get rid of them.

Btw, the patch targets the branch `python-team`.

Looking forwards to your comments!


* gnu/packages/python.scm (python-3.12, python-next): New variables.
* gnu/packages/patches/python-3.12-fix-tests.patch: New file.

Change-Id: Ie393b732a8863569578e72e62603b75a1655a34e
---
.../patches/python-3.12-fix-tests.patch | 334 ++++++++++++++++
gnu/packages/python.scm | 378 +++++++++++++++++-
2 files changed, 711 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/python-3.12-fix-tests.patch

Toggle diff (406 lines)
diff --git a/gnu/packages/patches/python-3.12-fix-tests.patch b/gnu/packages/patches/python-3.12-fix-tests.patch
new file mode 100644
index 0000000000..206a7223f5
--- /dev/null
+++ b/gnu/packages/patches/python-3.12-fix-tests.patch
@@ -0,0 +1,334 @@
+From f0698133e7d6c353a3e6ae0fc62e57ba558a9bc0 Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Date: Wed, 28 Oct 2020 22:55:05 -0400
+Subject: [PATCH] Skip problematic Python 3 tests in Guix.
+
+A subset of the hunks in this patch is tracked upstream at
+https://bugs.python.org/issue38845, which was contributed by Tanguy Le
+Carrour <tanguy@bioneland.org>.
+
+diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
+index e42c7ab4bd..8087c84dab 100644
+--- a/Lib/test/_test_multiprocessing.py
++++ b/Lib/test/_test_multiprocessing.py
+@@ -1695,6 +1695,7 @@ def _test_wait_result(cls, c, pid):
+ if pid is not None:
+ os.kill(pid, signal.SIGINT)
+
++ @unittest.skipIf(True, "This fails for unknown reasons on Guix")
+ def test_wait_result(self):
+ if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
+ pid = os.getpid()
+@@ -4150,6 +4151,7 @@ def test_shared_memory_across_processes(self):
+ sms.close()
+
+ @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
+ # bpo-36368: protect SharedMemoryManager server process from
+ # KeyboardInterrupt signals.
+diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
+index 85c8152d49..e35cfffe84 100644
+--- a/Lib/test/test_asyncio/test_base_events.py
++++ b/Lib/test/test_asyncio/test_base_events.py
+@@ -1377,6 +1377,8 @@ def test_create_connection_no_inet_pton(self, m_socket):
+ self._test_create_connection_ip_addr(m_socket, False)
+
+ @patch_socket
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_create_connection_service_name(self, m_socket):
+ m_socket.getaddrinfo = socket.getaddrinfo
+ sock = m_socket.socket.return_value
+diff --git a/Lib/test/test_ctypes/test_find.py b/Lib/test/test_ctypes/test_find.py
+index a41e94971d..1291af3057 100644
+--- a/Lib/test/test_ctypes/test_find.py
++++ b/Lib/test/test_ctypes/test_find.py
+@@ -117,6 +117,7 @@ def test_find_library_with_gcc(self):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
+ self.assertNotEqual(find_library('c'), None)
+
++ @unittest.skipIf(True, 'Fails on Guix.')
+ def test_find_library_with_ld(self):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
+ unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
+diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
+index 1ee9958445..ab6b41befe 100644
+--- a/Lib/test/test_generators.py
++++ b/Lib/test/test_generators.py
+@@ -34,6 +34,7 @@ def generator2(self):
+ else:
+ return "FAILED"
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
+ def test_raise_and_yield_from(self):
+ gen = self.generator1()
+ gen.send(None)
+diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
+index ec105ae1a0..ae4c5b672e 100644
+--- a/Lib/test/test_pathlib.py
++++ b/Lib/test/test_pathlib.py
+@@ -3069,6 +3069,7 @@ def test_rglob(self):
+ 'pwd module does not expose getpwall()')
+ @unittest.skipIf(sys.platform == "vxworks",
+ "no home directory on VxWorks")
++ @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
+ def test_expanduser(self):
+ P = self.cls
+ import_helper.import_module('pwd')
+diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
+index 51b844262e..004d3133cf 100644
+--- a/Lib/test/test_pdb.py
++++ b/Lib/test/test_pdb.py
+@@ -1580,6 +1580,7 @@ def test_pdb_next_command_subiterator():
+ (Pdb) continue
+ """
+
++@unittest.skipIf(True, 'Fails on Guix… but skipIf not taken into account?!')
+ def test_pdb_issue_20766():
+ """Test for reference leaks when the SIGINT handler is set.
+
+@@ -1598,11 +1599,11 @@ def test_pdb_issue_20766():
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 1: <built-in function default_int_handler>
++ pdb 1: 1
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 2: <built-in function default_int_handler>
++ pdb 2: 1
+ """
+
+ def test_pdb_issue_43318():
+diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
+index 2ab6f6a986..8cf6b4d1c8 100644
+--- a/Lib/test/test_regrtest.py
++++ b/Lib/test/test_regrtest.py
+@@ -1049,6 +1049,7 @@ def test_fromfile(self):
+ output = self.run_tests('--fromfile', filename)
+ self.check_executed_tests(output, tests, stats=stats)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_interrupted(self):
+ code = TEST_INTERRUPTED
+ test = self.create_test('sigint', code=code)
+@@ -1066,6 +1067,7 @@ def test_slowest(self):
+ % (self.TESTNAME_REGEX, len(tests)))
+ self.check_line(output, regex)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_slowest_interrupted(self):
+ # Issue #25373: test --slowest with an interrupted test
+ code = TEST_INTERRUPTED
+diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
+index 317e7ca8f8..7f272daf24 100644
+--- a/Lib/test/test_resource.py
++++ b/Lib/test/test_resource.py
+@@ -151,6 +151,7 @@ def test_freebsd_contants(self):
+
+ @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
+ @support.requires_linux_version(2, 6, 36)
++ @unittest.skipIf(True, "Bug: the PermissionError is not raised")
+ def test_prlimit(self):
+ self.assertRaises(TypeError, resource.prlimit)
+ self.assertRaises(ProcessLookupError, resource.prlimit,
+diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
+index bf60f37934..5e3a96380a 100644
+--- a/Lib/test/test_shutil.py
++++ b/Lib/test/test_shutil.py
+@@ -1743,6 +1743,7 @@ def test_make_archive(self):
+ base_name = os.path.join(tmpdir, 'archive')
+ self.assertRaises(ValueError, make_archive, base_name, 'xxx')
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ def test_make_archive_owner_group(self):
+ # testing make_archive with owner and group, with various combinations
+@@ -1771,6 +1772,7 @@ def test_make_archive_owner_group(self):
+ self.assertTrue(os.path.isfile(res))
+
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+ def test_tarfile_root_owner(self):
+diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
+index 637a0ca3b3..2fb804e340 100644
+--- a/Lib/test/test_signal.py
++++ b/Lib/test/test_signal.py
+@@ -160,6 +160,7 @@ def test_valid_signals(self):
+ self.assertLess(signum, signal.NSIG)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @support.requires_subprocess()
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers exit via SIGINT."""
+@@ -211,6 +212,7 @@ def test_issue9324(self):
+ signal.signal(7, handler)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @support.requires_subprocess()
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
+@@ -1407,6 +1409,7 @@ def cycle_handlers():
+
+ class RaiseSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_sigint(self):
+ with self.assertRaises(KeyboardInterrupt):
+ signal.raise_signal(signal.SIGINT)
+@@ -1452,6 +1455,7 @@ def __del__(self):
+
+ class PidfdSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @unittest.skipUnless(
+ hasattr(signal, "pidfd_send_signal"),
+ "pidfd support not built in",
+diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
+index 4eb5af99d6..9c7b8f6dbc 100644
+--- a/Lib/test/test_socket.py
++++ b/Lib/test/test_socket.py
+@@ -1016,6 +1016,8 @@ def testHostnameRes(self):
+ if not fqhn in all_host_names:
+ self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
+
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_host_resolution(self):
+ for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:
+ self.assertEqual(socket.gethostbyname(addr), addr)
+@@ -1161,6 +1163,8 @@ def testNtoHErrors(self):
+ self.assertRaises(OverflowError, socket.ntohl, k)
+ self.assertRaises(OverflowError, socket.htonl, k)
+
++ @unittest.skipUnless(os.path.exists("/etc/services"),
++ "getservbyname uses /etc/services, which is not in the chroot")
+ def testGetServBy(self):
+ eq = self.assertEqual
+ # Find one service that exists, then check all the related interfaces.
+@@ -1521,6 +1525,8 @@ def test_sio_loopback_fast_path(self):
+ raise
+ self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ def testGetaddrinfo(self):
+ try:
+ socket.getaddrinfo('localhost', 80)
+@@ -1653,6 +1659,8 @@ def test_getnameinfo(self):
+ # only IP addresses are allowed
+ self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ @unittest.skipUnless(support.is_resource_enabled('network'),
+ 'network is not enabled')
+ def test_idna(self):
+diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
+index 50766c2548..0c7eb7a83a 100644
+--- a/Lib/test/test_spwd.py
++++ b/Lib/test/test_spwd.py
+@@ -9,8 +9,7 @@
+ spwd = import_helper.import_module('spwd')
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
+- 'root privileges required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdRoot(unittest.TestCase):
+
+ def test_getspall(self):
+@@ -60,8 +59,7 @@ def test_getspnam(self):
+ self.assertRaises(TypeError, spwd.getspnam, bytes_name)
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
+- 'non-root user required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdNonRoot(unittest.TestCase):
+
+ def test_getspnam_exception(self):
+diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
+index 71489ea493..33351919fe 100644
+--- a/Lib/test/test_tarfile.py
++++ b/Lib/test/test_tarfile.py
+@@ -2911,9 +2911,12 @@ def root_is_uid_gid_0():
+ import pwd, grp
+ except ImportError:
+ return False
+- if pwd.getpwuid(0)[0] != 'root':
+- return False
+- if grp.getgrgid(0)[0] != 'root':
++ try:
++ if pwd.getpwuid(0)[0] != 'root':
++ return False
++ if grp.getgrgid(0)[0] != 'root':
++ return False
++ except KeyError:
+ return False
+ return True
+
+diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
+index 00d9e591c7..2515603715 100644
+--- a/Lib/test/test_threading.py
++++ b/Lib/test/test_threading.py
+@@ -1962,6 +1962,7 @@ def check_interrupt_main_noerror(self, signum):
+ # Restore original handler
+ signal.signal(signum, handler)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_subthread(self):
+ # Calling start_new_thread with a function that executes interrupt_main
+ # should raise KeyboardInterrupt upon completion.
+@@ -1973,6 +1974,8 @@ def call_interrupt():
+ t.join()
+ t.join()
+
++
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_mainthread(self):
+ # Make sure that if interrupt_main is called in main thread that
+ # KeyboardInterrupt is raised instantly.
+diff --git a/Lib/test/test_tools/test_freeze.py b/Lib/test/test_tools/test_freeze.py
+index 0e7ed67de7..6539a2983b 100644
+--- a/Lib/test/test_tools/test_freeze.py
++++ b/Lib/test/test_tools/test_freeze.py
+@@ -23,6 +23,7 @@
+ 'test is too slow with PGO')
+ class TestFreeze(unittest.TestCase):
+
++ @unittest.skipIf(True, 'Fails on Guix.')
+ @support.requires_resource('cpu') # Building Python is slow
+ def test_freeze_simple_script(self):
+ script = textwrap.dedent("""
+diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
+index 515c3840cb..a96dfad0fe 100644
+--- a/Lib/test/test_unicodedata.py
++++ b/Lib/test/test_unicodedata.py
+@@ -342,6 +342,7 @@ def test_linebreak_7643(self):
+ self.assertEqual(len(lines), 1,
+ r"\u%.4x should not be a linebreak" % i)
+
++@requires_resource('network')
+ class NormalizationTest(unittest.TestCase):
+ @staticmethod
+ def check_version(testfile):
+diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
+index 445a34ae3e..8f750537c3 100644
+--- a/Tools/scripts/run_tests.py
++++ b/Tools/scripts/run_tests.py
+@@ -69,7 +69,7 @@ def main(regrtest_args):
+ else:
+ args.extend(['-j', '0']) # Use all CPU cores
+ if not any(is_resource_use_flag(arg) for arg in regrtest_args):
+- args.extend(['-u', 'all,-largefile,-audio,-gui'])
++ args.extend(['-u', 'all,-largefile,-audio,-gui,-network'])
+
+ if cross_compile and hostrunner:
+ # If HOSTRUNNER is set and -p/--python option is not given, then
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 51d5f598d7..471cf190fb 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -55,7 +55,7 @@
;;; Copyright © 2018, 2019, 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2018 Luther Thompson <lutheroto@gmail.com>
;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
-;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
+;;; Copyright © 2019, 2024 Tanguy Le Carrour <tanguy@bioneland.org>
;;; Copyright © 2020, 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2020, 2021 Greg Hogan <code@greghogan.com>
;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
@@ -596,6 +596,382 @@ (define-public python-3.10
(variable "PYTHONTZPATH")
(files (list "share/zoneinfo")))))))
+(define-public python-3.12
+ (package
+ (name "python")
+ (version "3.12.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://www.python.org/ftp/python/" version
+ "/Python-" version ".tar.xz"))
+ (sha256
+ (base32 "0w6qyfhc912xxav9x9pifwca40b4l49vy52wai9j0gc1mhni2a5y"))
+ (patches (search-patches "python-3-deterministic-build-info.patch"
+ "python-3.12-fix-tests.patch"
+ "python-3-hurd-configure.patch"))
+ (modules '((guix build utils)))
+ (snippet '(begin
+ ;; Delete the bundled copy of libexpat.
+ (delete-file-recursively "Modules/expat")
+ (substitute* "Modules/Setup"
+ ;; Link Expat instead of embedding the bundled one.
+ (("^#pyexpat.*")
+ "pyexpat pyexpat.c -lexpat\n"))
+ ;; Delete windows binaries
+ (for-each delete-file
+ (find-files "Lib/distutils/command" "\\.exe$"))))))
+ (outputs '("out" "tk" ;tkinter; adds 50 MiB to the closure
+ "idle")) ;programming environment; weighs 5MB
+ (build-system gnu-build-system)
+ (arguments
+ `(#:test-target "test"
+ #:configure-flags (list "--enable-shared" ;allow embedding
+ "--with-system-expat" ;for XML support
+ "--with-system-ffi" ;build ctypes
+ "--with-ensurepip=install" ;install pip and setuptools
+ "--with-computed-gotos" ;main interpreter loop optimization
+ "--enable-unicode=ucs4"
+ "--without-static-libpython"
+
+ ;; FIXME: These flags makes Python significantly faster, but
+ ;; leads to non-reproducible binaries.
+ ;; "--with-lto" ;increase size by 20MB, but 15% speedup
+ ;; "--enable-optimizations"
+
+ ;; Prevent the installed _sysconfigdata.py from retaining a reference
+ ;; to coreutils.
+ "INSTALL=install -c"
+ "MKDIR_P=mkdir -p"
+
+
This message was truncated. Download the full message here.
T
T
Tanguy Le Carrour wrote on 21 Feb 19:36 +0100
(address . 60240@debbugs.gnu.org)
710517CB-0F53-4A5A-ADDA-78F9AA1285D7@bioneland.org
Oups! I've just figured out that I forgot to mention something…

Le 21 février 2024 13:13:42 GMT+01:00, Tanguy Le Carrour <tanguy@bioneland.org> a écrit :
>+ ;; With no -j argument tests use all available cpus, so provide one.
Toggle quote (10 lines)
>+ #:make-flags (list (string-append (format #f "TESTOPTS=-j~d"
>+ (parallel-job-count))
>+ ;; those tests fail on low-memory systems
>+ " --exclude test_mmap test_socket test_threading test_asyncio"
>+ ,@(if (system-hurd?)
>+ '(" test_posix" ;multiple errors
>+ ;;...
>+ " test_sqlite")
>+ '())))

Here, I had to exlude 'test_socket' and 'test_threading' for, after 20min, there were making my computer crash! ?
They were in the "if hurd" block, so I removed them from there.

I'll try to un-exclude them and see if it works on my bigger computer at work.

--
Tanguy
T
T
Tanguy LE CARROUR wrote on 22 Feb 10:07 +0100
(address . 60240@debbugs.gnu.org)
170859284041.29391.324420994855433124@bioneland.org
Quoting Tanguy Le Carrour (2024-02-21 19:36:35)
Toggle quote (17 lines)
> Le 21 février 2024 13:13:42 GMT+01:00, Tanguy Le Carrour <tanguy@bioneland.org> a écrit :
> >+ ;; With no -j argument tests use all available cpus, so provide one.
> >+ #:make-flags (list (string-append (format #f "TESTOPTS=-j~d"
> >+ (parallel-job-count))
> >+ ;; those tests fail on low-memory systems
> >+ " --exclude test_mmap test_socket test_threading test_asyncio"
> >+ ,@(if (system-hurd?)
> >+ '(" test_posix" ;multiple errors
> >+ ;;...
> >+ " test_sqlite")
> >+ '())))
>
> Here, I had to exlude 'test_socket' and 'test_threading' for, after 20min, there were making my computer crash! ?
> They were in the "if hurd" block, so I removed them from there.
>
> I'll try to un-exclude them and see if it works on my bigger computer at work.

And… it almost killed my computer… again! ?
So, I won’t "un-exclude" them, and I’ll leave the patch as it is.

--
Tanguy
L
L
Lars-Dominik Braun wrote on 25 Feb 15:08 +0100
Re: [bug#60240] [PATCH v2] gnu: Add python-3.12 and python-next.
(name . Tanguy Le Carrour)(address . tanguy@bioneland.org)
ZdtJ1AU7ru7Vr2TU@noor.fritz.box
Hi,

Toggle quote (5 lines)
> I created a brand new package definition for it, not inheriting from
> `python-2`. I actually copied/pasted the `python-2` package definition,
> removed what was specific to Python 2 and then copied over the things
> specific to Python 3 from the `python-3.10` package definition.

LGTM.

I believe the separate tk output does not give us any benefits regarding
closure size (any more?), because tcl and tk are both referenced from
`out`. Can we remove those references to reduce closure size again?

And I can also confirm test_asyncio runs out of memory on my machine
and test_threading never finishes. We should probably investigate both,
because they should not.

Toggle quote (3 lines)
> - When I apply the patch I get whitespace errors, but I don’t know how
> those whitespace were introduced and how to get rid of them.

Line 641, as highlighted by `git show`.

Toggle quote (2 lines)
> Btw, the patch targets the branch `python-team`.

I believe this change could target master, since it only adds python-3.12,
but does not cause any rebuilds using it.

Cheers,
Lars
T
T
Tanguy LE CARROUR wrote on 26 Feb 09:25 +0100
(name . Lars-Dominik Braun)(address . lars@6xq.net)(address . 60240@debbugs.gnu.org)
170893592338.2024.18126018474930945065@bioneland.org
Hi Lars,

Thanks for reviewing!


Quoting Lars-Dominik Braun (2024-02-25 15:08:20)
Toggle quote (11 lines)
> > I created a brand new package definition for it, not inheriting from
> > `python-2`. I actually copied/pasted the `python-2` package definition,
> > removed what was specific to Python 2 and then copied over the things
> > specific to Python 3 from the `python-3.10` package definition.
>
> LGTM.
>
> I believe the separate tk output does not give us any benefits regarding
> closure size (any more?), because tcl and tk are both referenced from
> `out`. Can we remove those references to reduce closure size again?

Sorry, but I’m not sure to see what you mean!?
Outputs are defined for `out`, `tk` and `idle`. And I see phases to move
files to the outputs: `move-tk-inter` and `move-idle`.

What do you mean by `referenced from out`? And how would you remove such
a reference!

Sorry, I’m still new to this! ?


Toggle quote (4 lines)
> And I can also confirm test_asyncio runs out of memory on my machine
> and test_threading never finishes. We should probably investigate both,
> because they should not.

I searched in the issue list on GH, but couldn’t find anything relevant.
But there are quite a lot of issues there.
Do we have to fix this before we merge it?


Toggle quote (5 lines)
> > - When I apply the patch I get whitespace errors, but I don’t know how
> > those whitespace were introduced and how to get rid of them.
>
> Line 641, as highlighted by `git show`.

Mmm… when I apply it using b4, it doesn’t complain any more?! ?

```console
$ b4 shazam 20221221153230.27764-1-tanguy@bioneland.org
Grabbing thread from yhetil.org/guix/20221221153230.27764-1-tanguy@bioneland.org/t.mbox.gz
Checking for newer revisions
Grabbing search results from lore.kernel.org
Nothing matching that query.
Analyzing 10 messages in the thread
Will use the latest revision: v2
You can pick other revisions using the -vN flag
---
[PATCH v2] gnu: Add python-3.12 and python-next.
---
Total patches: 1
---
Base: using specified base-commit 6831dfc58bf14341176f7358941ed685f34fb4c3
Applying: gnu: Add python-3.12 and python-next.
```


Toggle quote (5 lines)
> > Btw, the patch targets the branch `python-team`.
>
> I believe this change could target master, since it only adds python-3.12,
> but does not cause any rebuilds using it.

Oh… correct! ?

Regards,

--
Tanguy
L
L
Lars-Dominik Braun wrote on 2 Mar 10:59 +0100
(name . Tanguy LE CARROUR)(address . tanguy@bioneland.org)(address . 60240@debbugs.gnu.org)
ZeL4e8_uI24-2OGc@noor.fritz.box
Hey,

Toggle quote (7 lines)
> Sorry, but I’m not sure to see what you mean!?
> Outputs are defined for `out`, `tk` and `idle`. And I see phases to move
> files to the outputs: `move-tk-inter` and `move-idle`.
>
> What do you mean by `referenced from out`? And how would you remove such
> a reference!

so, if you look at `guix size python@3.12`, you can see
it lists tk and tcl. And then a `grep -Ri /gnu/store/path/to/tcl
/gnu/store/path/to/python` reveals it’s being referenced by
lib/python3.12/_sysconfigdata__linux_x86_64-linux-gnu.py and
lib/python3.12/config-3.12-x86_64-linux-gnu/Makefile, which are both
part of the default “out” output. That means TCL and TK are both
part of the closure of the python@3.12 package, i.e. they are downloaded
whenever you install it, making the package “bigger” in size (234.5
MiB in total to be precise). I believe we wanted to avoid that by moving
some parts of Python into the separate “tk” output. But apparently
that does not work (any more).

The attached patch (on top of yours) removes these references and shrinks
the closure of python@3.12 to 180.6 MiB. But I don’t know whether it
has any negative side-effects (i.e. packages not building any more),
because I can’t build libxslt with Python 3.12 due to the module
“imp” having been removed in Python 3.12.

Toggle quote (4 lines)
> I searched in the issue list on GH, but couldn’t find anything relevant.
> But there are quite a lot of issues there.
> Do we have to fix this before we merge it?

No, we’d have to dig deeper into which particular test causes this
behavior.

And actually one more nitpick: The name of the package should be
“python-next” not “python”, otherwise `guix install python`
will pick Python 3.12 (it’s based on the name property, not the
variable name).

Cheers,
Lars
Toggle diff (29 lines)
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 471cf190fb..0b887a2cdb 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -836,7 +836,7 @@ (define-public python-3.12
"json/tests"
"distutils/tests"))))))))
(add-after 'remove-tests 'move-tk-inter
- (lambda* (#:key outputs #:allow-other-keys)
+ (lambda* (#:key outputs inputs #:allow-other-keys)
;; When Tkinter support is built move it to a separate output so
;; that the main output doesn't contain a reference to Tcl/Tk.
(let ((out (assoc-ref outputs "out"))
@@ -854,7 +854,14 @@ (define-public python-3.12
len)
"/site-packages")))
(install-file tkinter.so target)
- (delete-file tkinter.so))))))))
+ (delete-file tkinter.so))))
+ ;; Remove explicit store path references.
+ (let ((tcl (assoc-ref inputs "tcl"))
+ (tk (assoc-ref inputs "tk")))
+ (substitute* (find-files (string-append out "/lib")
+ "^(_sysconfigdata_.*\\.py|Makefile)$")
+ (((string-append "-L" tk "/lib")) "")
+ (((string-append "-L" tcl "/lib")) "")))))))
(add-after 'move-tk-inter 'move-idle
(lambda* (#:key outputs #:allow-other-keys)
;; when idle is built, move it to a separate output to save some
T
T
Tanguy LE CARROUR wrote on 6 Mar 13:49 +0100
(name . Lars-Dominik Braun)(address . lars@6xq.net)(address . 60240@debbugs.gnu.org)
170972934744.10042.4258218570652595127@bioneland.org
Hi Lars,


Quoting Lars-Dominik Braun (2024-03-02 10:59:23)
Toggle quote (5 lines)
> And actually one more nitpick: The name of the package should be
> “python-next” not “python”, otherwise `guix install python`
> will pick Python 3.12 (it’s based on the name property, not the
> variable name).

Oh… thanks! Fixed in v3.
The package name only apply when used I input, right?
I submitted other patches where I did the same. But it’s a different matter
for Python libraries, I guess!? ?


Toggle quote (21 lines)
> > Sorry, but I’m not sure to see what you mean!?
> > Outputs are defined for `out`, `tk` and `idle`. And I see phases to move
> > files to the outputs: `move-tk-inter` and `move-idle`.
> >
> > What do you mean by `referenced from out`? And how would you remove such
> > a reference!
>
> so, if you look at `guix size python@3.12`, you can see
> it lists tk and tcl. And then a `grep -Ri /gnu/store/path/to/tcl
> /gnu/store/path/to/python` reveals it’s being referenced by
> lib/python3.12/_sysconfigdata__linux_x86_64-linux-gnu.py and
> lib/python3.12/config-3.12-x86_64-linux-gnu/Makefile, which are both
> part of the default “out” output. That means TCL and TK are both
> part of the closure of the python@3.12 package, i.e. they are downloaded
> whenever you install it, making the package “bigger” in size (234.5
> MiB in total to be precise). I believe we wanted to avoid that by moving
> some parts of Python into the separate “tk” output. But apparently
> that does not work (any more).
> The attached patch (on top of yours) removes these references and shrinks
> the closure of python@3.12 to 180.6 MiB.

Oh-again! Thanks for taking the time to clarify!
I think I now see what you see:

```console
$ ./pre-inst-env guix size python-next
store item total self
/gnu/store/g6w91736w66pszrg0bmcgwx84ahw7frd-python-next-3.12.2 180.6 82.3 45.6%
/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35 40.6 38.8 21.5%
/gnu/store/930nwsiysdvy2x5zv1sf6v7ym75z8ayk-gcc-11.3.0-lib 75.3 34.7 19.2%
/gnu/store/69wd3pd1hd3j84xr965jj2fk2qmxn0hl-openssl-3.0.8 83.4 8.1 4.5%
/gnu/store/bcc053jvsbspdjr17gnnd9dg85b3a0gy-ncurses-6.2.20210619 81.2 5.9 3.3%
/gnu/store/4jakqiibsvrkv4jdw1wyl6racrwv9bkh-sqlite-3.39.3 86.0 3.4 1.9%
/gnu/store/zzyywykw7kriln18rxqd82f0k5kidla7-bash-static-5.1.16 1.8 1.8 1.0%
/gnu/store/lxfc2a05ysi7vlaq0m3w5wsfsy0drdlw-readline-8.1.2 82.6 1.4 0.8%
/gnu/store/6k1yys9wqrfn4y41ic1win8gpnimncwj-xz-5.2.8 77.7 1.4 0.8%
/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16 41.6 1.0 0.6%
/gnu/store/2w976k6g70gkfih9wwhalqsni209vcqz-gdbm-1.23 75.9 0.6 0.4%
/gnu/store/pl09vk5g3cl8fxfln2hjk996pyahqk8m-bzip2-1.0.8 76.7 0.4 0.2%
/gnu/store/fw1wywd34vh33l4dq182ds5d7jdz45j5-expat-2.5.0 75.7 0.4 0.2%
/gnu/store/slzq3zqwj75lbrg4ly51hfhbv2vhryv5-zlib-1.2.13 75.5 0.2 0.1%
/gnu/store/w8b0l8hk6g0fahj4fvmc4qqm3cvaxnmv-libffi-3.4.4 75.5 0.2 0.1%
total: 180.6 MiB
```

No more Tcl/Tk, thanks! ?
If you don’t mind, I squashed your modification in v3.


Toggle quote (5 lines)
> But I don’t know whether it has any negative side-effects (i.e.
> packages not building any more), because I can’t build libxslt with
> Python 3.12 due to the module “imp” having been removed in Python
> 3.12.

Mmmm… is it something that has to be fixed in `libxslt`?
More likely, it comes from `python-lxml`. Our current version is 4.9.1,
and one test file (`src/lxml/html/tests/test_html5parser.py`) depends on
`imp` for `imp.new_module`.
This has been dropped in 5.1.0.

Regards,

--
Tanguy
T
T
Tanguy Le Carrour wrote on 6 Mar 13:55 +0100
[PATCH v3] gnu: Add python-3.12 and python-next.
(address . 60240@debbugs.gnu.org)
796e983ade5fec88ff68f68fa30385aa0283839b.1709729756.git.tanguy@bioneland.org
Patch v3 changes the name of the package to `python-next` and
actually exclude Tcl/Tk from `out`. Thanks Lars!

* gnu/packages/python.scm (python-3.12, python-next): New variables.
* gnu/packages/patches/python-3.12-fix-tests.patch: New file.

Change-Id: Ie393b732a8863569578e72e62603b75a1655a34e
---
.../patches/python-3.12-fix-tests.patch | 334 +++++++++++++++
gnu/packages/python.scm | 385 +++++++++++++++++-
2 files changed, 718 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/python-3.12-fix-tests.patch

Toggle diff (419 lines)
diff --git a/gnu/packages/patches/python-3.12-fix-tests.patch b/gnu/packages/patches/python-3.12-fix-tests.patch
new file mode 100644
index 0000000000..fa5c8027ce
--- /dev/null
+++ b/gnu/packages/patches/python-3.12-fix-tests.patch
@@ -0,0 +1,334 @@
+From f0698133e7d6c353a3e6ae0fc62e57ba558a9bc0 Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Date: Wed, 28 Oct 2020 22:55:05 -0400
+Subject: [PATCH] Skip problematic Python 3 tests in Guix.
+
+A subset of the hunks in this patch is tracked upstream at
+https://bugs.python.org/issue38845, which was contributed by Tanguy Le
+Carrour <tanguy@bioneland.org>.
+
+diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
+index e42c7ab4bd..8087c84dab 100644
+--- a/Lib/test/_test_multiprocessing.py
++++ b/Lib/test/_test_multiprocessing.py
+@@ -1695,6 +1695,7 @@ def _test_wait_result(cls, c, pid):
+ if pid is not None:
+ os.kill(pid, signal.SIGINT)
+
++ @unittest.skipIf(True, "This fails for unknown reasons on Guix")
+ def test_wait_result(self):
+ if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
+ pid = os.getpid()
+@@ -4150,6 +4151,7 @@ def test_shared_memory_across_processes(self):
+ sms.close()
+
+ @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
+ # bpo-36368: protect SharedMemoryManager server process from
+ # KeyboardInterrupt signals.
+diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
+index 85c8152d49..e35cfffe84 100644
+--- a/Lib/test/test_asyncio/test_base_events.py
++++ b/Lib/test/test_asyncio/test_base_events.py
+@@ -1377,6 +1377,8 @@ def test_create_connection_no_inet_pton(self, m_socket):
+ self._test_create_connection_ip_addr(m_socket, False)
+
+ @patch_socket
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_create_connection_service_name(self, m_socket):
+ m_socket.getaddrinfo = socket.getaddrinfo
+ sock = m_socket.socket.return_value
+diff --git a/Lib/test/test_ctypes/test_find.py b/Lib/test/test_ctypes/test_find.py
+index a41e94971d..1291af3057 100644
+--- a/Lib/test/test_ctypes/test_find.py
++++ b/Lib/test/test_ctypes/test_find.py
+@@ -117,6 +117,7 @@ def test_find_library_with_gcc(self):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
+ self.assertNotEqual(find_library('c'), None)
+
++ @unittest.skipIf(True, 'Fails on Guix.')
+ def test_find_library_with_ld(self):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
+ unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
+diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
+index 1ee9958445..ab6b41befe 100644
+--- a/Lib/test/test_generators.py
++++ b/Lib/test/test_generators.py
+@@ -34,6 +34,7 @@ def generator2(self):
+ else:
+ return "FAILED"
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
+ def test_raise_and_yield_from(self):
+ gen = self.generator1()
+ gen.send(None)
+diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
+index ec105ae1a0..ae4c5b672e 100644
+--- a/Lib/test/test_pathlib.py
++++ b/Lib/test/test_pathlib.py
+@@ -3069,6 +3069,7 @@ def test_rglob(self):
+ 'pwd module does not expose getpwall()')
+ @unittest.skipIf(sys.platform == "vxworks",
+ "no home directory on VxWorks")
++ @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
+ def test_expanduser(self):
+ P = self.cls
+ import_helper.import_module('pwd')
+diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
+index 51b844262e..004d3133cf 100644
+--- a/Lib/test/test_pdb.py
++++ b/Lib/test/test_pdb.py
+@@ -1580,6 +1580,7 @@ def test_pdb_next_command_subiterator():
+ (Pdb) continue
+ """
+
++@unittest.skipIf(True, 'Fails on Guix… but skipIf not taken into account?!')
+ def test_pdb_issue_20766():
+ """Test for reference leaks when the SIGINT handler is set.
+
+@@ -1598,11 +1599,11 @@ def test_pdb_issue_20766():
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 1: <built-in function default_int_handler>
++ pdb 1: 1
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 2: <built-in function default_int_handler>
++ pdb 2: 1
+ """
+
+ def test_pdb_issue_43318():
+diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
+index 2ab6f6a986..8cf6b4d1c8 100644
+--- a/Lib/test/test_regrtest.py
++++ b/Lib/test/test_regrtest.py
+@@ -1049,6 +1049,7 @@ def test_fromfile(self):
+ output = self.run_tests('--fromfile', filename)
+ self.check_executed_tests(output, tests, stats=stats)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_interrupted(self):
+ code = TEST_INTERRUPTED
+ test = self.create_test('sigint', code=code)
+@@ -1066,6 +1067,7 @@ def test_slowest(self):
+ % (self.TESTNAME_REGEX, len(tests)))
+ self.check_line(output, regex)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_slowest_interrupted(self):
+ # Issue #25373: test --slowest with an interrupted test
+ code = TEST_INTERRUPTED
+diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
+index 317e7ca8f8..7f272daf24 100644
+--- a/Lib/test/test_resource.py
++++ b/Lib/test/test_resource.py
+@@ -151,6 +151,7 @@ def test_freebsd_contants(self):
+
+ @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
+ @support.requires_linux_version(2, 6, 36)
++ @unittest.skipIf(True, "Bug: the PermissionError is not raised")
+ def test_prlimit(self):
+ self.assertRaises(TypeError, resource.prlimit)
+ self.assertRaises(ProcessLookupError, resource.prlimit,
+diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
+index bf60f37934..5e3a96380a 100644
+--- a/Lib/test/test_shutil.py
++++ b/Lib/test/test_shutil.py
+@@ -1743,6 +1743,7 @@ def test_make_archive(self):
+ base_name = os.path.join(tmpdir, 'archive')
+ self.assertRaises(ValueError, make_archive, base_name, 'xxx')
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ def test_make_archive_owner_group(self):
+ # testing make_archive with owner and group, with various combinations
+@@ -1771,6 +1772,7 @@ def test_make_archive_owner_group(self):
+ self.assertTrue(os.path.isfile(res))
+
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+ def test_tarfile_root_owner(self):
+diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
+index 637a0ca3b3..2fb804e340 100644
+--- a/Lib/test/test_signal.py
++++ b/Lib/test/test_signal.py
+@@ -160,6 +160,7 @@ def test_valid_signals(self):
+ self.assertLess(signum, signal.NSIG)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @support.requires_subprocess()
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers exit via SIGINT."""
+@@ -211,6 +212,7 @@ def test_issue9324(self):
+ signal.signal(7, handler)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @support.requires_subprocess()
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
+@@ -1407,6 +1409,7 @@ def cycle_handlers():
+
+ class RaiseSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_sigint(self):
+ with self.assertRaises(KeyboardInterrupt):
+ signal.raise_signal(signal.SIGINT)
+@@ -1452,6 +1455,7 @@ def __del__(self):
+
+ class PidfdSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @unittest.skipUnless(
+ hasattr(signal, "pidfd_send_signal"),
+ "pidfd support not built in",
+diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
+index 4eb5af99d6..9c7b8f6dbc 100644
+--- a/Lib/test/test_socket.py
++++ b/Lib/test/test_socket.py
+@@ -1016,6 +1016,8 @@ def testHostnameRes(self):
+ if not fqhn in all_host_names:
+ self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
+
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_host_resolution(self):
+ for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:
+ self.assertEqual(socket.gethostbyname(addr), addr)
+@@ -1161,6 +1163,8 @@ def testNtoHErrors(self):
+ self.assertRaises(OverflowError, socket.ntohl, k)
+ self.assertRaises(OverflowError, socket.htonl, k)
+
++ @unittest.skipUnless(os.path.exists("/etc/services"),
++ "getservbyname uses /etc/services, which is not in the chroot")
+ def testGetServBy(self):
+ eq = self.assertEqual
+ # Find one service that exists, then check all the related interfaces.
+@@ -1521,6 +1525,8 @@ def test_sio_loopback_fast_path(self):
+ raise
+ self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ def testGetaddrinfo(self):
+ try:
+ socket.getaddrinfo('localhost', 80)
+@@ -1653,6 +1659,8 @@ def test_getnameinfo(self):
+ # only IP addresses are allowed
+ self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ @unittest.skipUnless(support.is_resource_enabled('network'),
+ 'network is not enabled')
+ def test_idna(self):
+diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
+index 50766c2548..0c7eb7a83a 100644
+--- a/Lib/test/test_spwd.py
++++ b/Lib/test/test_spwd.py
+@@ -9,8 +9,7 @@
+ spwd = import_helper.import_module('spwd')
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
+- 'root privileges required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdRoot(unittest.TestCase):
+
+ def test_getspall(self):
+@@ -60,8 +59,7 @@ def test_getspnam(self):
+ self.assertRaises(TypeError, spwd.getspnam, bytes_name)
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
+- 'non-root user required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdNonRoot(unittest.TestCase):
+
+ def test_getspnam_exception(self):
+diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
+index 71489ea493..33351919fe 100644
+--- a/Lib/test/test_tarfile.py
++++ b/Lib/test/test_tarfile.py
+@@ -2911,9 +2911,12 @@ def root_is_uid_gid_0():
+ import pwd, grp
+ except ImportError:
+ return False
+- if pwd.getpwuid(0)[0] != 'root':
+- return False
+- if grp.getgrgid(0)[0] != 'root':
++ try:
++ if pwd.getpwuid(0)[0] != 'root':
++ return False
++ if grp.getgrgid(0)[0] != 'root':
++ return False
++ except KeyError:
+ return False
+ return True
+
+diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
+index 00d9e591c7..2515603715 100644
+--- a/Lib/test/test_threading.py
++++ b/Lib/test/test_threading.py
+@@ -1962,6 +1962,7 @@ def check_interrupt_main_noerror(self, signum):
+ # Restore original handler
+ signal.signal(signum, handler)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_subthread(self):
+ # Calling start_new_thread with a function that executes interrupt_main
+ # should raise KeyboardInterrupt upon completion.
+@@ -1973,6 +1974,8 @@ def call_interrupt():
+ t.join()
+ t.join()
+
++
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_mainthread(self):
+ # Make sure that if interrupt_main is called in main thread that
+ # KeyboardInterrupt is raised instantly.
+diff --git a/Lib/test/test_tools/test_freeze.py b/Lib/test/test_tools/test_freeze.py
+index 0e7ed67de7..6539a2983b 100644
+--- a/Lib/test/test_tools/test_freeze.py
++++ b/Lib/test/test_tools/test_freeze.py
+@@ -23,6 +23,7 @@
+ 'test is too slow with PGO')
+ class TestFreeze(unittest.TestCase):
+
++ @unittest.skipIf(True, 'Fails on Guix.')
+ @support.requires_resource('cpu') # Building Python is slow
+ def test_freeze_simple_script(self):
+ script = textwrap.dedent("""
+diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
+index 515c3840cb..a96dfad0fe 100644
+--- a/Lib/test/test_unicodedata.py
++++ b/Lib/test/test_unicodedata.py
+@@ -342,6 +342,7 @@ def test_linebreak_7643(self):
+ self.assertEqual(len(lines), 1,
+ r"\u%.4x should not be a linebreak" % i)
+
++@requires_resource('network')
+ class NormalizationTest(unittest.TestCase):
+ @staticmethod
+ def check_version(testfile):
+diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
+index 445a34ae3e..8f750537c3 100644
+--- a/Tools/scripts/run_tests.py
++++ b/Tools/scripts/run_tests.py
+@@ -69,7 +69,7 @@ def main(regrtest_args):
+ else:
+ args.extend(['-j', '0']) # Use all CPU cores
+ if not any(is_resource_use_flag(arg) for arg in regrtest_args):
+- args.extend(['-u', 'all,-largefile,-audio,-gui'])
++ args.extend(['-u', 'all,-largefile,-audio,-gui,-network'])
+
+ if cross_compile and hostrunner:
+ # If HOSTRUNNER is set and -p/--python option is not given, then
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 51d5f598d7..25fe83ea69 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -55,7 +55,7 @@
;;; Copyright © 2018, 2019, 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2018 Luther Thompson <lutheroto@gmail.com>
;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
-;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
+;;; Copyright © 2019, 2024 Tanguy Le Carrour <tanguy@bioneland.org>
;;; Copyright © 2020, 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2020, 2021 Greg Hogan <code@greghogan.com>
;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
@@ -596,6 +596,389 @@ (define-public python-3.10
(variable "PYTHONTZPATH")
(files (list "share/zoneinfo")))))))
+(define-public python-3.12
+ (package
+ (name "python-next")
+ (version "3.12.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://www.python.org/ftp/python/" version
+ "/Python-" version ".tar.xz"))
+ (sha256
+ (base32 "0w6qyfhc912xxav9x9pifwca40b4l49vy52wai9j0gc1mhni2a5y"))
+ (patches (search-patches "python-3-deterministic-build-info.patch"
+ "python-3.12-fix-tests.patch"
+ "python-3-hurd-configure.patch"))
+ (modules '((guix build utils)))
+ (snippet '(begin
+ ;; Delete the bundled copy of libexpat.
+ (delete-file-recursively "Modules/expat")
+ (substitute* "Modules/Setup"
+ ;; Link Expat instead of embedding the bundled one.
+ (("^#pyexpat.*")
+ "pyexpat pyexpat.c -lexpat\n"))
+ ;; Delete windows binaries
+ (for-each delete-file
+ (find-files "Lib/distutils/command" "\\.exe$"))))))
+ (outputs '("out" "tk" ;tkinter; adds 50 MiB to the closure
+ "idle")) ;programming environment; weighs 5MB
+ (build-system gnu-build-system)
+ (arguments
+ `(#:test-target "test"
+ #:configure-flags (list "--enable-shared" ;allow embedding
+ "--with-system-expat" ;for XML support
+ "--with-system-ffi" ;build ctypes
+ "--with-ensurepip=install" ;install pip and setuptools
+ "--with-computed-gotos" ;main interpreter loop optimization
+ "--enable-unicode=ucs4"
+ "--without-static-libpython"
+
+ ;; FIXME: These flags makes Python significantly faster, but
+ ;; leads to non-reproducible binaries.
+ ;; "--with-lto" ;increase size by 20MB, but 15% speedup
+ ;; "--enable-optimizations"
+
+ ;; Prevent the installed _sysconfigdata.py from retaining a reference
+ ;; to coreutils.
+ "INSTALL=install -c"
+ "MKDIR_P=mkdir -p"
+
+ ;; Disable runtime check failing if cross-compiling, see:
+ ;; https://lists.yoctoproject.org/pipermail/poky/2013-June/008997.html
+ ,@(if (%current-target-system)
+ '("ac_cv_buggy_getaddrinfo=no"
+ "ac_cv_file__dev_ptmx=no"
+ "ac_cv_file__dev_ptc=no")
+ '())
+ ;; -fno-semantic-interposition reinstates some optimizations by gcc
+ ;; leading to around 15% speedup. This is the default starting from
+ ;; python 3.10.
+ "CFLAGS=-fno-semantic-interposition"
+ (string-append "LDFLAGS=-Wl,-rpath="
+ (assoc-ref %outputs "out")
+
This message was truncated. Download the full message here.
T
T
Tanguy Le Carrour wrote on 7 Mar 19:45 +0100
[PATCH v4] gnu: Add python-3.12 and python-next.
(address . 60240@debbugs.gnu.org)
09f5a111fcd5adc49fc6e2ffde0ee4718c252c4d.1709837110.git.tanguy@bioneland.org
Thanks to public shaming during the patch review session ?,
I’m sending this v4 that fixes some linter warnings.
Most of them were "line too long" that I wrongly thought
were taken care of by `guix style`. My bad!

The remaining problems are:

```
gnu/packages/python.scm:600:2: python-next@3.12.2: file names of patches should start with the package name
```

But I think the naming follows the convention used for other Python patches.

```
gnu/packages/python.scm:648:0: python-next@3.12.2: line 648 is way too long (101 characters)
```

It’s an URL that I cannot split.

```
gnu/packages/python.scm:604:5: python-next@3.12.2: updater 'generic-html' failed to find upstream releases
```

Don’t know what that means.

```
gnu/packages/python.scm:604:5: python-next@3.12.2: source not archived on Software Heritage and missing from the Disarchive database
```

Not **yet** archived by SWH.

* gnu/packages/python.scm (python-3.12, python-next): New variables.
* gnu/packages/patches/python-3.12-fix-tests.patch: New file.

Change-Id: Ie393b732a8863569578e72e62603b75a1655a34e
Signed-off-by: Tanguy Le Carrour <tanguy@bioneland.org>
---
.../patches/python-3.12-fix-tests.patch | 334 +++++++++++++++
gnu/packages/python.scm | 385 +++++++++++++++++-
2 files changed, 718 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/python-3.12-fix-tests.patch

Toggle diff (407 lines)
diff --git a/gnu/packages/patches/python-3.12-fix-tests.patch b/gnu/packages/patches/python-3.12-fix-tests.patch
new file mode 100644
index 0000000000..fa5c8027ce
--- /dev/null
+++ b/gnu/packages/patches/python-3.12-fix-tests.patch
@@ -0,0 +1,334 @@
+From f0698133e7d6c353a3e6ae0fc62e57ba558a9bc0 Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Date: Wed, 28 Oct 2020 22:55:05 -0400
+Subject: [PATCH] Skip problematic Python 3 tests in Guix.
+
+A subset of the hunks in this patch is tracked upstream at
+https://bugs.python.org/issue38845, which was contributed by Tanguy Le
+Carrour <tanguy@bioneland.org>.
+
+diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
+index e42c7ab4bd..8087c84dab 100644
+--- a/Lib/test/_test_multiprocessing.py
++++ b/Lib/test/_test_multiprocessing.py
+@@ -1695,6 +1695,7 @@ def _test_wait_result(cls, c, pid):
+ if pid is not None:
+ os.kill(pid, signal.SIGINT)
+
++ @unittest.skipIf(True, "This fails for unknown reasons on Guix")
+ def test_wait_result(self):
+ if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
+ pid = os.getpid()
+@@ -4150,6 +4151,7 @@ def test_shared_memory_across_processes(self):
+ sms.close()
+
+ @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
+ # bpo-36368: protect SharedMemoryManager server process from
+ # KeyboardInterrupt signals.
+diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
+index 85c8152d49..e35cfffe84 100644
+--- a/Lib/test/test_asyncio/test_base_events.py
++++ b/Lib/test/test_asyncio/test_base_events.py
+@@ -1377,6 +1377,8 @@ def test_create_connection_no_inet_pton(self, m_socket):
+ self._test_create_connection_ip_addr(m_socket, False)
+
+ @patch_socket
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_create_connection_service_name(self, m_socket):
+ m_socket.getaddrinfo = socket.getaddrinfo
+ sock = m_socket.socket.return_value
+diff --git a/Lib/test/test_ctypes/test_find.py b/Lib/test/test_ctypes/test_find.py
+index a41e94971d..1291af3057 100644
+--- a/Lib/test/test_ctypes/test_find.py
++++ b/Lib/test/test_ctypes/test_find.py
+@@ -117,6 +117,7 @@ def test_find_library_with_gcc(self):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
+ self.assertNotEqual(find_library('c'), None)
+
++ @unittest.skipIf(True, 'Fails on Guix.')
+ def test_find_library_with_ld(self):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
+ unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
+diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
+index 1ee9958445..ab6b41befe 100644
+--- a/Lib/test/test_generators.py
++++ b/Lib/test/test_generators.py
+@@ -34,6 +34,7 @@ def generator2(self):
+ else:
+ return "FAILED"
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
+ def test_raise_and_yield_from(self):
+ gen = self.generator1()
+ gen.send(None)
+diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
+index ec105ae1a0..ae4c5b672e 100644
+--- a/Lib/test/test_pathlib.py
++++ b/Lib/test/test_pathlib.py
+@@ -3069,6 +3069,7 @@ def test_rglob(self):
+ 'pwd module does not expose getpwall()')
+ @unittest.skipIf(sys.platform == "vxworks",
+ "no home directory on VxWorks")
++ @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
+ def test_expanduser(self):
+ P = self.cls
+ import_helper.import_module('pwd')
+diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
+index 51b844262e..004d3133cf 100644
+--- a/Lib/test/test_pdb.py
++++ b/Lib/test/test_pdb.py
+@@ -1580,6 +1580,7 @@ def test_pdb_next_command_subiterator():
+ (Pdb) continue
+ """
+
++@unittest.skipIf(True, 'Fails on Guix… but skipIf not taken into account?!')
+ def test_pdb_issue_20766():
+ """Test for reference leaks when the SIGINT handler is set.
+
+@@ -1598,11 +1599,11 @@ def test_pdb_issue_20766():
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 1: <built-in function default_int_handler>
++ pdb 1: 1
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 2: <built-in function default_int_handler>
++ pdb 2: 1
+ """
+
+ def test_pdb_issue_43318():
+diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
+index 2ab6f6a986..8cf6b4d1c8 100644
+--- a/Lib/test/test_regrtest.py
++++ b/Lib/test/test_regrtest.py
+@@ -1049,6 +1049,7 @@ def test_fromfile(self):
+ output = self.run_tests('--fromfile', filename)
+ self.check_executed_tests(output, tests, stats=stats)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_interrupted(self):
+ code = TEST_INTERRUPTED
+ test = self.create_test('sigint', code=code)
+@@ -1066,6 +1067,7 @@ def test_slowest(self):
+ % (self.TESTNAME_REGEX, len(tests)))
+ self.check_line(output, regex)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_slowest_interrupted(self):
+ # Issue #25373: test --slowest with an interrupted test
+ code = TEST_INTERRUPTED
+diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
+index 317e7ca8f8..7f272daf24 100644
+--- a/Lib/test/test_resource.py
++++ b/Lib/test/test_resource.py
+@@ -151,6 +151,7 @@ def test_freebsd_contants(self):
+
+ @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
+ @support.requires_linux_version(2, 6, 36)
++ @unittest.skipIf(True, "Bug: the PermissionError is not raised")
+ def test_prlimit(self):
+ self.assertRaises(TypeError, resource.prlimit)
+ self.assertRaises(ProcessLookupError, resource.prlimit,
+diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
+index bf60f37934..5e3a96380a 100644
+--- a/Lib/test/test_shutil.py
++++ b/Lib/test/test_shutil.py
+@@ -1743,6 +1743,7 @@ def test_make_archive(self):
+ base_name = os.path.join(tmpdir, 'archive')
+ self.assertRaises(ValueError, make_archive, base_name, 'xxx')
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ def test_make_archive_owner_group(self):
+ # testing make_archive with owner and group, with various combinations
+@@ -1771,6 +1772,7 @@ def test_make_archive_owner_group(self):
+ self.assertTrue(os.path.isfile(res))
+
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+ def test_tarfile_root_owner(self):
+diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
+index 637a0ca3b3..2fb804e340 100644
+--- a/Lib/test/test_signal.py
++++ b/Lib/test/test_signal.py
+@@ -160,6 +160,7 @@ def test_valid_signals(self):
+ self.assertLess(signum, signal.NSIG)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @support.requires_subprocess()
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers exit via SIGINT."""
+@@ -211,6 +212,7 @@ def test_issue9324(self):
+ signal.signal(7, handler)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @support.requires_subprocess()
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
+@@ -1407,6 +1409,7 @@ def cycle_handlers():
+
+ class RaiseSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_sigint(self):
+ with self.assertRaises(KeyboardInterrupt):
+ signal.raise_signal(signal.SIGINT)
+@@ -1452,6 +1455,7 @@ def __del__(self):
+
+ class PidfdSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @unittest.skipUnless(
+ hasattr(signal, "pidfd_send_signal"),
+ "pidfd support not built in",
+diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
+index 4eb5af99d6..9c7b8f6dbc 100644
+--- a/Lib/test/test_socket.py
++++ b/Lib/test/test_socket.py
+@@ -1016,6 +1016,8 @@ def testHostnameRes(self):
+ if not fqhn in all_host_names:
+ self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
+
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_host_resolution(self):
+ for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:
+ self.assertEqual(socket.gethostbyname(addr), addr)
+@@ -1161,6 +1163,8 @@ def testNtoHErrors(self):
+ self.assertRaises(OverflowError, socket.ntohl, k)
+ self.assertRaises(OverflowError, socket.htonl, k)
+
++ @unittest.skipUnless(os.path.exists("/etc/services"),
++ "getservbyname uses /etc/services, which is not in the chroot")
+ def testGetServBy(self):
+ eq = self.assertEqual
+ # Find one service that exists, then check all the related interfaces.
+@@ -1521,6 +1525,8 @@ def test_sio_loopback_fast_path(self):
+ raise
+ self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ def testGetaddrinfo(self):
+ try:
+ socket.getaddrinfo('localhost', 80)
+@@ -1653,6 +1659,8 @@ def test_getnameinfo(self):
+ # only IP addresses are allowed
+ self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ @unittest.skipUnless(support.is_resource_enabled('network'),
+ 'network is not enabled')
+ def test_idna(self):
+diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
+index 50766c2548..0c7eb7a83a 100644
+--- a/Lib/test/test_spwd.py
++++ b/Lib/test/test_spwd.py
+@@ -9,8 +9,7 @@
+ spwd = import_helper.import_module('spwd')
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
+- 'root privileges required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdRoot(unittest.TestCase):
+
+ def test_getspall(self):
+@@ -60,8 +59,7 @@ def test_getspnam(self):
+ self.assertRaises(TypeError, spwd.getspnam, bytes_name)
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
+- 'non-root user required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdNonRoot(unittest.TestCase):
+
+ def test_getspnam_exception(self):
+diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
+index 71489ea493..33351919fe 100644
+--- a/Lib/test/test_tarfile.py
++++ b/Lib/test/test_tarfile.py
+@@ -2911,9 +2911,12 @@ def root_is_uid_gid_0():
+ import pwd, grp
+ except ImportError:
+ return False
+- if pwd.getpwuid(0)[0] != 'root':
+- return False
+- if grp.getgrgid(0)[0] != 'root':
++ try:
++ if pwd.getpwuid(0)[0] != 'root':
++ return False
++ if grp.getgrgid(0)[0] != 'root':
++ return False
++ except KeyError:
+ return False
+ return True
+
+diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
+index 00d9e591c7..2515603715 100644
+--- a/Lib/test/test_threading.py
++++ b/Lib/test/test_threading.py
+@@ -1962,6 +1962,7 @@ def check_interrupt_main_noerror(self, signum):
+ # Restore original handler
+ signal.signal(signum, handler)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_subthread(self):
+ # Calling start_new_thread with a function that executes interrupt_main
+ # should raise KeyboardInterrupt upon completion.
+@@ -1973,6 +1974,8 @@ def call_interrupt():
+ t.join()
+ t.join()
+
++
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_mainthread(self):
+ # Make sure that if interrupt_main is called in main thread that
+ # KeyboardInterrupt is raised instantly.
+diff --git a/Lib/test/test_tools/test_freeze.py b/Lib/test/test_tools/test_freeze.py
+index 0e7ed67de7..6539a2983b 100644
+--- a/Lib/test/test_tools/test_freeze.py
++++ b/Lib/test/test_tools/test_freeze.py
+@@ -23,6 +23,7 @@
+ 'test is too slow with PGO')
+ class TestFreeze(unittest.TestCase):
+
++ @unittest.skipIf(True, 'Fails on Guix.')
+ @support.requires_resource('cpu') # Building Python is slow
+ def test_freeze_simple_script(self):
+ script = textwrap.dedent("""
+diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
+index 515c3840cb..a96dfad0fe 100644
+--- a/Lib/test/test_unicodedata.py
++++ b/Lib/test/test_unicodedata.py
+@@ -342,6 +342,7 @@ def test_linebreak_7643(self):
+ self.assertEqual(len(lines), 1,
+ r"\u%.4x should not be a linebreak" % i)
+
++@requires_resource('network')
+ class NormalizationTest(unittest.TestCase):
+ @staticmethod
+ def check_version(testfile):
+diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
+index 445a34ae3e..8f750537c3 100644
+--- a/Tools/scripts/run_tests.py
++++ b/Tools/scripts/run_tests.py
+@@ -69,7 +69,7 @@ def main(regrtest_args):
+ else:
+ args.extend(['-j', '0']) # Use all CPU cores
+ if not any(is_resource_use_flag(arg) for arg in regrtest_args):
+- args.extend(['-u', 'all,-largefile,-audio,-gui'])
++ args.extend(['-u', 'all,-largefile,-audio,-gui,-network'])
+
+ if cross_compile and hostrunner:
+ # If HOSTRUNNER is set and -p/--python option is not given, then
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 51d5f598d7..25fe83ea69 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -55,7 +55,7 @@
;;; Copyright © 2018, 2019, 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2018 Luther Thompson <lutheroto@gmail.com>
;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
-;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
+;;; Copyright © 2019, 2024 Tanguy Le Carrour <tanguy@bioneland.org>
;;; Copyright © 2020, 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2020, 2021 Greg Hogan <code@greghogan.com>
;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
@@ -596,6 +596,389 @@ (define-public python-3.10
(variable "PYTHONTZPATH")
(files (list "share/zoneinfo")))))))
+(define-public python-3.12
+ (package
+ (name "python-next")
+ (version "3.12.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://www.python.org/ftp/python/" version
+ "/Python-" version ".tar.xz"))
+ (sha256
+ (base32 "0w6qyfhc912xxav9x9pifwca40b4l49vy52wai9j0gc1mhni2a5y"))
+ (patches (search-patches "python-3-deterministic-build-info.patch"
+ "python-3.12-fix-tests.patch"
+ "python-3-hurd-configure.patch"))
+ (modules '((guix build utils)))
+ (snippet '(begin
+ ;; Delete the bundled copy of libexpat.
+ (delete-file-recursively "Modules/expat")
+ (substitute* "Modules/Setup"
+ ;; Link Expat instead of embedding the bundled one.
+ (("^#pyexpat.*")
+ "pyexpat pyexpat.c -lexpat\n"))
+ ;; Delete windows binaries
+ (for-each delete-file
+ (find-files "Lib/distutils/command" "\\.exe$"))))))
+ (outputs '("out" "tk" ;tkinter; adds 50 MiB to the closure
+ "idle")) ;programming environment; weighs 5MB
+ (build-system gnu-build-system)
+ (arguments
+ `(#:test-target "test"
+ #:configure-flags (list "--enable-shared" ;allow embedding
+ "--with-system-expat" ;for XML support
+ "--with-system-ffi" ;build ctypes
+ "--with-ensurepip=install" ;install pip and setuptools
+ "--with-computed-gotos" ;main interpreter loop optimization
+ "--enable-unicode=ucs4"
+ "--without-static-libpython"
+
+ ;; FIXME: These flags makes Python significantly faster, but
+ ;; leads to non-reproducible binaries.
+ ;; "--with-lto" ;increase size by 20MB, but 15% speedup
+ ;; "--enable-optimizations"
+
+ ;; Prevent the installed _sysconfigdata.py from retaining a reference
+ ;; to coreutils.
+ "INSTALL=install -c"
+ "MKDIR_P=mkdir -p"
+
+ ;; Disable runtime check failing if cross-compiling, see:
+ ;; https://lists.yoctoproject.org/pipermail/poky
This message was truncated. Download the full message here.
T
T
Tanguy Le Carrour wrote on 7 Mar 19:58 +0100
[PATCH v5] gnu: Add python-3.12 and python-next.
(address . 60240@debbugs.gnu.org)
653c693bd16ce733151e9e108a6e4e5a94a3a3c4.1709837898.git.tanguy@bioneland.org
Patch v5 **actually** contains **all** the modifications announced
in v4. Sooooorry!

* gnu/packages/python.scm (python-3.12, python-next): New variables.
* gnu/packages/patches/python-3.12-fix-tests.patch: New file.

Change-Id: Ie393b732a8863569578e72e62603b75a1655a34e
Signed-off-by: Tanguy Le Carrour <tanguy@bioneland.org>
---
.../patches/python-3.12-fix-tests.patch | 334 +++++++++++++++
gnu/packages/python.scm | 387 +++++++++++++++++-
2 files changed, 720 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/python-3.12-fix-tests.patch

Toggle diff (418 lines)
diff --git a/gnu/packages/patches/python-3.12-fix-tests.patch b/gnu/packages/patches/python-3.12-fix-tests.patch
new file mode 100644
index 0000000000..fa5c8027ce
--- /dev/null
+++ b/gnu/packages/patches/python-3.12-fix-tests.patch
@@ -0,0 +1,334 @@
+From f0698133e7d6c353a3e6ae0fc62e57ba558a9bc0 Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Date: Wed, 28 Oct 2020 22:55:05 -0400
+Subject: [PATCH] Skip problematic Python 3 tests in Guix.
+
+A subset of the hunks in this patch is tracked upstream at
+https://bugs.python.org/issue38845, which was contributed by Tanguy Le
+Carrour <tanguy@bioneland.org>.
+
+diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
+index e42c7ab4bd..8087c84dab 100644
+--- a/Lib/test/_test_multiprocessing.py
++++ b/Lib/test/_test_multiprocessing.py
+@@ -1695,6 +1695,7 @@ def _test_wait_result(cls, c, pid):
+ if pid is not None:
+ os.kill(pid, signal.SIGINT)
+
++ @unittest.skipIf(True, "This fails for unknown reasons on Guix")
+ def test_wait_result(self):
+ if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
+ pid = os.getpid()
+@@ -4150,6 +4151,7 @@ def test_shared_memory_across_processes(self):
+ sms.close()
+
+ @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
+ # bpo-36368: protect SharedMemoryManager server process from
+ # KeyboardInterrupt signals.
+diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
+index 85c8152d49..e35cfffe84 100644
+--- a/Lib/test/test_asyncio/test_base_events.py
++++ b/Lib/test/test_asyncio/test_base_events.py
+@@ -1377,6 +1377,8 @@ def test_create_connection_no_inet_pton(self, m_socket):
+ self._test_create_connection_ip_addr(m_socket, False)
+
+ @patch_socket
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_create_connection_service_name(self, m_socket):
+ m_socket.getaddrinfo = socket.getaddrinfo
+ sock = m_socket.socket.return_value
+diff --git a/Lib/test/test_ctypes/test_find.py b/Lib/test/test_ctypes/test_find.py
+index a41e94971d..1291af3057 100644
+--- a/Lib/test/test_ctypes/test_find.py
++++ b/Lib/test/test_ctypes/test_find.py
+@@ -117,6 +117,7 @@ def test_find_library_with_gcc(self):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
+ self.assertNotEqual(find_library('c'), None)
+
++ @unittest.skipIf(True, 'Fails on Guix.')
+ def test_find_library_with_ld(self):
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
+ unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
+diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
+index 1ee9958445..ab6b41befe 100644
+--- a/Lib/test/test_generators.py
++++ b/Lib/test/test_generators.py
+@@ -34,6 +34,7 @@ def generator2(self):
+ else:
+ return "FAILED"
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
+ def test_raise_and_yield_from(self):
+ gen = self.generator1()
+ gen.send(None)
+diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
+index ec105ae1a0..ae4c5b672e 100644
+--- a/Lib/test/test_pathlib.py
++++ b/Lib/test/test_pathlib.py
+@@ -3069,6 +3069,7 @@ def test_rglob(self):
+ 'pwd module does not expose getpwall()')
+ @unittest.skipIf(sys.platform == "vxworks",
+ "no home directory on VxWorks")
++ @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
+ def test_expanduser(self):
+ P = self.cls
+ import_helper.import_module('pwd')
+diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
+index 51b844262e..004d3133cf 100644
+--- a/Lib/test/test_pdb.py
++++ b/Lib/test/test_pdb.py
+@@ -1580,6 +1580,7 @@ def test_pdb_next_command_subiterator():
+ (Pdb) continue
+ """
+
++@unittest.skipIf(True, 'Fails on Guix… but skipIf not taken into account?!')
+ def test_pdb_issue_20766():
+ """Test for reference leaks when the SIGINT handler is set.
+
+@@ -1598,11 +1599,11 @@ def test_pdb_issue_20766():
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 1: <built-in function default_int_handler>
++ pdb 1: 1
+ > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
+ -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
+ (Pdb) continue
+- pdb 2: <built-in function default_int_handler>
++ pdb 2: 1
+ """
+
+ def test_pdb_issue_43318():
+diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
+index 2ab6f6a986..8cf6b4d1c8 100644
+--- a/Lib/test/test_regrtest.py
++++ b/Lib/test/test_regrtest.py
+@@ -1049,6 +1049,7 @@ def test_fromfile(self):
+ output = self.run_tests('--fromfile', filename)
+ self.check_executed_tests(output, tests, stats=stats)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_interrupted(self):
+ code = TEST_INTERRUPTED
+ test = self.create_test('sigint', code=code)
+@@ -1066,6 +1067,7 @@ def test_slowest(self):
+ % (self.TESTNAME_REGEX, len(tests)))
+ self.check_line(output, regex)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
+ def test_slowest_interrupted(self):
+ # Issue #25373: test --slowest with an interrupted test
+ code = TEST_INTERRUPTED
+diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
+index 317e7ca8f8..7f272daf24 100644
+--- a/Lib/test/test_resource.py
++++ b/Lib/test/test_resource.py
+@@ -151,6 +151,7 @@ def test_freebsd_contants(self):
+
+ @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
+ @support.requires_linux_version(2, 6, 36)
++ @unittest.skipIf(True, "Bug: the PermissionError is not raised")
+ def test_prlimit(self):
+ self.assertRaises(TypeError, resource.prlimit)
+ self.assertRaises(ProcessLookupError, resource.prlimit,
+diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
+index bf60f37934..5e3a96380a 100644
+--- a/Lib/test/test_shutil.py
++++ b/Lib/test/test_shutil.py
+@@ -1743,6 +1743,7 @@ def test_make_archive(self):
+ base_name = os.path.join(tmpdir, 'archive')
+ self.assertRaises(ValueError, make_archive, base_name, 'xxx')
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ def test_make_archive_owner_group(self):
+ # testing make_archive with owner and group, with various combinations
+@@ -1771,6 +1772,7 @@ def test_make_archive_owner_group(self):
+ self.assertTrue(os.path.isfile(res))
+
+
++ @unittest.skipIf(True, "The Guix build container has no root user")
+ @support.requires_zlib()
+ @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+ def test_tarfile_root_owner(self):
+diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
+index 637a0ca3b3..2fb804e340 100644
+--- a/Lib/test/test_signal.py
++++ b/Lib/test/test_signal.py
+@@ -160,6 +160,7 @@ def test_valid_signals(self):
+ self.assertLess(signum, signal.NSIG)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @support.requires_subprocess()
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers exit via SIGINT."""
+@@ -211,6 +212,7 @@ def test_issue9324(self):
+ signal.signal(7, handler)
+
+ @unittest.skipUnless(sys.executable, "sys.executable required.")
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @support.requires_subprocess()
+ def test_keyboard_interrupt_exit_code(self):
+ """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
+@@ -1407,6 +1409,7 @@ def cycle_handlers():
+
+ class RaiseSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ def test_sigint(self):
+ with self.assertRaises(KeyboardInterrupt):
+ signal.raise_signal(signal.SIGINT)
+@@ -1452,6 +1455,7 @@ def __del__(self):
+
+ class PidfdSignalTest(unittest.TestCase):
+
++ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+ @unittest.skipUnless(
+ hasattr(signal, "pidfd_send_signal"),
+ "pidfd support not built in",
+diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
+index 4eb5af99d6..9c7b8f6dbc 100644
+--- a/Lib/test/test_socket.py
++++ b/Lib/test/test_socket.py
+@@ -1016,6 +1016,8 @@ def testHostnameRes(self):
+ if not fqhn in all_host_names:
+ self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
+
++ @unittest.skipUnless(support.is_resource_enabled('network'),
++ 'network is not enabled')
+ def test_host_resolution(self):
+ for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:
+ self.assertEqual(socket.gethostbyname(addr), addr)
+@@ -1161,6 +1163,8 @@ def testNtoHErrors(self):
+ self.assertRaises(OverflowError, socket.ntohl, k)
+ self.assertRaises(OverflowError, socket.htonl, k)
+
++ @unittest.skipUnless(os.path.exists("/etc/services"),
++ "getservbyname uses /etc/services, which is not in the chroot")
+ def testGetServBy(self):
+ eq = self.assertEqual
+ # Find one service that exists, then check all the related interfaces.
+@@ -1521,6 +1525,8 @@ def test_sio_loopback_fast_path(self):
+ raise
+ self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ def testGetaddrinfo(self):
+ try:
+ socket.getaddrinfo('localhost', 80)
+@@ -1653,6 +1659,8 @@ def test_getnameinfo(self):
+ # only IP addresses are allowed
+ self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
+
++ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
++ "getaddrinfo() will fail")
+ @unittest.skipUnless(support.is_resource_enabled('network'),
+ 'network is not enabled')
+ def test_idna(self):
+diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
+index 50766c2548..0c7eb7a83a 100644
+--- a/Lib/test/test_spwd.py
++++ b/Lib/test/test_spwd.py
+@@ -9,8 +9,7 @@
+ spwd = import_helper.import_module('spwd')
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
+- 'root privileges required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdRoot(unittest.TestCase):
+
+ def test_getspall(self):
+@@ -60,8 +59,7 @@ def test_getspnam(self):
+ self.assertRaises(TypeError, spwd.getspnam, bytes_name)
+
+
+-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
+- 'non-root user required')
++@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
+ class TestSpwdNonRoot(unittest.TestCase):
+
+ def test_getspnam_exception(self):
+diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
+index 71489ea493..33351919fe 100644
+--- a/Lib/test/test_tarfile.py
++++ b/Lib/test/test_tarfile.py
+@@ -2911,9 +2911,12 @@ def root_is_uid_gid_0():
+ import pwd, grp
+ except ImportError:
+ return False
+- if pwd.getpwuid(0)[0] != 'root':
+- return False
+- if grp.getgrgid(0)[0] != 'root':
++ try:
++ if pwd.getpwuid(0)[0] != 'root':
++ return False
++ if grp.getgrgid(0)[0] != 'root':
++ return False
++ except KeyError:
+ return False
+ return True
+
+diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
+index 00d9e591c7..2515603715 100644
+--- a/Lib/test/test_threading.py
++++ b/Lib/test/test_threading.py
+@@ -1962,6 +1962,7 @@ def check_interrupt_main_noerror(self, signum):
+ # Restore original handler
+ signal.signal(signum, handler)
+
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_subthread(self):
+ # Calling start_new_thread with a function that executes interrupt_main
+ # should raise KeyboardInterrupt upon completion.
+@@ -1973,6 +1974,8 @@ def call_interrupt():
+ t.join()
+ t.join()
+
++
++ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
+ def test_interrupt_main_mainthread(self):
+ # Make sure that if interrupt_main is called in main thread that
+ # KeyboardInterrupt is raised instantly.
+diff --git a/Lib/test/test_tools/test_freeze.py b/Lib/test/test_tools/test_freeze.py
+index 0e7ed67de7..6539a2983b 100644
+--- a/Lib/test/test_tools/test_freeze.py
++++ b/Lib/test/test_tools/test_freeze.py
+@@ -23,6 +23,7 @@
+ 'test is too slow with PGO')
+ class TestFreeze(unittest.TestCase):
+
++ @unittest.skipIf(True, 'Fails on Guix.')
+ @support.requires_resource('cpu') # Building Python is slow
+ def test_freeze_simple_script(self):
+ script = textwrap.dedent("""
+diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
+index 515c3840cb..a96dfad0fe 100644
+--- a/Lib/test/test_unicodedata.py
++++ b/Lib/test/test_unicodedata.py
+@@ -342,6 +342,7 @@ def test_linebreak_7643(self):
+ self.assertEqual(len(lines), 1,
+ r"\u%.4x should not be a linebreak" % i)
+
++@requires_resource('network')
+ class NormalizationTest(unittest.TestCase):
+ @staticmethod
+ def check_version(testfile):
+diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
+index 445a34ae3e..8f750537c3 100644
+--- a/Tools/scripts/run_tests.py
++++ b/Tools/scripts/run_tests.py
+@@ -69,7 +69,7 @@ def main(regrtest_args):
+ else:
+ args.extend(['-j', '0']) # Use all CPU cores
+ if not any(is_resource_use_flag(arg) for arg in regrtest_args):
+- args.extend(['-u', 'all,-largefile,-audio,-gui'])
++ args.extend(['-u', 'all,-largefile,-audio,-gui,-network'])
+
+ if cross_compile and hostrunner:
+ # If HOSTRUNNER is set and -p/--python option is not given, then
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 51d5f598d7..df3ea7ca9a 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -55,7 +55,7 @@
;;; Copyright © 2018, 2019, 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2018 Luther Thompson <lutheroto@gmail.com>
;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
-;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
+;;; Copyright © 2019, 2024 Tanguy Le Carrour <tanguy@bioneland.org>
;;; Copyright © 2020, 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2020, 2021 Greg Hogan <code@greghogan.com>
;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
@@ -596,6 +596,391 @@ (define-public python-3.10
(variable "PYTHONTZPATH")
(files (list "share/zoneinfo")))))))
+(define-public python-3.12
+ (package
+ (name "python-next")
+ (version "3.12.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://www.python.org/ftp/python/" version
+ "/Python-" version ".tar.xz"))
+ (sha256
+ (base32 "0w6qyfhc912xxav9x9pifwca40b4l49vy52wai9j0gc1mhni2a5y"))
+ (patches (search-patches "python-3-deterministic-build-info.patch"
+ "python-3.12-fix-tests.patch"
+ "python-3-hurd-configure.patch"))
+ (modules '((guix build utils)))
+ (snippet '(begin
+ ;; Delete the bundled copy of libexpat.
+ (delete-file-recursively "Modules/expat")
+ (substitute* "Modules/Setup"
+ ;; Link Expat instead of embedding the bundled one.
+ (("^#pyexpat.*")
+ "pyexpat pyexpat.c -lexpat\n"))
+ ;; Delete windows binaries
+ (for-each delete-file
+ (find-files "Lib/distutils/command" "\\.exe$"))))))
+ (outputs '("out" "tk" ;tkinter; adds 50 MiB to the closure
+ "idle")) ;programming environment; weighs 5MB
+ (build-system gnu-build-system)
+ (arguments
+ `(#:test-target "test"
+ #:configure-flags (list "--enable-shared" ;allow embedding
+ "--with-system-expat" ;for XML support
+ "--with-system-ffi" ;build ctypes
+ "--with-ensurepip=install" ;install pip and setuptools
+ "--with-computed-gotos" ;main interpreter loop optimization
+ "--enable-unicode=ucs4"
+ "--without-static-libpython"
+
+ ;; FIXME: These flags makes Python significantly faster,
+ ;; but leads to non-reproducible binaries.
+ ;; "--with-lto" ;increase size by 20MB, but 15% speedup
+ ;; "--enable-optimizations"
+
+ ;; Prevent the installed _sysconfigdata.py from retaining
+ ;; a reference to coreutils.
+ "INSTALL=install -c"
+ "MKDIR_P=mkdir -p"
+
+ ;; Disable runtime check failing if cross-compiling, see:
+ ;; https://lists.yoctoproject.org/pipermail/poky/2013-June/008997.html
+ ,@(if (%current-target-system)
+ '("ac_cv_buggy_getaddrinfo=no"
+ "ac_cv_file__dev_ptmx=no"
+ "ac_cv_file__dev_ptc=no")
+ '())
+ ;; -fno-semantic-interposition reinstates some
+ ;; optimizations by gcc leading to around 15% speedup.
+ ;; This is the default starting from python 3.10.
+ "CFLAGS=-fno-semantic-interposition"
+ (string-append "LDFLAGS=-Wl,-rpath="
+ (assoc-ref %outputs "out
This message was truncated. Download the full message here.
?