markupsafe icon indicating copy to clipboard operation
markupsafe copied to clipboard

Building markupsafe wheel fails on 3.13a1

Open tonybaloney opened this issue 2 years ago • 4 comments

Compiling wheels on Python 3.13 is hard. Compiling them with the new ABI (t) when --disable-gil is even more challenging.

I'm just logging this here, not expecting it to be fixed anytime soon :-)

Environment:

  • Python version: 3.13a1+ (with --disable-gil --with-pydebug flags)
  • Flask version: n/a
pip install flask
/home/anthonyshaw/cpython/.venv-main/lib/python3.13/site-packages/pip/_internal/metadata/importlib/_envs.py:111: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pip._vendor.pkg_resources import find_distributions
Collecting flask
  Obtaining dependency information for flask from https://files.pythonhosted.org/packages/36/42/015c23096649b908c809c69388a805a571a3bea44362fe87e33fc3afa01f/flask-3.0.0-py3-none-any.whl.metadata
  Using cached flask-3.0.0-py3-none-any.whl.metadata (3.6 kB)
Collecting Werkzeug>=3.0.0 (from flask)
  Obtaining dependency information for Werkzeug>=3.0.0 from https://files.pythonhosted.org/packages/c3/fc/254c3e9b5feb89ff5b9076a23218dafbc99c96ac5941e900b71206e6313b/werkzeug-3.0.1-py3-none-any.whl.metadata
  Using cached werkzeug-3.0.1-py3-none-any.whl.metadata (4.1 kB)
Collecting Jinja2>=3.1.2 (from flask)
  Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
/home/anthonyshaw/cpython/.venv-main/lib/python3.13/site-packages/pip/_internal/metadata/importlib/_dists.py:74: DeprecationWarning: Unimplemented abstract methods {'locate_file'}
  return cls(files, info_location)
Collecting itsdangerous>=2.1.2 (from flask)
  Using cached itsdangerous-2.1.2-py3-none-any.whl (15 kB)
Collecting click>=8.1.3 (from flask)
  Obtaining dependency information for click>=8.1.3 from https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl.metadata
  Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting blinker>=1.6.2 (from flask)
  Obtaining dependency information for blinker>=1.6.2 from https://files.pythonhosted.org/packages/fa/2a/7f3714cbc6356a0efec525ce7a0613d581072ed6eb53eb7b9754f33db807/blinker-1.7.0-py3-none-any.whl.metadata
  Using cached blinker-1.7.0-py3-none-any.whl.metadata (1.9 kB)
