Skip to content

Can't build wheels on CPython 3.13t (no GIL / PEP 703) when py-limited-api option is set #624

@bastimeyer

Description

@bastimeyer

I ran into this issue while trying to build a pycryptodome wheel on CPython 3.13t.
See Legrandin/pycryptodome#813

The pycryptodome project sets the py-limited-api option to cp35 in order to limit its abi3 wheels to cp35 and above.

However, when using CPython 3.13t (built without global interpreter lock - PEP 703), this option raises an AssertionError when trying to build the wheel.

The reason for this is this if-else-block:
https://github.com/pypa/wheel/blob/0.43.0/src/wheel/bdist_wheel.py#L344-L348

Building CPython 3.13 without the GIL adds the t ABI flag, so the (impl_name + impl_ver).startswith("cp3") check is incorrect where it sets abi_tag = "abi3" if the condition is true. The AssertionError is then raised afterwards when it checks for supported tags:
https://github.com/pypa/wheel/blob/0.43.0/src/wheel/bdist_wheel.py#L349-L356

$ 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'

$ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions