-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regex library depedency is causing installation problems #7676
Comments
Thanks for reporting. We need |
I would agree that if it works with pip, the standard, and not uv that maybe the problem is with uv. Regardless of uv being preferred by some. But maybe I don't have a full understanding of the real problem. |
should this work?
would that not be looking for a module "import regex"? I installed regex as described in a venv and running "import regex" at the Python prompt works fine. Material also seems to work fine, thought I only tried a toy project. edit: replaced the |
I use |
We don't need to make a decision right away, especially as it will take few days to figure out exactly what is causing this issue. Apparently is not uv fault. Now I suspect the way python is compiled/installed or the non standard packaging of regex wheel. -- I find it bit fascinating because it seems to be a recurring issue (first report ~5 years old), even black was affected by it psf/black#1207 but they sorted it by removing it. I don't publish anything in Chinese and I bet that people that do are less than 10-20% of mkdocs-material users. This would make it a good case for adding this as an |
If the exact problem could be quantified, a PR could be issued over at regex. I don't think anyone knows exactly what the issue is.... |
This is exactly the argument that is a non-argument. 10-20% is a lot, and yes, Material is very popular among Chinese users, since it is one of the few SSGs that supports Chinese search to a reasonable degree, albeit it's still not perfect. Chinese is the second most spoken language in the world, so there's quite a lot of users out there. We do not want to make it anymore complicated, and as I mentioned, it would mean a breaking change which we're currently not planning for. For this reason, we're currently not considering this change. I hope for your understanding. |
Hello @ssbarnea, I tested Windows 10 + Python 3.13 + venv + uv and it works for me. In the other link you gave this example: > uv pip install regex==2024.9.11
> python3 -c "import regex._regex as _regex"
ModuleNotFoundError: No module named 'regex._regex'
> uv pip uninstall regex
> pip install regex==2024.9.11
> python3 -c "import regex._regex as _regex"
success This gave me the idea that perhaps (test-uv) :~$ uv pip tree --verbose
DEBUG uv 0.4.30
DEBUG Searching for default Python interpreter in system path
DEBUG Found `cpython-3.11.9-linux-x86_64-musl` at `/home/frog/test-uv/bin/python3` (active virtual environment)
Using Python 3.11.9 environment at test-uv
mkdocs-material v9.5.44
# ... (test-uv) :~$ python3 -c "import sys; print(*sys.path, sep='\n'); print(sys.executable)"
/usr/lib/python311.zip
/usr/lib/python3.11
/usr/lib/python3.11/lib-dynload
/home/frog/test-uv/lib/python3.11/site-packages
/home/frog/test-uv/bin/python3 Make sure the paths match between commands and there is no weird path to another version. $ uv pip show regex
Location: /home/frog/test-uv/lib/python3.11/site-packages
$ python3 -m pip show regex
Location: /home/frog/test-uv/lib/python3.11/site-packages $ ls -la /home/frog/test-uv/lib/python3.11/site-packages/regex
total 2368
drwxr-sr-x 3 frog frog 4096 Nov 7 04:42 .
drwxr-sr-x 67 frog frog 4096 Nov 7 04:42 ..
-rw-r--r-- 2 frog frog 65 Nov 7 04:42 __init__.py
drwxr-sr-x 2 frog frog 4096 Nov 7 04:42 __pycache__
-rwxr-xr-x 2 frog frog 2003488 Nov 7 04:42 _regex.cpython-311-x86_64-linux-musl.so #Compiled regex._regex file unique for each OS variant
-rw-r--r-- 2 frog frog 141028 Nov 7 04:42 _regex_core.py
-rw-r--r-- 2 frog frog 32683 Nov 7 04:42 regex.py
-rw-r--r-- 2 frog frog 222040 Nov 7 04:42 test_regex.py I didn't read much of it but here I see version 3.9 at the start of the code block and the traceback errors paths are from python3.8 🤔 Very strange indeed 🔍 |
This was tracked down to be an issue with I had a hunch we were dealing with a mixed bag of issues and the error in the CI run confirmed it: File "/home/runner/work/tox-ansible/tox-ansible/.tox/docs/lib/python3.12/site-packages/material/plugins/search/plugin.py", line 24, in <module>
import regex as re
File "/home/runner/work/tox-ansible/tox-ansible/.tox/docs/lib/python3.12/site-packages/regex/__init__.py", line 1, in <module>
from .regex import *
File "/home/runner/work/tox-ansible/tox-ansible/.tox/docs/lib/python3.12/site-packages/regex/regex.py", line 417, in <module>
import regex._regex_core as _regex_core
File "/home/runner/work/tox-ansible/tox-ansible/.tox/docs/lib/python3.12/site-packages/regex/_regex_core.py", line 21, in <module>
import regex._regex as _regex
ModuleNotFoundError: No module named 'regex._regex' The regex module was found Crazy edge case shenanigans 🤯 |
Looks like Occam's razor turned out to be correct in this case. Problem installing package with uv? It's probably a problem with uv 🙂. |
Context
MacOS arm64 python 3.12 or newer using uv instead of pip to install dependencies.
I raised this bug on mkdocs-material in order to re-evaluate the need for keeping this a direct dependency. If we are not able to find an alternative, we should at least consider making it a soft-dependency as it would be much easier to not use the search plugin that not being able to use mkdocs-material.
Bug description
AFAIK, regex library is only used inside the search plugin but is listed as a permanent dependency. Apparently bugs like mrabarnett/mrab-regex#413 and mrabarnett/mrab-regex#547 show that this binary dependency is problematic as it causes installation failures for a notable number of users.
This dependency is not using PEP-517 packaging.
Related links
Reproduction
Steps to reproduce
Browser
No response
Before submitting
The text was updated successfully, but these errors were encountered: