forked from openstack/diskimage-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Add python-stow-versions element"
- Loading branch information
Showing
11 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
==================== | ||
python-stow-versions | ||
==================== | ||
|
||
Element that installs latest minor releases of python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package-installs | ||
source-repositories |
38 changes: 38 additions & 0 deletions
38
diskimage_builder/elements/python-stow-versions/install.d/70-python-build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
if [ ${DIB_DEBUG_TRACE:-0} -gt 1 ]; then | ||
set -x | ||
fi | ||
set -eu | ||
set -o pipefail | ||
|
||
#Install python-build | ||
/pyenv/plugins/python-build/install.sh | ||
|
||
DIB_PYTHON_VERSIONS=${DIB_PYTHON_VERSIONS:-"2.7,3.5,3.6,3.7,3.8,3.9"} | ||
DIB_VERSIONS_TO_INSTALL=${1:-$DIB_PYTHON_VERSIONS} | ||
|
||
# Get pyenv versions | ||
DIB_PYENV_VERSIONS=$(python-build --definitions \ | ||
| egrep "^\s*[2,3]\.[0-9]{1,2}\.[0-9]{1,2}$") | ||
|
||
declare -A DIB_PYTHON_VERSIONS_ARRAY | ||
|
||
for version in ${DIB_PYENV_VERSIONS}; do | ||
DIB_PYTHON_VERSIONS_ARRAY[${version%.*}]+="${version##*.} " | ||
done | ||
|
||
if [ -n $DIB_VERSIONS_TO_INSTALL ]; then | ||
readarray -t DIB_VERSIONS_ARRAY <<<\ | ||
"$(echo "$DIB_VERSIONS_TO_INSTALL" | tr ',' '\n')" | ||
fi | ||
for key in ${!DIB_PYTHON_VERSIONS_ARRAY[@]}; do | ||
if ([ -n $DIB_VERSIONS_ARRAY ] && \ | ||
[[ " ${DIB_VERSIONS_ARRAY[@]} " =~ " ${key} " ]]) || \ | ||
[ -z ${DIB_VERSIONS_ARRAY} ]; then | ||
DIB_LAST_VERSION=${key}.$(echo "${DIB_PYTHON_VERSIONS_ARRAY[${key}]}" \ | ||
| sed "s/ /\n/g" | sort -nr | head -n1) | ||
python-build ${DIB_LAST_VERSION} /usr/local/stow/python-${DIB_LAST_VERSION} | ||
fi | ||
done |
18 changes: 18 additions & 0 deletions
18
diskimage_builder/elements/python-stow-versions/package-installs.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
bzip-dev: | ||
build-only: True | ||
curl: | ||
gcc: | ||
build-only: True | ||
git: | ||
build-only: True | ||
make: | ||
build-only: True | ||
readline-dev: | ||
build-only: True | ||
ssl-dev: | ||
build-only: True | ||
stow: | ||
sqlite-dev: | ||
build-only: True | ||
zlib-dev: | ||
build-only: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"family": { | ||
"debian": { | ||
"bzip-dev": "libbz2-dev", | ||
"curl": "curl", | ||
"gcc": "gcc", | ||
"git": "git", | ||
"make": "make", | ||
"readline-dev": "libreadline-dev", | ||
"ssl-dev": "libssl-dev", | ||
"stow": "stow", | ||
"sqlite-dev": "libsqlite3-dev", | ||
"zlib-dev": "zlib1g-dev" | ||
}, | ||
"redhat": { | ||
"bzip-dev": "bzip2-devel", | ||
"curl": "curl", | ||
"gcc": "gcc", | ||
"git": "git", | ||
"make": "make", | ||
"readline-dev": "readline-devel", | ||
"ssl-dev": "openssl-devel", | ||
"stow": "stow", | ||
"sqlite-dev": "sqlite-devel", | ||
"zlib-dev": "zlib-devel" | ||
}, | ||
"suse": { | ||
"bzip-dev": "libbz2-devel", | ||
"curl": "curl", | ||
"gcc": "gcc", | ||
"git": "git", | ||
"make": "make", | ||
"readline-dev": "readline-devel", | ||
"ssl-dev": "openssl-devel", | ||
"stow": "stow", | ||
"sqlite-dev": "sqlite3-devel", | ||
"zlib-dev": "zlib-devel" | ||
} | ||
}, | ||
"default": { | ||
"bzip-dev": "", | ||
"curl": "curl", | ||
"gcc": "gcc", | ||
"git": "git", | ||
"make": "make", | ||
"readline-dev": "", | ||
"ssl-dev": "", | ||
"sqlite-dev": "", | ||
"zlib-dev": "" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
diskimage_builder/elements/python-stow-versions/post-install.d/70-python-build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
if [ ${DIB_DEBUG_TRACE:-0} -gt 1 ]; then | ||
set -x | ||
fi | ||
set -eu | ||
set -o pipefail | ||
|
||
DIB_PYTHON_FILES=('/usr/local/bin/pyenv-install', \ | ||
'/usr/localbin/pyenv-uninstall', '/usr/local/bin/python-build', \ | ||
'/usr/local/share/python-build', '/pyenv') | ||
|
||
for path in ${DIB_PYTHON_FILES}; do | ||
rm -rf ${DIB_PYTHON_PREFIX}/${path} | ||
done |
1 change: 1 addition & 0 deletions
1
diskimage_builder/elements/python-stow-versions/source-repository-pyenv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pyenv git /pyenv/ https://github.com/pyenv/pyenv |
4 changes: 4 additions & 0 deletions
4
diskimage_builder/elements/python-stow-versions/test-elements/test-python-stow/element-deps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package-installs | ||
python-stow-versions | ||
source-repositories | ||
ubuntu-minimal |
1 change: 1 addition & 0 deletions
1
...ython-stow-versions/test-elements/test-python-stow/environment.d/70-test-python-stow.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export DIB_PYTHON_SUPPORTED_VERSIONS=3.8 |
13 changes: 13 additions & 0 deletions
13
...lements/python-stow-versions/test-elements/test-python-stow/install.d/69-test-python-stow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then | ||
set -x | ||
fi | ||
set -eux | ||
set -o pipefail | ||
|
||
[ -f "/pyenv/plugins/python-build/install.sh" ] | ||
[ -d "/usr/local/stow" ] | ||
|
||
# dib-lint: disable=which | ||
which stow |
27 changes: 27 additions & 0 deletions
27
...lements/python-stow-versions/test-elements/test-python-stow/install.d/71-test-python-stow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then | ||
set -x | ||
fi | ||
set -eux | ||
set -o pipefail | ||
|
||
DIB_STOW_PATH="/usr/local/stow" | ||
|
||
DIB_PY_BUILD_COUNTER=0 | ||
|
||
for pybuilds in $(ls -1 ${DIB_STOW_PATH} | grep "python-"); do | ||
DIB_PY_BUILD_COUNTER=$((DIB_PY_BUILD_COUNTER+1)) | ||
py_dir_version=$(echo ${pybuilds} | cut -d "-" -f 2) | ||
py_real_version=$(\ | ||
${DIB_STOW_PATH}/${pybuilds}/bin/python --version | cut -d " " -f 2) | ||
[[ ${py_real_version} == ${py_dir_version} ]] | ||
pushd ${DIB_STOW_PATH} | ||
stow ${pybuilds} | ||
popd | ||
py_stow_version=$(\ | ||
/usr/local/bin/python${py_dir_version%.*} --version | cut -d " " -f 2) | ||
[[ ${py_stow_version} == ${py_dir_version} ]] | ||
done | ||
|
||
[ $DIB_PY_BUILD_COUNTER -eq 1 ] |