Skip to content
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

feat: Add a custom Python 3.8 installation #181

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ This file keeps track of all notable changes to the Slurm Charms.
Unreleased
----------

- added a custom python installation to run the charm code
- removed CentOS 8 support

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
2 changes: 1 addition & 1 deletion charm-slurmctld/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ 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
2 changes: 1 addition & 1 deletion 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
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
Loading