Bug 2021808 - python-crypto fails to build with Python 3.11: fatal error: longintrepr.h: No such file or directory
Summary: python-crypto fails to build with Python 3.11: fatal error: longintrepr.h: N...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-crypto
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Paul Howarth
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2021-11-10 09:17 UTC by Tomáš Hrnčiar
Modified: 2021-11-23 15:47 UTC (History)
4 users (show)

Fixed In Version: python-crypto-2.6.1-37.fc36
Clone Of:
Environment:
Last Closed: 2021-11-23 15:47:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2021-11-10 09:17:14 UTC
python-crypto fails to build with Python 3.11.0a2.

src/_fastmath.c:33:10: fatal error: longintrepr.h: No such file or directory
   33 | #include <longintrepr.h>                                /* for conversions */
      |          ^~~~~~~~~~~~~~~
compilation terminated.

The non-limited API files cellobject.h, classobject.h, context.h, funcobject.h, genobject.h and longintrepr.h have been moved to the Include/cpython directory. Moreover, the eval.h header file was removed. These files must not be included directly, as they are already included in Python.h: Include Files. If they have been included directly, consider including Python.h instead. (Contributed by Victor Stinner in bpo-35134.)
https://bugs.python.org/issue35134
https://docs.python.org/3.11/whatsnew/3.11.html


For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/02939749-python-crypto/

For all our attempts to build python-crypto with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/python-crypto/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Paul Howarth 2021-11-11 11:57:57 UTC
It's builing OK now.

There's another problem coming up for Python 3.12: this module uses the deprecated distutils that will be going away in 3.12 and its use of distutils isn't covered by the migration guide so I don't know how to fix that.

Comment 2 Miro Hrončok 2021-11-11 12:17:57 UTC
$ rg distutils
setup.py
39:from distutils import core
40:from distutils.ccompiler import new_compiler
41:from distutils.core import Extension, Command
42:from distutils.command.build import build
43:from distutils.command.build_ext import build_ext
59:    from distutils.command.build_py import build_py_2to3 as build_py
62:    from distutils.command.build_py import build_py

lib/Crypto/Util/number.py
44:    # from distutils.sysconfig import get_config_var

lib/Crypto/SelfTest/PublicKey/test_DSA.py
226:        from distutils.sysconfig import get_config_var

lib/Crypto/SelfTest/PublicKey/test_RSA.py
396:        from distutils.sysconfig import get_config_var



The runtime change is easy:

distutils.sysconfig import get_config_var -> sysconfig.get_config_var



The setup.py changes might require more fiddling, but generally:


from distutils import core is used for:
 core.setup -> use setuptools.setup
 core.setup_keywords -> remove the check, only used to support pre-2.3 Python


from distutils.ccompiler import new_compiler -> from setuptools.command.build_ext import new_compiler


from distutils.core import Extension, Command -> form setuptools import Extension, Command


from distutils.command.build import build -> appears unused?


from distutils.command.build_ext import build_ext -> from setuptools.command.build_ext import build_ext

from distutils.command.build_py import build_py_2to3 -> drop this entirely and make the code Python 3 compatible at once by calling the 2to3 tool while it still exists?

from distutils.command.build_py import build_py -> from setuptools.command.build_py import build_py

Comment 3 Paul Howarth 2021-11-11 19:40:52 UTC
Thanks, that seems to have worked for me (python-crypto-2.6.1-38.fc36).

There's just this:

writing byte-compilation script '/tmp/tmp6oe3lj52.py'
/usr/bin/python3 -Wignore:The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives:DeprecationWarning /tmp/tmp6oe3lj52.py
removing /tmp/tmp6oe3lj52.py

That looks like something that will need fixing in whatever generates the byte-compilation script, right?

Comment 4 Miro Hrončok 2021-11-11 20:42:11 UTC
No idea where is this coming from.

Comment 5 Paul Howarth 2021-11-12 13:19:05 UTC
Looks like setuptools still uses distutils internally:

writing byte-compilation script '/tmp/tmp3uz0_qn4.py'
Traceback (most recent call last):
  File "/builddir/build/BUILD/pycrypto-2.6.1/setup.py", line 386, in <module>
    setup(**kw)
  File "/usr/lib/python3.10/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib64/python3.10/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib64/python3.10/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python3.10/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.10/site-packages/setuptools/command/install.py", line 61, in run
    return orig.install.run(self)
  File "/usr/lib64/python3.10/distutils/command/install.py", line 580, in run
    self.run_command(cmd_name)
  File "/usr/lib64/python3.10/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python3.10/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.10/site-packages/setuptools/command/install_lib.py", line 15, in run
    self.byte_compile(outfiles)
  File "/usr/lib64/python3.10/distutils/command/install_lib.py", line 136, in byte_compile
    byte_compile(files, optimize=self.optimize,
  File "/usr/lib64/python3.10/distutils/util.py", line 389, in byte_compile
    raise RuntimeError('Raising exception to see how we got here')
RuntimeError: Raising exception to see how we got here

I got that from hacking an exception into distutils.util where it's about to write a byte-compilation script (on regular rawhide, not the Python 3.11 version, as I expect they're the same in this respect).

If I add SETUPTOOLS_USE_DISTUTILS=local then that message no longer appears, and I guess the plan is for that to be the default for Python 3.12.


Note You need to log in before you can comment on or make changes to this bug.