You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Creating RPM on Python 2 works, but Python 3 fails because of sys.implementation.cache_tag #76235
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2021-02-03.18:19:21.949>created_at=<Date2017-11-16.22:07:02.207>labels= ['type-bug', 'library']
title='Creating RPM on Python 2 works, but Python 3 fails because of sys.implementation.cache_tag'updated_at=<Date2021-02-03.18:19:21.948>user='https://bugs.python.org/pgacv2'
Running python setup.py bdist_rpm with Python 2 works. However, running python3 setup.py bdist_rpm outputs the following:
running bdist_rpm
running egg_info
writing top-level names to MyApp.egg-info/top_level.txt
...
byte-compiling /home/pedro/MyApp/build/bdist.linux-x86_64/rpm/BUILDROOT/MyApp-1.2.3-1.x86_64/usr/lib/python3.4/site-packages/MyApp/my_file.py to my_file.cpython-34.pyc
...
Processing files: MyApp-1.2.3-1.noarch
error: File not found: /home/pedro/MyApp/build/bdist.linux-x86_64/rpm/BUILDROOT/MyApp-1.2.3-1.x86_64/usr/lib/python3.4/site-packages/MyApp/my_file.py
RPM build errors:
File not found: /home/pedro/MyApp/build/bdist.linux-x86_64/rpm/BUILDROOT/MyApp-1.2.3-1.x86_64/usr/lib/python3.4/site-packages/MyApp/my_file.py
error: command 'rpmbuild' failed with exit status 1
The problem appears to be that setuptools is generating a file that ends in .cpython-34.pyc, and later looks for a file without the .cpython-34 but can't find it.
The RPM generation process on Python 3 goes through distutils.util.byte_compile(), which in turn calls importlib.util.cache_from_source(path), where path is the file to be byte-compiled. cache_from_source() injects the value of sys.implementation.cache_tag (which is equal to 'cpython-34' on SLES12 SP2) into the filename of the compiled file. This attribute of sys does not exist in Python 2. So it looks like setuptools alters the filename with that tag during byte compilation, but later forgets that it modified the filename and fails because it's looking for the original name.
I ended up working around this by patching distutils.file_util.write_file to eliminate the .pyc entries from INSTALLED_FILES:
Distutils is now deprecated (see PEP-632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils.
If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
Activity
pgacv2 commentedon Nov 16, 2017
I am trying to create an RPM on SLES12 SP2. (I think that corresponds to OpenSUSE 42.2.) This is my setup.py file, nothing special:
Running
python setup.py bdist_rpmwith Python 2 works. However, runningpython3 setup.py bdist_rpmoutputs the following:The problem appears to be that setuptools is generating a file that ends in
.cpython-34.pyc, and later looks for a file without the.cpython-34but can't find it.The RPM generation process on Python 3 goes through
distutils.util.byte_compile(), which in turn callsimportlib.util.cache_from_source(path), wherepathis the file to be byte-compiled.cache_from_source()injects the value ofsys.implementation.cache_tag(which is equal to 'cpython-34' on SLES12 SP2) into the filename of the compiled file. This attribute ofsysdoes not exist in Python 2. So it looks likesetuptoolsalters the filename with that tag during byte compilation, but later forgets that it modified the filename and fails because it's looking for the original name.I ended up working around this by patching
distutils.file_util.write_fileto eliminate the .pyc entries from INSTALLED_FILES:But I don't think I should have to do anything special to build an RPM on Python 3 vs. Python 2. Is this expected behavior?
zooba commentedon Feb 3, 2021
Distutils is now deprecated (see PEP-632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils.
If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools