Building regex module with Python 3.13

I use the regex module in one project. I seem to be unable to install/update it with a build of 3.13.0a2+ (current tip of the main python/cpython branch). Trying to update it manually I get this:

(3.13) (python311a) ~/src/smontanaro.net% python -m pip install -U regex
Requirement already satisfied: regex in ./3.13/lib/python3.13/site-packages (2023.8.8)
Collecting regex
  Downloading regex-2023.10.3.tar.gz (394 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 394.7/394.7 kB 8.4 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: regex
  Building wheel for regex (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for regex (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [76 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-14.1-arm64-cpython-313
      creating build/lib.macosx-14.1-arm64-cpython-313/regex
      copying regex_3/__init__.py -> build/lib.macosx-14.1-arm64-cpython-313/regex
      copying regex_3/regex.py -> build/lib.macosx-14.1-arm64-cpython-313/regex
      copying regex_3/_regex_core.py -> build/lib.macosx-14.1-arm64-cpython-313/regex
      copying regex_3/test_regex.py -> build/lib.macosx-14.1-arm64-cpython-313/regex
      running build_ext
      building 'regex._regex' extension
      creating build/temp.macosx-14.1-arm64-cpython-313
      creating build/temp.macosx-14.1-arm64-cpython-313/regex_3
      gcc -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -I/Users/skip/src/smontanaro.net/3.13/include -I/Users/skip/src/python/cpython/Include -I/Users/skip/src/python/cpython -c regex_3/_regex.c -o build/temp.macosx-14.1-arm64-cpython-313/regex_3/_regex.o
      gcc -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -I/Users/skip/src/smontanaro.net/3.13/include -I/Users/skip/src/python/cpython/Include -I/Users/skip/src/python/cpython -c regex_3/_regex_unicode.c -o build/temp.macosx-14.1-arm64-cpython-313/regex_3/_regex_unicode.o
      gcc -bundle -undefined dynamic_lookup build/temp.macosx-14.1-arm64-cpython-313/regex_3/_regex.o build/temp.macosx-14.1-arm64-cpython-313/regex_3/_regex_unicode.o -o build/lib.macosx-14.1-arm64-cpython-313/regex/_regex.cpython-313t-darwin.so
      installing to build/bdist.macosx-14.1-arm64/wheel
      running install
      running install_lib
      creating build/bdist.macosx-14.1-arm64
      creating build/bdist.macosx-14.1-arm64/wheel
      creating build/bdist.macosx-14.1-arm64/wheel/regex
      copying build/lib.macosx-14.1-arm64-cpython-313/regex/test_regex.py -> build/bdist.macosx-14.1-arm64/wheel/regex
      copying build/lib.macosx-14.1-arm64-cpython-313/regex/__init__.py -> build/bdist.macosx-14.1-arm64/wheel/regex
      copying build/lib.macosx-14.1-arm64-cpython-313/regex/_regex.cpython-313t-darwin.so -> build/bdist.macosx-14.1-arm64/wheel/regex
      copying build/lib.macosx-14.1-arm64-cpython-313/regex/regex.py -> build/bdist.macosx-14.1-arm64/wheel/regex
      copying build/lib.macosx-14.1-arm64-cpython-313/regex/_regex_core.py -> build/bdist.macosx-14.1-arm64/wheel/regex
      running install_egg_info
      running egg_info
      writing regex.egg-info/PKG-INFO
      writing dependency_links to regex.egg-info/dependency_links.txt
      writing top-level names to regex.egg-info/top_level.txt
      reading manifest file 'regex.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE.txt'
      writing manifest file 'regex.egg-info/SOURCES.txt'
      Copying regex.egg-info to build/bdist.macosx-14.1-arm64/wheel/regex-2023.10.3-py3.13.egg-info
      running install_scripts

      Traceback (most recent call last):
        File "/Users/skip/src/smontanaro.net/3.13/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/skip/src/smontanaro.net/3.13/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'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... [ most of traceback stack elided ] ...
        File "/private/var/folders/d6/rzq9g7qd7zn5pwbc3pj1sthc0000gn/T/pip-build-env-lmo7v2ko/overlay/lib/python3.13/site-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/private/var/folders/d6/rzq9g7qd7zn5pwbc3pj1sthc0000gn/T/pip-build-env-lmo7v2ko/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/d6/rzq9g7qd7zn5pwbc3pj1sthc0000gn/T/pip-build-env-lmo7v2ko/normal/lib/python3.13/site-packages/wheel/bdist_wheel.py", line 405, in run
          impl_tag, abi_tag, plat_tag = self.get_tag()
                                        ^^^^^^^^^^^^^^
        File "/private/var/folders/d6/rzq9g7qd7zn5pwbc3pj1sthc0000gn/T/pip-build-env-lmo7v2ko/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 ('cp313', 'cp313t', 'macosx_14_0_arm64')
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for regex
Failed to build regex
ERROR: Could not build wheels for regex, which is required to install pyproject.toml-based projects

Here’s what I’m running:

[(3.13) (python311a) ~/src/smontanaro.net% python
Python 3.13.0a2+ (heads/main:e0449b9a7f, Nov 29 2023, 10:11:15) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

I downloaded the module source and it built just fine with python setup.py build (after installing setuptools). pip and wheel are up-to-date. I uninstalled the existing regex (maybe only partially installed?), but attempts to reinstall failed with the same error. pip says “it’s not me.” If regex builds okay, but pip says the problem lies with a subprocess, where do I look for the culprit?

Isn’t Python v3.13 prerelease?

Try uninstalling your currently installed Python version(s) and installing v3.12 … the latest released stable version. Then try installing the re module. Sometimes as in electronic systems, you have to reboot.
I have the re module installed and it is working fine (I also have Python v3.12 installed).

Yes, my point is to test my project against the alpha version of 3.13.

Oh, ok.

My apologies.

I think I’ve seen something about this relating to platform tags for --disable-gil builds not being fully sorted out yet; is your 3.13 built with --disable-gil?

Unfortunately I don’t have any advice for getting around it, but hopefully this helps point in the right direction.

(Aside: this brings up the point that we should probably include any points relevant to packaging in sys.version (such as whether the GIL is disabled)).

Also, note that I’m explicitly using the regex module, not the builtin re module.

Ah, yes I am. Thanks for recalling that. Enabling the GIL solved the issue (though it fell back to a slightly older version of regex). I guess I’ll have to wait for the --disable-gil build for a bit longer.

1 Like