Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 912734 - dev-python/meson-python: missing a dependency on dev-python/colorama? (AttributeError: module 'colorama' has no attribute 'init' when building dev-python/numpy)
Summary: dev-python/meson-python: missing a dependency on dev-python/colorama? (Attrib...
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-21 12:12 UTC by Markus Walter
Modified: 2023-08-27 08:09 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build log (numpy-1.25.2:20230821-115928.log,5.13 KB, text/x-log)
2023-08-21 12:12 UTC, Markus Walter
Details
emerge --info (emerge--info.txt,10.85 KB, text/plain)
2023-08-21 12:12 UTC, Markus Walter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Walter 2023-08-21 12:12:21 UTC
Created attachment 868311 [details]
build log

It fails with the following exception:

gpep517 build-wheel --backend mesonpy --output-fd 3 --wheel-dir /var/tmp/portage/dev-python/numpy-1.25.2/work/numpy-1.25.2-python3_10/wheel --config-json {"builddir": "/var/tmp/portage/dev-python/numpy-1.25.2/work/numpy-1.25.2-python3_10", "setup-args": ["-Dblas=cblas", "-Dlapack=lapack"], "compile-args": ["-v", "-j16", "-l0"]}
2023-08-21 13:59:30,731 gpep517 INFO Building wheel via backend mesonpy
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.10/gpep517", line 4, in <module>
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/gpep517/__main__.py", line 406, in main
    return func(args)
  File "/usr/lib/python3.10/site-packages/gpep517/__main__.py", line 202, in build_wheel
    print(build_wheel_impl(args, args.wheel_dir), file=out)
  File "/usr/lib/python3.10/site-packages/gpep517/__main__.py", line 194, in build_wheel_impl
    wheel_name = backend.build_wheel(str(wheel_dir), args.config_json)
  File "/usr/lib/python3.10/site-packages/mesonpy/__init__.py", line 1047, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/mesonpy/__init__.py", line 1108, in build_wheel
    _setup_cli()
  File "/usr/lib/python3.10/site-packages/mesonpy/__init__.py", line 203, in _setup_cli
    colorama.init()  # fix colors on windows
AttributeError: module 'colorama' has no attribute 'init'
Comment 1 Markus Walter 2023-08-21 12:12:42 UTC
Created attachment 868312 [details]
emerge --info
Comment 3 Eli Schwartz 2023-08-21 12:45:49 UTC
I don't think there's a true disagreement here. meson-python uses it if it's available, and insists via pyproject.toml that it should be available on Windows. An argument could be made that it should be an optional "extra" but I don't see what advantage that would bring.

The issue here is that you do have colorama installed, it just doesn't have the function that meson-python tries to use. Adding a dependency would do nothing since the problem is that it's there but broken.
Comment 4 Markus Walter 2023-08-21 13:10:11 UTC
(In reply to Eli Schwartz from comment #3)
> The issue here is that you do have colorama installed, it just doesn't have
> the function that meson-python tries to use. Adding a dependency would do
> nothing since the problem is that it's there but broken.

I think the point is that numpy has PYTHON_TARGETS python3_10 and python3_11 on my machine whereas colorama has only python3_11 and not python3_10. A dependency with use_dep could fix this.
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-08-21 13:11:32 UTC
That doesn't explain why it could import it though. the else clause only gets run if no exception occurred
Comment 6 Markus Walter 2023-08-21 13:38:50 UTC
(In reply to Sam James from comment #5)
> That doesn't explain why it could import it though. the else clause only
> gets run if no exception occurred

Fair question. I did some digging and indeed in Python 3.10 I can `import colorama` but it's an empty module. Looking further I found the folder /usr/lib/python3.10/site-packages/colorama which is empty except for a __pycache__ directory, that contains the following files:
__init__.cpython-311.pyc  ansi.cpython-311.pyc  ansitowin32.cpython-311.pyc  initialise.cpython-311.pyc  win32.cpython-311.pyc  winterm.cpython-311.pyc
__init__.cpython-39.pyc   ansi.cpython-39.pyc   ansitowin32.cpython-39.pyc   initialise.cpython-39.pyc   win32.cpython-39.pyc   winterm.cpython-39.pyc

So to me it looks like at some point there was some version confusion on my system and this is a problem on my side. However I'm not aware of having done something strange to colorama so I'm quizzed as to what the culprit is here. I tried `equery belongs` on these files, but no luck.
Comment 7 Markus Walter 2023-08-21 19:32:56 UTC
If there are no enlightening ideas I'm going to close this in a few days as a fluke on my system.
Comment 8 Markus Walter 2023-08-27 08:09:20 UTC
It seems that this was some local fluke. The problem vanished after I removed the mostly empty colorama directory. Closing.