Skip to content

Commit

Permalink
feat: ASP-3288 Use Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimesouza committed Dec 11, 2023
1 parent da69a87 commit 0925886
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 46 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Unreleased
- Added new configuration: JOBBERGATE_LEGACY_NAME_CONVENTION
- Added new configuration: SBATCH_PATH [ASP-4238]
- Added new configuration: JOBBERGATE_CACHE_DIR [ASP-4053]
- Dropped support for CentOS 8
- Installed Python 3.12 to run the CLI

1.0.3 - 2023-09-07
------------------
Expand Down
6 changes: 3 additions & 3 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ bases:
- name: centos
channel: "7"
architectures: [amd64]
- name: centos
channel: "8"
architectures: [amd64]
parts:
charm:
charm-python-packages: [setuptools]
64 changes: 32 additions & 32 deletions dispatch
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
#!/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

PYTHON_BIN=/opt/python/3.8.16/bin/python3.8
PYTHON_BIN=/opt/python/python3.12/bin/python3.12

if [ ! -f '.installed' ]
if ! [[ -f '.installed' ]]
then
# Determine if we are running in centos or ubuntu, if centos
# provision the needed prereqs.
if [[ $ID == 'centos' || $ID == 'rocky' ]]
then
# Install yaml deps
yum -y install libyaml-devel

# We need python3.8 to run license-manager-agent.
# Install python3.8 from source.
if [ ! -e $PYTHON_BIN ]
then
yum install -y epel-release gcc zlib-devel bzip2 bzip2-devel readline-devel \
sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel wget

/bin/bash ./src/templates/install_python.sh
fi
elif [ $ID == 'ubuntu' ]
if [[ ! -e $PYTHON_BIN ]]
then
# We are running an ubuntu os, so check for python and install the
# needed venv package or python3 from source, depending on what already
# exists on the system.
#
if [ ! -e $PYTHON_BIN ]
if [[ $ID == 'centos' || $ID == 'rocky' ]]
then
apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
# Install dependencies to build custom python
yum -y install epel-release
yum -y install wget gcc make tar bzip2-devel zlib-devel xz-devel openssl-devel libffi-devel sqlite-devel ncurses-devel openssl11-libs openssl11-devel tk-devel libreadline-devel libgdbm-devel

# Install yaml deps
yum -y install libyaml-devel
fi

/bin/bash ./src/templates/install_python.sh
if [[ $ID == 'ubuntu' ]]
then
# Install dependencies to build custom python
apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
fi

export PYTHON_VERSION=3.12.1
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}
export CFLAGS="$CFLAGS $(pkg-config --cflags openssl11)"
export LDFLAGS="$LDFLAGS $(pkg-config --libs openssl11)"
./configure --prefix=/opt/python/python3.12 --enable-optimizations
make -C /tmp/Python-${PYTHON_VERSION} -j $(nproc) altinstall
cd $OLDPWD
rm -rf /tmp/Python*
fi
touch .installed
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 src/jobbergate_cli_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class JobbergateCliOps:
"""Track and perform jobbergate-cli ops."""

_PYTHON_BIN = Path("/opt/python/3.8.16/bin/python3.8")
_PYTHON_BIN = Path("/opt/python/python3.12/bin/python3.12")
_PACKAGE_NAME = "jobbergate-cli"
_VENV_DIR = Path("/srv/new-jobbergate-cli-venv")
_VENV_PYTHON = _VENV_DIR.joinpath("bin", "python").as_posix()
Expand Down
10 changes: 0 additions & 10 deletions src/templates/install_python.sh

This file was deleted.

0 comments on commit 0925886

Please sign in to comment.