Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 736122 - dev-python/matplotlib-3.3.0 - ImportError: dynamic module does not define module export function (PyInit_ft2font)
Summary: dev-python/matplotlib-3.3.0 - ImportError: dynamic module does not define mod...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Science Related Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-06 10:36 UTC by jon R-B
Modified: 2021-01-04 09:45 UTC (History)
3 users (show)

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


Attachments
a (dev-python:matplotlib-3.3.3:20210103-124106.log,284.39 KB, text/x-log)
2021-01-03 16:49 UTC, jon R-B
Details
b (dev-python:matplotlib-3.3.3:20210103-123758.log,265.52 KB, text/x-log)
2021-01-03 16:49 UTC, jon R-B
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jon R-B 2020-08-06 10:36:25 UTC
the recent updated matplotlib fails to import: 

python
Python 3.7.8 (default, Aug  5 2020, 19:42:11) 
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/matplotlib/__init__.py", line 174, in <module>
    _check_versions()
  File "/usr/lib/python3.7/site-packages/matplotlib/__init__.py", line 159, in _check_versions
    from . import ft2font
ImportError: dynamic module does not define module export function (PyInit_ft2font)



Reproducible: Always

Steps to Reproduce:
1. start python prompt
2. import matplotlib
3.
Comment 1 jon R-B 2020-12-26 01:36:14 UTC
This is still an issue:

Python 3.8.7 (default, Dec 22 2020, 17:30:32) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/matplotlib/__init__.py", line 174, in <module>
    _check_versions()
  File "/usr/lib/python3.8/site-packages/matplotlib/__init__.py", line 159, in _check_versions
    from . import ft2font
ImportError: dynamic module does not define module export function (PyInit_ft2font)




[ebuild   R    ] dev-python/matplotlib-3.3.3::gentoo  USE="cairo examples qt5 tk (-doc) -excel -gtk3 -latex -test -webagg -wxwidgets" PYTHON_TARGETS="python3_8 -python3_6 -python3_7 -python3_9" 0 KiB



emerge --info
Portage 3.0.12 (python 3.8.7-final-0, default/linux/amd64/17.1/desktop, gcc-10.2.0, glibc-2.32-r6, 5.9.11-gentoo x86_64)
=================================================================
System uname: Linux-5.9.11-gentoo-x86_64-AMD_Ryzen_5_1600_Six-Core_Processor-with-glibc2.2.5
KiB Mem:    32900244 total,  14810048 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 24 Dec 2020 10:35:11 +0000
Head commit of repository gentoo: 77639b299adbd3650f515d63bc211e7b1150e25b

sh bash 5.1_p4
ld GNU gold (Gentoo 2.35.1 p2 2.35.1) 1.16
app-shells/bash:          5.1_p4::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.30.3-r1::gentoo
dev-lang/python:          3.7.9-r1::gentoo, 3.8.7::gentoo, 3.9.1::gentoo, 3.10.0_alpha3::gentoo
dev-util/cmake:           3.19.2::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.7-r1::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.3-r1::gentoo
sys-devel/binutils:       2.35.1-r1::gentoo
sys-devel/gcc:            10.2.0-r3::gentoo
sys-devel/gcc-config:     2.3.2-r1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.32-r6::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://anongit.gentoo.org/git/repo/sync/gentoo.git
    priority: -1000
    sync-git-verify-commit-signature: true

