Legrandin / pycryptodome

A self-contained cryptographic library for Python
https://www.pycryptodome.org
Other
2.74k stars 492 forks source link

Build failure on CPython `3.13t` (disabled GIL): would build wheel with unsupported tag #813

Open bastimeyer opened 3 weeks ago

bastimeyer commented 3 weeks ago

CPython 3.13 has added the --disable-gil build option for disabling the global interpreter lock. This introduces some ABI changes and therefore adds the t (threading) ABI flag until those changes become the default in upcoming CPython releases.

This ABI flag unfortunately breaks building pycryptodome wheels in this kind of environment.

$ python3.13 -c 'import sys;print(f"{sys.version_info=}\n{sys.abiflags=}")'
sys.version_info=sys.version_info(major=3, minor=13, micro=0, releaselevel='beta', serial=2)
sys.abiflags='t'

AssertionError: would build wheel with unsupported tag ('cp35', 'abi3', 'linux_x86_64')

The issue appears to be the py-limited-api bdist_wheel configuration:

$ python3.13 -m venv /tmp/venv-pycryptodome-313t
$ source /tmp/venv-pycryptodome-313t/bin/activate
$ pip -v install --no-cache --no-binary=:all: pycryptodome
...
  running install_scripts
  Traceback (most recent call last):
    File "/tmp/venv-pycryptodome-313t/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
      ~~~~^^
    File "/tmp/venv-pycryptodome-313t/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/venv-pycryptodome-313t/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                          metadata_directory)
                                          ^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-n5p4723l/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 410, in build_wheel
      return self._build_with_temp_dir(
             ~~~~~~~~~~~~~~~~~~~~~~~~~^
          ['bdist_wheel'],
          ^^^^^^^^^^^^^^^^
      ...<3 lines>...
          self._arbitrary_args(config_settings),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      )
      ^
    File "/tmp/pip-build-env-n5p4723l/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 395, in _build_with_temp_dir
      self.run_setup()
      ~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-n5p4723l/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 311, in run_setup
      exec(code, locals())
      ~~~~^^^^^^^^^^^^^^^^
    File "<string>", line 500, in <module>
    File "/tmp/pip-build-env-n5p4723l/overlay/lib/python3.13/site-packages/setuptools/__init__.py", line 103, in setup
      return distutils.core.setup(**attrs)
             ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-n5p4723l/overlay/lib/python3.13/site-packages/setuptools/_distutils/core.py", line 184, in setup
      return run_commands(dist)
    File "/tmp/pip-build-env-n5p4723l/overlay/lib/python3.13/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
      dist.run_commands()
      ~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-n5p4723l/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
      self.run_command(cmd)
      ~~~~~~~~~~~~~~~~^^^^^
    File "/tmp/pip-build-env-n5p4723l/overlay/lib/python3.13/site-packages/setuptools/dist.py", line 968, in run_command
      super().run_command(command)
      ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-n5p4723l/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
      ~~~~~~~~~~~^^
    File "/tmp/pip-build-env-n5p4723l/normal/lib/python3.13/site-packages/wheel/bdist_wheel.py", line 405, in run
      impl_tag, abi_tag, plat_tag = self.get_tag()
                                    ~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-n5p4723l/normal/lib/python3.13/site-packages/wheel/bdist_wheel.py", line 355, in get_tag
      tag in supported_tags
  AssertionError: would build wheel with unsupported tag ('cp35', 'abi3', 'linux_x86_64')
  error: subprocess-exited-with-error

  × Building wheel for pycryptodome (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /tmp/venv-pycryptodome-313t/bin/python3.13 /tmp/venv-pycryptodome-313t/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmp7erx0b00
  cwd: /tmp/pip-install-tj_45mnk/pycryptodome_a71993a696bd4012b7591b24261f2f5c
  Building wheel for pycryptodome (pyproject.toml): finished with status 'error'
  ERROR: Failed building wheel for pycryptodome
Failed to build pycryptodome
ERROR: Could not build wheels for pycryptodome, which is required to install pyproject.toml-based projects
Varbin commented 3 weeks ago

Maybe this issue should be reported at setuptools/wheel/... so multiple abi levels can be build (e.g. cp35 for GIL enabled Python versions and cp313t (?) for GIL disabled Python).

bastimeyer commented 3 weeks ago

Please have a look at this comment on the setuptools issue tracker (bdist_wheel has been vendored into setuptools - wheel won't patch its current implementation) and make a suggestion in regards to having a config option for building different kinds of wheels: https://github.com/pypa/setuptools/issues/4420#issuecomment-2172946806

bastimeyer commented 2 weeks ago

The maintainers of setuptools are asking for feedback on how to solve building extensions with py_limited_api=True being set when using a no-GIL environment. Please see here, thank you: https://github.com/pypa/setuptools/pull/4424