-
Notifications
You must be signed in to change notification settings - Fork 219
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
docker: Add ability to build shared library flavours of CPython #1185
base: main
Are you sure you want to change the base?
Conversation
If people are happy enough I will update the README/etc too. And could even expose it as a slightly less hidden top-level |
Can't use the vanilla manylinux images because CPython isn't built as shared. koordinates2/manylinux2014-pyshared images are a minor tweak. See pypa/manylinux#1185 for details. After that just install PyInstaller into the image before running. Manylinux2014-derived libraries use libxcrypt to provide libcrypt.so.2, but that doesn't seem to end up bundled. Do it manually. Probably goes away with a newer PyInstaller.
Can't use the vanilla manylinux images because CPython isn't built as shared. koordinates2/manylinux2014-pyshared images are a minor tweak. See pypa/manylinux#1185 for details. After that just install PyInstaller into the image before running. Manylinux2014-derived libraries use libxcrypt to provide libcrypt.so.2, but that doesn't seem to end up bundled. Do it manually. Probably goes away with a newer PyInstaller.
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.
looks good to me
232bd84
to
9850236
Compare
Enable via: PY_SHARED=1 \ PLATFORM=$(uname -m) POLICY=manylinux2014 COMMIT_SHA=latest \ ./build.sh If set, builds both static & shared versions of CPython into the images. Shared versions end up in (eg) /opt/python/cp37-cp37m-shared/ alongside the existing static /opt/python/cp37-cp37m/, with a Python binary as /usr/local/bin/python3.7-shared.
9850236
to
7b3e32a
Compare
I've done that in the latest push. |
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.
Thanks for taking the time to do this.
Before this can be merged, please do explain why you'd need a manylinux like image. The issues you mentioned provides another way to handle the PyInstaller/cx-freeze use-case with minimal effort. What use-case is not solved with a minimal "CentOS" (or other base image) image with python ?
I'd rather understand the added value for downstream repos before including bits of code that will never be tested here.
ABI_TAG=$(${PREFIX}/bin/python ${MY_DIR}/python-tag-abi-tag.py) | ||
ln -s ${PREFIX} /opt/python/${ABI_TAG} | ||
ln -s ${PREFIX} /opt/python/${ABI_TAG}${SUFFIX:-} |
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.
ln -s ${PREFIX} /opt/python/${ABI_TAG}${SUFFIX:-} | |
ln -s ${PREFIX} /opt/python/${ABI_TAG}${SUFFIX} |
To build and test PyInstaller/cx-freeze based executables for every supported python version.
No, the issues mentioned basically say - use whatever python provided by the base image or build your own. And manylinux project itself proves that it is not a minimal effort.
The use case is pretty obvious - base your work on top of well done manylinux project and avoid reinventing this wheel (properly build all supported python versions) over and over again.
The added value for downstream repos is ability to use properly built all supported python versions with up to date supporting libraries like openssl etc. for building/testing executables from python scripts. |
@termim, can you please explain the use-case (or better, provide a real reference for the use-case) of building an application/executable with every supported python version ? This is where I'm lost. If you're building an application, only one python version should be enough ? Not sure if it's been mentioned before but there's also https://github.com/indygreg/python-build-standalone/ python builds which are meant to be highly portable builds of python (manylinux just build without any care that the python builds themselves should be portable, only the built wheels are taken care of). |
Example: my application uses Python-3.8 and I build an executable with PyInstaller-4.8 currently. Obviously I plan to update to more recent Python, PyInstaller and a bunch of other packages my application uses. Obviously I have to test it as an executable on different Linux distros as well. Obviously I need to properly build Python for that. Currently I have to maintain myself these builds. Manylinux project does exactly that except one little option - build shared libpython. This option does not need to be on by default or there could be 'shared' flavor of x86_64 images - in any case that would help a lot to those who use PyInstaller/cx-Freeze. That would be very natural extension to manylinux project IMHO.
There is a lot of duplication in this project and manylinux. IMHO manylinux does better job by explicitly addressing different glibc versions and providing well defined policies and I do not see why python built with it should not be as portable as the wheels. |
👍 for /opt/python/cp39-cp39-shared. |
Python community is notoriously sloppy with how glibc dependencies are handled. |
Mwahahaha. We are not in the fantasy world with rainbows and unicorns. We live in the harsh reality where some library update may require a new python version. Now what? |
**Summary:** See pypa#1185 We propose to: * update the branch and "bake" the shared libraries build * remove old Python (<3.8) versions that we do not care * remove the GIL build
**Summary:** See pypa#1185 We propose to: * update the branch and "bake" the shared libraries build * remove old Python (<3.8) versions that we do not care * remove the GIL build * remove compression for static libs
Add a build option to enable building shared/libpython-enabled Python. Helps a number of use-cases (eg: #1149 #793 #255 #30). In mine, using PyInstaller for creating a works-on-many-linux distribution.
Obviously as described in some of the above tickets, it doesn't fit the manylinux requirements and shouldn't be on by default. But adding the option helps people reuse the huge work put into manylinux images without maintaining forks or redoing it all.
Enable via:
If set, builds both static & shared versions of CPython interpreters into the images.
Shared versions end up in (eg)
/opt/python/cp37-cp37m-shared/
alongside the existing static/opt/python/cp37-cp37m/
, with a Python binary as/usr/local/bin/python3.7-shared
.