local
    location: /var/db/repos/local
    masters: gentoo

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -fomit-frame-pointer -march=native -fno-lto -mindirect-branch=thunk -ftree-vectorize -ftree-slp-vectorize"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -fomit-frame-pointer -march=native -fno-lto -mindirect-branch=thunk -ftree-vectorize -ftree-slp-vectorize"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=5 --load-average=5.0 --with-bdeps y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync metadata-transfer multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirror.bytemark.co.uk/gentoo/ http://www.mirrorservice.org/sites/distfiles.gentoo.org/"
LANG="en_GB.utf8"
LDFLAGS="-Wl,--as-needed -Wl,--hash-style=gnu"
LINGUAS="en en_GB uk"
MAKEOPTS="-j6 -l6"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi aiglx alsa amd64 bash-completion berkdb binddist branding bzip2 cairo cblas-external cdda cdr cleartype cli corefonts crypt dri dts emboss encode eselect-ldso evdev exif ffmpeg flac fortran gcc64 gdbm gegl gif gpm graphite gstreamer gtk gui iconv icu imlib introspection ipv6 java jpeg lcms libglvnd libnotify libtirpc lto mad mng mp3 mp4 mpeg multilib ncurses nls nptl nptlonly nsplugin ogg opengl openmp oss pam pango pcre pdf pgo png ppds pulseaudio python qt4 qt5 readline samba sdl seccomp smbclient spell split-usr ssl startup-notification svg tcpd threads tiff truetype type1 udev udisks unicode upower usb vorbis webkit wxwidgets x264 xattr xcb xml xulrunner xv xvid zlib" ABI_X86="64 32" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="f16c mmx mmxext popcnt sse sse2 sse3 sse4a ssse" CURL_SSL="gnutls" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64 efi-32" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" L10N="en en-GB" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_8" PYTHON_TARGETS="python2_7 python3_8" RUBY_TARGETS="ruby25 ruby27" USERLAND="GNU" VIDEO_CARDS="nvidia vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-01-02 16:44:24 UTC
...and I still can't reproduce.  Attach the build log for a start.
Comment 3 jon R-B 2021-01-02 19:07:30 UTC
ok the issue is associated with the -fno-lto CFLAGS

if you build with that the fault is created.
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-01-02 23:20:09 UTC
(In reply to jon R-B from comment #3)
> ok the issue is associated with the -fno-lto CFLAGS
> 
> if you build with that the fault is created.

Build.log please.
Comment 5 jon R-B 2021-01-03 12:46:13 UTC
TEST 1: 
CFLAGS="-O2 -pipe -fomit-frame-pointer -march=native" 


emerge matplotlib
Calculating dependencies... done!
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) dev-python/matplotlib-3.3.3::gentoo
>>> Installing (1 of 1) dev-python/matplotlib-3.3.3::gentoo
>>> Jobs: 1 of 1 complete                           Load avg: 0.93, 0.65, 0.92
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.

!!! existing preserved libs:
>>> package: dev-libs/boost-1.75.0
 *  - /usr/lib64/libboost_thread.so.1.74.0
 *      used by /usr/bin/povray (media-gfx/povray-3.7.0.0-r1)
>>> package: sci-libs/netcdf-4.7.4
 *  - /usr/lib64/libnetcdf.so.13
 *  - /usr/lib64/libnetcdf.so.13.1.1
 *      used by /usr/lib64/libexodus.so (sci-libs/exodusii-6.09)
 *      used by /usr/lib64/libvtkIOMINC.so.1 (sci-libs/vtk-8.2.0-r1)
 *      used by /usr/lib64/libvtkIONetCDF.so.1 (sci-libs/vtk-8.2.0-r1)
 *      used by 2 other files
Use emerge @preserved-rebuild to rebuild packages using these libraries
fluidmotion ~ # python
Python 3.8.7 (default, Dec 22 2020, 17:30:32)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>



BUILD LOG: dev-python:matplotlib-3.3.3:20210103-123758.log

---------------------------------------------------------------------------

TEST 2: 
CFLAGS="-O2 -pipe -fomit-frame-pointer -march=native -fno-lto" 

emerge matplotlib
Calculating dependencies... done!
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) dev-python/matplotlib-3.3.3::gentoo
>>> Installing (1 of 1) dev-python/matplotlib-3.3.3::gentoo
>>> Jobs: 1 of 1 complete                           Load avg: 0.73, 0.57, 0.84
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.

