Skip to content

Commit

Permalink
ASP-3288 Add a custom Python 3.8 installation
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimesouza committed Dec 8, 2023
1 parent 87dd887 commit a6b269c
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 145 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This file keeps track of all notable changes to the Slurm Charms.
Unreleased
----------

- added a custom python installation to run the charm code

1.1.2 - 2023-09-07
------------------

Expand Down
3 changes: 0 additions & 3 deletions charm-slurmctld/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ bases:
- name: centos
channel: "7"
architectures: [amd64]
- name: centos
channel: "8"
architectures: [amd64]
parts:
charm:
build-packages: [git]
Expand Down
70 changes: 38 additions & 32 deletions charm-slurmctld/dispatch
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
#!/bin/bash
# This hook installs the centos dependencies needed to run the charm,
# This hook installs the dependencies needed to run the charm,
# creates the dispatch executable, regenerates the symlinks for start and
# upgrade-charm, and kicks off the operator framework.

set -e

# Source the os-release information into the env.
# Source the os-release information into the env
. /etc/os-release

if ! [[ -f '.installed' ]]
then
# Determine if we are running in centos or ubuntu, if centos
# provision the needed prereqs.
if [[ $ID == 'ubuntu' ]]
then
echo "Running Ubuntu."
echo "Nothing to do."
elif [[ $ID == 'centos' ]]
then
# Determine the centos version and install prereqs accordingly
major=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f1)
echo "Running CentOS$major, installing prereqs."
if [[ $major == "7" ]]
then
yum -y install epel-release
yum -y install yum-priorities python3
elif [[ $major == "8" ]]
then
dnf -y install epel-release
dnf -y install yum-priorities python3
else
echo "Running unsuppored version of centos: $major"
exit -1
fi
elif [[ $ID == 'rocky' ]]

# Rocky specific setup
if [[ $ID == 'rocky' ]]
then
dnf install epel-release -y
dnf install dnf-plugins-core -y
dnf config-manager --set-enabled powertools -y
dnf install make automake yum-utils -y
else
echo "Running unsuppored os: $ID"
exit -1
fi
fi

if [[ $ID == 'centos' || $ID == 'rocky' ]]
then
# Install dependencies
yum -y install epel-release
yum -y install yum-priorities python3 automake yum-utils

# Install dependencies and build custom python
yum -y install wget gcc make tar bzip2-devel zlib-devel xz-devel openssl-devel libffi-devel sqlite-devel ncurses-devel

export PYTHON_VERSION=3.8.16
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz -P /tmp
tar xvf /tmp/Python-${PYTHON_VERSION}.tar.xz -C /tmp
cd /tmp/Python-${PYTHON_VERSION}
./configure --prefix=/opt/python/python3.8 --enable-optimizations
make -C /tmp/Python-${PYTHON_VERSION} -j $(nproc) altinstall
cd $OLDPWD
rm -rf /tmp/Python*

# set the correct python bin path
PYTHON_BIN="/opt/python/python3.8/bin/python3.8"
elif [[ $ID == 'ubuntu' ]]
then
# Necessary to compile and install NHC
apt-get install --assume-yes make

# set the correct python bin path
PYTHON_BIN="/usr/bin/env python3"
fi

touch .installed
fi

JUJU_DISPATCH_PATH="${JUJU_DISPATCH_PATH:-$0}" PYTHONPATH=lib:venv ./src/charm.py

JUJU_DISPATCH_PATH="${JUJU_DISPATCH_PATH:-$0}" PYTHONPATH=lib:venv $PYTHON_BIN ./src/charm.py
4 changes: 2 additions & 2 deletions charm-slurmctld/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ops==1.3.0
ops==2.*
influxdb==5.3.1
urllib3==1.26.9
etcd3gw==1.0.2
jinja2==3.1.2
git+https://github.com/omnivector-solutions/[email protected].15
git+https://github.com/omnivector-solutions/[email protected].16
3 changes: 0 additions & 3 deletions charm-slurmd/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ bases:
- name: centos
channel: "7"
architectures: [amd64]
- name: centos
channel: "8"
architectures: [amd64]
parts:
charm:
build-packages: [git]
Expand Down
69 changes: 37 additions & 32 deletions charm-slurmd/dispatch
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
#!/bin/bash
# This hook installs the centos dependencies needed to run the charm,
# This hook installs the dependencies needed to run the charm,
# creates the dispatch executable, regenerates the symlinks for start and
# upgrade-charm, and kicks off the operator framework.

set -e

# Source the os-release information into the env.
# Source the os-release information into the env
. /etc/os-release

if ! [[ -f '.installed' ]]
then
# Determine if we are running in centos or ubuntu, if centos
# provision the needed prereqs.
if [[ $ID == 'ubuntu' ]]
then
echo "Running Ubuntu."
# necessary to compile and install NHC
apt-get install --assume-yes make automake
elif [[ $ID == 'centos' ]]
then
# Determine the centos version and install prereqs accordingly
major=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f1)
echo "Running CentOS$major, installing prereqs."
if [[ $major == "7" ]]
then
yum -y install epel-release
yum -y install yum-priorities python3 make automake yum-utils
elif [[ $major == "8" ]]
then
dnf -y install epel-release
dnf -y install yum-priorities python3 make automake yum-utils
else
echo "Running unsuppored version of centos: $major"
exit -1
fi
elif [[ $ID == 'rocky' ]]

# Rocky specific setup
if [[ $ID == 'rocky' ]]
then
dnf install epel-release -y
dnf install dnf-plugins-core -y
dnf config-manager --set-enabled powertools -y
dnf install make automake yum-utils -y
else
echo "Running unsuppored os: $ID"
exit -1
fi

