-
Notifications
You must be signed in to change notification settings - Fork 73
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
use python_DISTLIB #1023
use python_DISTLIB #1023
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In light of comment: #818 (comment), the use of FindPackage(Python)
at build time verses the discovery and setting of Python_SITELIB
at installation time - The reason for the decision to opt for the installation time choice was to more accurately reflect and support the use case where build machine and install machine could be different and the location on the installation machine is what is important here.
@@ -1,13 +1,11 @@ | |||
#!/bin/sh | |||
|
|||
set -e | |||
Python_SITELIB=$(python3 -c "from distutils import sysconfig;print(sysconfig.get_python_lib(plat_specific=False,standard_lib=False))") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of python 3.10 (in Ubuntu 22), distutils
is deprecated. It will be removed in 3.12. Additionall pain: distutils must be installed before use!
I'm not 100% certain this suggestion works in non Debian derived environments, but it works in my Debain Python 3.11 environment as well as a mostly vanilla Ubuntu 18 environment. Here is the documentation on Debian dist-packages.
Python_SITELIB=$(python3 -c "from distutils import sysconfig;print(sysconfig.get_python_lib(plat_specific=False,standard_lib=False))") | |
Python_SITELIB=$(python3 -c "import sysconfig; print(sysconfig.get_path('stdlib'))")/dist-packages |
If this is not the solution, we should find a better solution than distutils
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't get that to work in Ubuntu nor Debian
# ls $(python3 -c "import sysconfig; print(sysconfig.get_path('stdlib'))")/dist-packages
ls: cannot access '/usr/lib/python3.8/dist-packages': No such file or directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want platlib
# python3 -c "import sysconfig; print(sysconfig.get_path('platlib'))"
/usr/lib/python3.9/site-packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, it is implemented with python3 -c "import sysconfig; print(sysconfig.get_path('purelib'))"
as described in https://cmake.org/cmake/help/latest/module/FindPython3.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to that link, dist-packages seem to be the correct path. I wonder if we need to mkdir -p
to ensure it exists. @spoonincode This worked for me in Debian 11/12 and Ubuntu 18.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
purelib
seems to be the correct answer. :-) Approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we should be installing into site-packages
?
dist-packages instead of site-packages. Third party Python software installed from Debian packages goes into dist-packages, not site-packages. This is to reduce conflict between the system Python, and any from-source Python build you might install manually.
https://wiki.debian.org/Python
# Also may have already existed, so it is acceptable to leave them in place if the rmdir fails | ||
rmdir --ignore-fail-on-non-empty ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages | ||
rmdir --ignore-fail-on-non-empty ${CMAKE_INSTALL_FULL_LIBDIR}/python3 | ||
Python_SITELIB=$(python3 -c "from distutils import sysconfig;print(sysconfig.get_python_lib(plat_specific=False,standard_lib=False))") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue with distutils
as noted in scripts/postinst
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments: distutils
requires install and is deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
holding
When I try to install the package, I get
I'm not sure if we're expected to create |
It installs now but I don't think this location is searched by default...
Don't we want this installed in to the default module search path? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to look at how official Ubuntu and Debian packages set distlib.
scripts/prerm
Outdated
# Also may have already existed, so it is acceptable to leave them in place if the rmdir fails | ||
rmdir --ignore-fail-on-non-empty ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages | ||
rmdir --ignore-fail-on-non-empty ${CMAKE_INSTALL_FULL_LIBDIR}/python3 | ||
Python_DISTLIB=$(python3 -c "import sysconfig; print(sysconfig.get_path('purelib'))" | sed 's/site-packages/dist-packages/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't think this is the right answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Something feels wrong about the trouble we're having here and that's usually a reasonable indicator we're on the wrong path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is based on the description of https://wiki.debian.org/Python, first point of the section Deviations from upstream
. In debian/Ubuntu, using the deprecated distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)
does return the right answer /usr/lib/python3/dist-packages
while using sysconfig does not. Based on the StackOverflow post
The root cause of the discrepancy is because Debian patch the distutils install layout, to correctly reflect their changes to the site, but they fail to patch the sysconfig module.
I am not sure how to move forward from here. Here are the list of solutions I can think of (I am welcome any other solutions)
- just use
/usr/lib/python3/dist-packages
, - use distutils (at least it's still available in our supported distributions),
- keep the current implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my vote is to just use distutils and sort out the problem with python 3.12 + ubuntu when that actually arrives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As much as I dislike using distutils, it seems like the least painful solution.
.github/workflows/build.yaml
Outdated
export DEBIAN_FRONTEND=noninteractive | ||
export TZ="America/New_York" | ||
apt install -y ./build/leap_*.deb | ||
apt install -y ./build/leap-dev*.deb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to keep the workflow as concise and clutter free as possible, so two changes I'd like here:
- move the
DEBIAN_FRONTEND
andTZ
to the Dockerfile - combine the two installs, either as
./build/leap_*.deb ./build/leap-dev*.deb
or./build/leap*.deb
or whatever
.github/workflows/build.yaml
Outdated
@@ -103,12 +103,21 @@ jobs: | |||
zstdcat build.tar.zst | tar x | |||
cd build | |||
cpack | |||
- name: Install dev package | |||
run: | | |||
apt update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be update && upgrade
here? I'm not sure how problematic it will be on Ubuntu to have "mixed age" packages installed: the base image is cached and could have many month old packages installed alongside new packages installed here.
This PR
Resolves #839