Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 735620 - dev-python/markupsafe et al: bad magic number in setuptools
Summary: dev-python/markupsafe et al: bad magic number in setuptools
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-02 21:27 UTC by Eric Westbrook
Modified: 2022-01-01 22:57 UTC (History)
2 users (show)

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


Attachments
Build log (markupsafe-build-log.txt,3.28 KB, text/plain)
2020-08-02 21:29 UTC, Eric Westbrook
Details
emerge --info (markupsafe-emerge-info.txt,6.20 KB, text/plain)
2020-08-02 21:29 UTC, Eric Westbrook
Details
emerge -pqv (markupsafe-emerge-pqv.txt,140 bytes, text/plain)
2020-08-02 21:30 UTC, Eric Westbrook
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Westbrook 2020-08-02 21:27:45 UTC
Emerge of a few python packages fails with e.g. the following:

   ImportError: bad magic number in 'setuptools': b'\x03\xf3\r\n'

Packages currently exhibiting this for me include:

   dev-python/markupsafe
   dev-python/cffi
   dev-python/bcrypt
   dev-python/cryptography


Reproducible: Always

Steps to Reproduce:
1. emerge -tv1 dev-python/markupsafe

Actual Results:  
 * python3_7: running distutils-r1_run_phase distutils-r1_python_compile
python3.7 setup.py build -j 5
Traceback (most recent call last):
  File "setup.py", line 172, in <module>
    from setuptools import setup, Distribution, Extension
ImportError: bad magic number in 'setuptools': b'\x03\xf3\r\n'


Expected Results:  
Expected a successful emerge.
Comment 1 Eric Westbrook 2020-08-02 21:29:10 UTC
Created attachment 652440 [details]
Build log
Comment 2 Eric Westbrook 2020-08-02 21:29:39 UTC
Created attachment 652442 [details]
emerge --info
Comment 3 Eric Westbrook 2020-08-02 21:30:09 UTC
Created attachment 652444 [details]
emerge -pqv
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-08-03 21:38:36 UTC
It seems likely to me your setuptools is corrupt. What happens if you re-emerge (with -1) it?

I would also be worried about other files being corrupt.
Comment 5 Eric Westbrook 2020-08-04 08:00:41 UTC
That occurred to me too.  Unfortunately re-emerging setuptools was not curative.  In fact, re-emerging python as well as all other installed python modules did not help.

Since this does not occur on another very similarly configured system, I too suspect corruption somewhere, but I have no idea where or how to correct it.
Comment 6 Eric Westbrook 2020-08-05 17:42:32 UTC
Turns out that the packages in question had been emerged with FEATURES="buildpkg".

Removing the existing binary package tarballs from the packages directory allowed the emerge to succeed.

I now wonder whether the binary packages that were previously built should have been deemed a system match.  Seems to me that they shouldn't have, but it's unclear to me how portage could determine that.
Comment 7 Eric Westbrook 2022-01-01 22:57:43 UTC
The root cause of this ended up being a misguided PYTHONPATH setting in root's .bashrc which wrongly put an old python library directory at the front of the list.  Upon removing that footgun, all proceeds well.