From 1571f8ad647881191185cc28b0b166b125c7e988 Mon Sep 17 00:00:00 2001 From: adehad <26027314+adehad@users.noreply.github.com> Date: Tue, 9 Jan 2024 02:05:51 +0000 Subject: [PATCH] add `shared` config to build Python shared library --- src/python/devcontainer-feature.json | 5 +++++ src/python/install.sh | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/python/devcontainer-feature.json b/src/python/devcontainer-feature.json index 7ebdad38a..472f8d7c4 100644 --- a/src/python/devcontainer-feature.json +++ b/src/python/devcontainer-feature.json @@ -32,6 +32,11 @@ "default": false, "description": "Optimize Python for performance when compiled (slow)" }, + "shared": { + "type": "boolean", + "default": false, + "description": "Build Python with the shared library files." + }, "installPath": { "type": "string", "default": "/usr/local/python", diff --git a/src/python/install.sh b/src/python/install.sh index e6eefd055..bb157a74e 100755 --- a/src/python/install.sh +++ b/src/python/install.sh @@ -10,6 +10,7 @@ PYTHON_VERSION="${VERSION:-"latest"}" # 'system' or 'os-provided' checks the base image first, else installs 'latest' INSTALL_PYTHON_TOOLS="${INSTALLTOOLS:-"true"}" OPTIMIZE_BUILD_FROM_SOURCE="${OPTIMIZE:-"false"}" +SHARED_LIBS="${SHARED:-"false"}" PYTHON_INSTALL_PATH="${INSTALLPATH:-"/usr/local/python"}" OVERRIDE_DEFAULT_VERSION="${OVERRIDEDEFAULTVERSION:-"true"}" @@ -264,7 +265,11 @@ install_from_source() { if [ "${OPTIMIZE_BUILD_FROM_SOURCE}" = "true" ]; then config_args="--enable-optimizations" fi - ./configure --prefix="${INSTALL_PATH}" --with-ensurepip=install ${config_args} + local shared_libs="" + if [ "${SHARED_LIBS}" = "true" ]; then + shared_libs="--enable-shared" + fi + ./configure --prefix="${INSTALL_PATH}" --with-ensurepip=install ${config_args} ${shared_libs} make -j 8 make install cd /tmp