Collecting MarkupSafe>=2.0 (from Jinja2>=3.1.2->flask)
  Using cached MarkupSafe-2.1.3.tar.gz (19 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Using cached flask-3.0.0-py3-none-any.whl (99 kB)
Using cached blinker-1.7.0-py3-none-any.whl (13 kB)
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Using cached werkzeug-3.0.1-py3-none-any.whl (226 kB)
Building wheels for collected packages: MarkupSafe
  Building wheel for MarkupSafe (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for MarkupSafe (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [83 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-313-pydebug
      creating build/lib.linux-x86_64-cpython-313-pydebug/markupsafe
      copying src/markupsafe/__init__.py -> build/lib.linux-x86_64-cpython-313-pydebug/markupsafe
      copying src/markupsafe/_native.py -> build/lib.linux-x86_64-cpython-313-pydebug/markupsafe
      running egg_info
      writing src/MarkupSafe.egg-info/PKG-INFO
      writing dependency_links to src/MarkupSafe.egg-info/dependency_links.txt
      writing top-level names to src/MarkupSafe.egg-info/top_level.txt
      reading manifest file 'src/MarkupSafe.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      no previously-included directories found matching 'docs/_build'
      warning: no previously-included files matching '*.pyc' found anywhere in distribution
      adding license file 'LICENSE.rst'
      writing manifest file 'src/MarkupSafe.egg-info/SOURCES.txt'
      copying src/markupsafe/_speedups.c -> build/lib.linux-x86_64-cpython-313-pydebug/markupsafe
      copying src/markupsafe/_speedups.pyi -> build/lib.linux-x86_64-cpython-313-pydebug/markupsafe
      copying src/markupsafe/py.typed -> build/lib.linux-x86_64-cpython-313-pydebug/markupsafe
      running build_ext
      building 'markupsafe._speedups' extension
      creating build/temp.linux-x86_64-cpython-313-pydebug
      creating build/temp.linux-x86_64-cpython-313-pydebug/src
      creating build/temp.linux-x86_64-cpython-313-pydebug/src/markupsafe
      gcc -pthread -fno-strict-overflow -Wsign-compare -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -Og -Wall -fPIC -I/home/anthonyshaw/cpython/.venv-main/include -I/home/anthonyshaw/cpython/Include -I/home/anthonyshaw/cpython -c src/markupsafe/_speedups.c -o build/temp.linux-x86_64-cpython-313-pydebug/src/markupsafe/_speedups.o
      gcc -pthread -shared build/temp.linux-x86_64-cpython-313-pydebug/src/markupsafe/_speedups.o -o build/lib.linux-x86_64-cpython-313-pydebug/markupsafe/_speedups.cpython-313td-x86_64-linux-gnu.so
      installing to build/bdist.linux-x86_64/wheel
      running install
      running install_lib
      creating build/bdist.linux-x86_64
      creating build/bdist.linux-x86_64/wheel
      creating build/bdist.linux-x86_64/wheel/markupsafe
      copying build/lib.linux-x86_64-cpython-313-pydebug/markupsafe/_speedups.c -> build/bdist.linux-x86_64/wheel/markupsafe
      copying build/lib.linux-x86_64-cpython-313-pydebug/markupsafe/_speedups.pyi -> build/bdist.linux-x86_64/wheel/markupsafe
      copying build/lib.linux-x86_64-cpython-313-pydebug/markupsafe/_speedups.cpython-313td-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/wheel/markupsafe
      copying build/lib.linux-x86_64-cpython-313-pydebug/markupsafe/__init__.py -> build/bdist.linux-x86_64/wheel/markupsafe
      copying build/lib.linux-x86_64-cpython-313-pydebug/markupsafe/py.typed -> build/bdist.linux-x86_64/wheel/markupsafe
      copying build/lib.linux-x86_64-cpython-313-pydebug/markupsafe/_native.py -> build/bdist.linux-x86_64/wheel/markupsafe
      running install_egg_info
      Copying src/MarkupSafe.egg-info to build/bdist.linux-x86_64/wheel/MarkupSafe-2.1.3-py3.13.egg-info
      running install_scripts
      Traceback (most recent call last):
        File "/home/anthonyshaw/cpython/.venv-main/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/anthonyshaw/cpython/.venv-main/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 "/home/anthonyshaw/cpython/.venv-main/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,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 434, in build_wheel
          return self._build_with_temp_dir(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 419, in _build_with_temp_dir
          self.run_setup()
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 507, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 341, in run_setup
          exec(code, locals())
        File "<string>", line 65, in <module>
        File "<string>", line 41, in run_setup
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/dist.py", line 989, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/wheel/bdist_wheel.py", line 406, in run
          impl_tag, abi_tag, plat_tag = self.get_tag()
                                        ^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-wnxiqzpz/overlay/lib/python3.13/site-packages/wheel/bdist_wheel.py", line 356, in get_tag
          tag in supported_tags
      AssertionError: would build wheel with unsupported tag ('cp313', 'cp313td', 'linux_x86_64')
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for MarkupSafe
Failed to build MarkupSafe
ERROR: Could not build wheels for MarkupSafe, which is required to install pyproject.toml-based projects
/home/anthonyshaw/cpython/.venv-main/lib/python3.13/site-packages/pip/_internal/self_outdated_check.py:232: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  current_time=datetime.datetime.utcnow(),

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip

tonybaloney avatar Nov 13 '23 09:11 tonybaloney

This belongs in the markupsafe repo, not in the flask repo...

ThiefMaster avatar Nov 13 '23 09:11 ThiefMaster

Considering that 3.13 is still in early alpha, I think the fastest way to get closer to a fix (assuming this is something that needs to be fixed in markupsafe), would be sending a PR that fixes it and runs CI on 3.13-dev as well.

Whether it makes sense to do so during alpha and not waiting at least until beta I don't know...

ThiefMaster avatar Nov 13 '23 09:11 ThiefMaster

This was from a conversion on Mastodon yesterday, Anthony is experimenting with threaded web servers with the new freethreading build. I do want to at least detect that we can't build yet and allow the native fallback.

davidism avatar Nov 13 '23 13:11 davidism

This is currently a bug in wheel, see https://github.com/pypa/wheel/issues/585

tonybaloney avatar Nov 13 '23 20:11 tonybaloney

Looks like that wheel issue was resolved and released, so we could try this again at some point.

davidism avatar Mar 11 '24 20:03 davidism

Yep, packaging 24.0 has now been released with support for the "t" tag for free-threaded, and it's been vendored and released in wheel 0.43.0.

On Sunday Pillow failed to build with:

AssertionError: would build wheel with unsupported tag ('cp313', 'cp313t', 'linux_x86_64')

On Monday it successfully builds! (and then a segmentation fault running tests but that's for another day).

hugovk avatar Mar 12 '24 07:03 hugovk

Going to close this, I'm assuming it works now but don't have a way to test it myself.

davidism avatar Apr 16 '24 22:04 davidism