Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 911128

Summary: dev-python/charset-normalizer missing md__mypyc module
Product: Gentoo Linux Reporter: Mark <mark.morschhaeuser>
Component: Current packagesAssignee: Python Gentoo Team <python>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Mark 2023-07-24 11:01:16 UTC
I have a python script that uses charset_normalizer by using the following code:

from charset_normalizer import md__mypyc

I installed mypy and charset_initializer but when I execute the script I get the message 

[...]
    from charset_normalizer import md__mypyc
ImportError: cannot import name 'md__mypyc' from 'charset_normalizer' (/usr/lib/python3.11/site-packages/charset_normalizer/__init__.py)

I downloaded the sources from charset_normalizer and found the following in setup.py:

USE_MYPYC = False

if len(sys.argv) > 1 and sys.argv[1] == "--use-mypyc":
    sys.argv.pop(1)
    USE_MYPYC = True
if os.getenv("CHARSET_NORMALIZER_USE_MYPYC", None) == "1":
    USE_MYPYC = True

if USE_MYPYC:
    from mypyc.build import mypycify

    MYPYC_MODULES = mypycify([
        "charset_normalizer/md.py"
    ])
else:
    MYPYC_MODULES = None

setup(
    name="charset-normalizer",
    version=get_version(),
    ext_modules=MYPYC_MODULES
)

So whatever it does, the mypyc module seems to be disabled by default unless --use-mypyc is provided to build that module. Would it be possible to detect mypyc or add a USE-flag to dev-python/charset-normalizer?