if [[ $ID == 'centos' || $ID == 'rocky' ]]
then
# Install dependencies
yum -y install epel-release
yum -y install yum-priorities python3 automake yum-utils

# Install dependencies and build custom python
yum -y install wget gcc make tar bzip2-devel zlib-devel xz-devel openssl-devel libffi-devel sqlite-devel ncurses-devel

export PYTHON_VERSION=3.8.16
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz -P /tmp
tar xvf /tmp/Python-${PYTHON_VERSION}.tar.xz -C /tmp
cd /tmp/Python-${PYTHON_VERSION}
./configure --prefix=/opt/python/python3.8 --enable-optimizations
make -C /tmp/Python-${PYTHON_VERSION} -j $(nproc) altinstall
cd $OLDPWD
rm -rf /tmp/Python*

# set the correct python bin path
PYTHON_BIN="/opt/python/python3.8/bin/python3.8"
elif [[ $ID == 'ubuntu' ]]
then
# Necessary to compile and install NHC
apt-get install --assume-yes make

# set the correct python bin path
PYTHON_BIN="/usr/bin/env python3"
fi

touch .installed
fi

JUJU_DISPATCH_PATH="${JUJU_DISPATCH_PATH:-$0}" PYTHONPATH=lib:venv ./src/charm.py

JUJU_DISPATCH_PATH="${JUJU_DISPATCH_PATH:-$0}" PYTHONPATH=lib:venv $PYTHON_BIN ./src/charm.py
2 changes: 1 addition & 1 deletion charm-slurmd/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ops==1.3.0
urllib3==1.26.9
etcd3gw==1.0.2
git+https://github.com/omnivector-solutions/[email protected].15
git+https://github.com/omnivector-solutions/[email protected].16
3 changes: 0 additions & 3 deletions charm-slurmdbd/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ bases:
- name: centos
channel: "7"
architectures: [amd64]
- name: centos
channel: "8"
architectures: [amd64]
parts:
charm:
build-packages: [git]
Expand Down
68 changes: 37 additions & 31 deletions charm-slurmdbd/dispatch
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
#!/bin/bash
# This hook installs the centos dependencies needed to run the charm,
# This hook installs the dependencies needed to run the charm,
# creates the dispatch executable, regenerates the symlinks for start and
# upgrade-charm, and kicks off the operator framework.

set -e

# Source the os-release information into the env.
# Source the os-release information into the env
. /etc/os-release

if ! [[ -f '.installed' ]]
then
# Determine if we are running in centos or ubuntu, if centos
# provision the needed prereqs.
if [[ $ID == 'ubuntu' ]]
then
echo "Running Ubuntu."
echo "Nothing to do."
elif [[ $ID == 'centos' ]]
then
# Determine the centos version and install prereqs accordingly
major=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f1)
echo "Running CentOS$major, installing prereqs."
if [[ $major == "7" ]]
then
yum -y install epel-release
yum -y install yum-priorities python3
elif [[ $major == "8" ]]
then
dnf -y install epel-release
dnf -y install yum-priorities python3
else
echo "Running unsuppored version of centos: $major"
exit -1
fi
elif [[ $ID == 'rocky' ]]

# Rocky specific setup
if [[ $ID == 'rocky' ]]
then
dnf install epel-release -y
dnf install dnf-plugins-core -y
dnf config-manager --set-enabled powertools -y
dnf install make automake yum-utils -y
else
echo "Running unsuppored os: $ID"
exit -1
fi

if [[ $ID == 'centos' || $ID == 'rocky' ]]
then
# Install dependencies
yum -y install epel-release
yum -y install yum-priorities python3 automake yum-utils

# Install dependencies and build custom python
yum -y install wget gcc make tar bzip2-devel zlib-devel xz-devel openssl-devel libffi-devel sqlite-devel ncurses-devel

export PYTHON_VERSION=3.8.16
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz -P /tmp
tar xvf /tmp/Python-${PYTHON_VERSION}.tar.xz -C /tmp
cd /tmp/Python-${PYTHON_VERSION}
./configure --prefix=/opt/python/python3.8 --enable-optimizations
make -C /tmp/Python-${PYTHON_VERSION} -j $(nproc) altinstall
cd $OLDPWD
rm -rf /tmp/Python*

# set the correct python bin path
PYTHON_BIN="/opt/python/python3.8/bin/python3.8"
elif [[ $ID == 'ubuntu' ]]
then
# Necessary to compile and install NHC
apt-get install --assume-yes make

# set the correct python bin path
PYTHON_BIN="/usr/bin/env python3"
fi

touch .installed
fi

JUJU_DISPATCH_PATH="${JUJU_DISPATCH_PATH:-$0}" PYTHONPATH=lib:venv ./src/charm.py

JUJU_DISPATCH_PATH="${JUJU_DISPATCH_PATH:-$0}" PYTHONPATH=lib:venv $PYTHON_BIN ./src/charm.py
4 changes: 2 additions & 2 deletions charm-slurmdbd/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ops==1.3.0
git+https://github.com/omnivector-solutions/[email protected].15
ops==2.*
git+https://github.com/omnivector-solutions/[email protected].16
3 changes: 0 additions & 3 deletions charm-slurmrestd/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ bases:
- name: centos
channel: "7"
architectures: [amd64]
- name: centos
channel: "8"
architectures: [amd64]
parts:
charm:
build-packages: [git]
Expand Down
Loading

0 comments on commit a6b269c

Please sign in to comment.