!!! existing preserved libs:
>>> package: dev-libs/boost-1.75.0
 *  - /usr/lib64/libboost_thread.so.1.74.0
 *      used by /usr/bin/povray (media-gfx/povray-3.7.0.0-r1)
>>> package: sci-libs/netcdf-4.7.4
 *  - /usr/lib64/libnetcdf.so.13
 *  - /usr/lib64/libnetcdf.so.13.1.1
 *      used by /usr/lib64/libexodus.so (sci-libs/exodusii-6.09)
 *      used by /usr/lib64/libvtkIOMINC.so.1 (sci-libs/vtk-8.2.0-r1)
 *      used by /usr/lib64/libvtkIONetCDF.so.1 (sci-libs/vtk-8.2.0-r1)
 *      used by 2 other files
Use emerge @preserved-rebuild to rebuild packages using these libraries
fluidmotion /var/log/portage # python
Python 3.8.7 (default, Dec 22 2020, 17:30:32)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/matplotlib/__init__.py", line 174, in <module>
    _check_versions()
  File "/usr/lib/python3.8/site-packages/matplotlib/__init__.py", line 159, in _check_versions
    from . import ft2font
ImportError: dynamic module does not define module export function (PyInit_ft2font)
>>>

BUILD LOG:dev-python:matplotlib-3.3.3:20210103-124106.log



Difference:
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/checkdep_freetype2.o: plugin needed to handle lto object
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/checkdep_freetype2.o: plugin needed to handle lto object
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/ft2font.o: plugin needed to handle lto object
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/ft2font.o: plugin needed to handle lto object
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/ft2font_wrapper.o: plugin needed to handle lto object
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/ft2font_wrapper.o: plugin needed to handle lto object
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/mplutils.o: plugin needed to handle lto object
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/mplutils.o: plugin needed to handle lto object
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/py_converters.o: plugin needed to handle lto object
/var/tmp/portage/dev-python/matplotlib-3.3.3/work/matplotlib-3.3.3-python3_8/build/temp.linux-x86_64-3.8/src/py_converters.o: plugin needed to handle lto object
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/crtendS.o: plugin needed to handle lto object


Matplotlib explicitly expects LTO and thus disabling it cause aspects to fail. Recommend filtering such CFLAG as user may set it (like I did) while testing LTO system wide and then disable
Comment 6 jon R-B 2021-01-03 12:48:04 UTC
Unable to attack logs... CGI is down
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-01-03 13:36:57 UTC
(In reply to jon R-B from comment #6)
> Unable to attack logs... CGI is down

Read the big message you're supposed to read before attaching files.
Comment 8 jon R-B 2021-01-03 16:49:22 UTC
Created attachment 680917 [details]
a
Comment 9 jon R-B 2021-01-03 16:49:51 UTC
Created attachment 680920 [details]
b
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-01-04 00:31:36 UTC
Right, so we need to:
1) filter -fno-lto, apparently (please use package.env anyway for LTO stuff)
2) possibly expose or just set enable_lto when building matplotlib (https://github.com/matplotlib/matplotlib/blob/7303d81eb2390208d3bac67dd51d390b585e411f/setup.cfg.template#L8)
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-01-04 09:07:54 UTC
I guess the underlying problem is that the package tries to force -flto.  I'm going to try patching that out.
Comment 12 Larry the Git Cow gentoo-dev 2021-01-04 09:45:50 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=96de8f81d7b7ff64bf39798f8790913e2759080f

commit 96de8f81d7b7ff64bf39798f8790913e2759080f
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2021-01-04 09:08:22 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2021-01-04 09:45:45 +0000

    dev-python/matplotlib: Remove -flto
    
    Closes: https://bugs.gentoo.org/736122
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 .../files/matplotlib-3.3.3-disable-lto.patch       | 25 ++++++++++++++++++++++
 ...lib-3.3.3.ebuild => matplotlib-3.3.3-r1.ebuild} |  1 +
 2 files changed, 26 insertions(+)