Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use distutils to get Python library path #98

Conversation

vojtechtrefny
Copy link
Member

distutils is deprecated and will be removed in Python 3.12.
sysconfig module provides replacement for distutils.sysconfig.

@vojtechtrefny
Copy link
Member Author

And as expected, this doesn't work.

With Python 3.9:

>>> import sys
>>> sys.exec_prefix = "/home/brq/vtrefny/libbytesize/libbytesize-2.6/_inst/"
>>> import sysconfig
>>> sysconfig.get_path('platlib')
'/home/brq/vtrefny/libbytesize/libbytesize-2.6/_inst/lib64/python3.9/site-packages'

With Python 3.6:

>>> import sys
>>> sys.exec_prefix = "/home/brq/vtrefny/libbytesize/libbytesize-2.6/_inst/"
>>> import sysconfig
>>> sysconfig.get_path('platlib')
'/usr/lib64/python3.6/site-packages'

So back to the drawing board...

@vojtechtrefny vojtechtrefny marked this pull request as draft August 24, 2021 16:00
distutils is deprecated and will be removed in Python 3.12.
sysconfig module provides replacement for distutils.sysconfig.
@vojtechtrefny
Copy link
Member Author

Reading the code proved to be the best documentation once again. sysconfig.get_path('platlib', vars={'platbase': '${exec_prefix}'})) seems to be working everywhere.

@vojtechtrefny vojtechtrefny marked this pull request as ready for review August 24, 2021 16:31
Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@vojtechtrefny vojtechtrefny merged commit fba2f64 into storaged-project:master Aug 25, 2021
@mbiebl
Copy link

mbiebl commented Aug 29, 2022

Somehow this change broke the Debian build.

               libbytesize 2.7
             ====================

        prefix:                     /usr
        libdir:                     ${prefix}/lib/x86_64-linux-gnu
        libexecdir:                 ${exec_prefix}/libexec
        bindir:                     ${exec_prefix}/bin
        sbindir:                    ${exec_prefix}/sbin
        datadir:                    ${datarootdir}
        sysconfdir:                 /etc
        localstatedir:              /var
        docdir:                     ${datarootdir}/doc/${PACKAGE_TARNAME}

        compiler:                   gcc
        cflags:                     -g -O2 -ffile-prefix-map=/home/michael/debian/build-area/libbytesize-2.7=. -fstack-protector-strong -Wformat -Werror=format-security -DENABLE_NLS
        cppflags:                   -Wdate-time -D_FORTIFY_SOURCE=2
        ldflags:                    -Wl,-z,relro -Wl,-z,now

        Python 3 bindings:          yes
        tools:                      no
...

 /bin/mkdir -p '/home/michael/debian/build-area/libbytesize-2.7/debian/tmp/usr/local/lib/python3.10/dist-packages/bytesize'
 /usr/bin/install -c -m 644 bytesize.py __init__.py '/home/michael/debian/build-area/libbytesize-2.7/debian/tmp/usr/local/lib/python3.10/dist-packages/bytesize'

Notice how it installs the files in /usr/local despite using --prefix=/usr

Reverting this commit, I get:

<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
 /bin/mkdir -p '/home/michael/debian/build-area/libbytesize-2.7/debian/tmp/usr/lib/python3/dist-packages/bytesize'
 /usr/bin/install -c -m 644 bytesize.py __init__.py '/home/michael/debian/build-area/libbytesize-2.7/debian/tmp/usr/lib/python3/dist-packages/bytesize'

A few warnings but installed into the proper path

@mbiebl
Copy link

mbiebl commented Aug 29, 2022

Full build log attached:
build.log.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants