Bug 1946972 - %{python3_sitelib} and %{python3_sitearch} use the deprecated distutils module
Summary: %{python3_sitelib} and %{python3_sitearch} use the deprecated distutils module
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-rpm-macros
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Karolina Surma
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1947468
TreeView+ depends on / blocked
 
Reported: 2021-04-07 12:00 UTC by Miro Hrončok
Modified: 2021-04-08 14:26 UTC (History)
6 users (show)

Fixed In Version: python-rpm-macros-3.9-37.fc35
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-04-08 14:26:21 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miro Hrončok 2021-04-07 12:00:54 UTC
Currently, we define the following macros:

%python3_sitelib %(%{__python3} -Ic "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
%python3_sitearch %(%{__python3} -Ic "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")

%python_sitelib %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
%python_sitearch %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")

But distutils is deprecated in Python 3.10: https://www.python.org/dev/peps/pep-0632/

We need to figure out how to get this data from somewhere else.

I've checked and sysconfig does not have get_python_lib(), but it has get_path(). This is a code that we can use:

>>> from sysconfig import get_path
>>> get_path('platlib') 
'/usr/lib64/python3.9/site-packages'
>>> get_path('purelib')
'/usr/lib/python3.9/site-packages'


It seems to work across variety of our Pythons:

$ for PYTHON in python{2.7,3.{5..10}} pypy2 pypy3; do echo $PYTHON; $PYTHON -c 'from __future__ import print_function; from distutils.sysconfig import get_python_lib; from sysconfig import get_path; print(get_path("platlib"), get_python_lib(1), get_path("platlib")==get_python_lib(1)); print(get_path("purelib"), get_python_lib(), get_path("purelib")==get_python_lib())'; echo; done
python2.7
/usr/lib64/python2.7/site-packages /usr/lib64/python2.7/site-packages True
/usr/lib/python2.7/site-packages /usr/lib/python2.7/site-packages True

python3.5
/usr/lib64/python3.5/site-packages /usr/lib64/python3.5/site-packages True
/usr/lib/python3.5/site-packages /usr/lib/python3.5/site-packages True

python3.6
/usr/lib64/python3.6/site-packages /usr/lib64/python3.6/site-packages True
/usr/lib/python3.6/site-packages /usr/lib/python3.6/site-packages True

python3.7
/usr/lib64/python3.7/site-packages /usr/lib64/python3.7/site-packages True
/usr/lib/python3.7/site-packages /usr/lib/python3.7/site-packages True

python3.8
/usr/lib64/python3.8/site-packages /usr/lib64/python3.8/site-packages True
/usr/lib/python3.8/site-packages /usr/lib/python3.8/site-packages True

python3.9
/usr/lib64/python3.9/site-packages /usr/lib64/python3.9/site-packages True
/usr/lib/python3.9/site-packages /usr/lib/python3.9/site-packages True

python3.10
/usr/lib64/python3.10/site-packages /usr/lib64/python3.10/site-packages True
/usr/lib/python3.10/site-packages /usr/lib/python3.10/site-packages True

pypy2
/usr/lib64/pypy-7.3/site-packages /usr/lib64/pypy-7.3/site-packages True
/usr/lib64/pypy-7.3/site-packages /usr/lib64/pypy-7.3/site-packages True

pypy3
/usr/lib64/pypy3-7.3/site-packages /usr/lib64/pypy3-7.3/site-packages True
/usr/lib64/pypy3-7.3/site-packages /usr/lib64/pypy3-7.3/site-packages True

Comment 2 Fedora Update System 2021-04-08 14:26:21 UTC
FEDORA-2021-afa6e07b4d has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.