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

Updated build_script for matplotlib #4797

Open
wants to merge 1 commit into
base: python-ecosystem
Choose a base branch
from
Open
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
88 changes: 41 additions & 47 deletions m/matplotlib/matplotlib_ubi_9.3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,65 +18,59 @@
#
# ----------------------------------------------------------------------------

yum install -y python311 python3.11-devel python3.11-pip git gcc-c++ cmake wget
yum install -y openblas-devel ninja-build
yum install -y zlib zlib-devel libjpeg-turbo libjpeg-turbo-devel

# Clone the matplotlib package.
PACKAGE_NAME=matplotlib
PACKAGE_VERSION=${1:-v3.9.2}
PACKAGE_URL=https://github.com/matplotlib/matplotlib.git
OS_NAME=$(cat /etc/os-release | grep ^PRETTY_NAME | cut -d= -f2)
PYTHON_VER=${2:-3.11}

git clone $PACKAGE_URL
cd $PACKAGE_NAME/
git checkout $PACKAGE_VERSION
git submodule update --init
dnf install -y https://mirror.stream.centos.org/9-stream/BaseOS/ppc64le/os/Packages/centos-gpg-keys-9.0-24.el9.noarch.rpm \
https://mirror.stream.centos.org/9-stream/BaseOS/`arch`/os/Packages/centos-stream-repos-9.0-24.el9.noarch.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf config-manager --add-repo https://mirror.stream.centos.org/9-stream/BaseOS/`arch`/os
dnf config-manager --add-repo https://mirror.stream.centos.org/9-stream/AppStream/`arch`/os
dnf config-manager --set-enabled crb
dnf install -y git g++ ninja-build pybind11-devel \
libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \
freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \
harfbuzz-devel fribidi-devel libraqm-devel libimagequant-devel libxcb-devel \
python${PYTHON_VER}-devel python${PYTHON_VER}-pip python${PYTHON_VER}-setuptools python${PYTHON_VER}-wheel

# Download qhull
mkdir -p build
wget 'http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz'
gunzip qhull-2020-src-8.0.2.tgz
tar -xvf qhull-2020-src-8.0.2.tar --no-same-owner
mv qhull-2020.2 build/
rm -f qhull-2020-src-8.0.2.tar
if ! command -v pip; then
ln -s $(command -v pip${PYTHON_VER}) /usr/bin/pip
fi
if ! command -v python; then
ln -s $(command -v python${PYTHON_VER}) /usr/bin/python
fi

# Setup virtual environment for python
python3.11 -m venv matplotlib-env
source matplotlib-env/bin/activate
pip3.11 install pytest hypothesis build meson pybind11 meson-python

# Build and Install the package (This is dependent on numpy,pillow)
python3.11 -m build
python3.11 -m pip install -e .
# A virtual environment is needed as Maplotlib builds with meson build system
# Meson picks python3 (/usr/bin/python3 -> python3.9) on UBI9
# Virtual env sets python3 -> python$PYTHON_VER and adds it in PATH
python -m venv .venv
source .venv/bin/activate

if [ $? == 0 ]; then
echo "------------------$PACKAGE_NAME::Build_Pass---------------------"
echo "$PACKAGE_VERSION $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | Pass | Build_Success"
else
echo "------------------$PACKAGE_NAME::Build_Fail-------------------------"
echo "$PACKAGE_VERSION $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | Fail | Build_Fail"
exit 1
fi
pip install -U contourpy cycler fonttools kiwisolver meson meson-python \
numpy packaging pillow pybind11 pyparsing pyproject-metadata python-dateutil setuptools-scm six

# Test the package
python3.11 -c "import matplotlib; print(matplotlib.__file__)"

pytest ./lib/matplotlib/tests/test_units.py
if ! pip install -v matplotlib==${PACKAGE_VERSION:1} --no-build-isolation; then
echo "------------------$PACKAGE_NAME:install_fails-------------------------------------"
echo "$PACKAGE_URL $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | GitHub | Fail | Install_Fails"
exit 1
fi

if [ $? == 0 ]; then
echo "------------------$PACKAGE_NAME::Test_Pass---------------------"
echo "$PACKAGE_VERSION $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | Pass | Test_Success"
exit 0
if ! python -c "import matplotlib; print(matplotlib.__file__)"; then
echo "------------------$PACKAGE_NAME:install_success_but_test_fails---------------------"
echo "$PACKAGE_URL $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | GitHub | Fail | Install_success_but_test_Fails"
exit 2
else
echo "------------------$PACKAGE_NAME::Test_Fail-------------------------"
echo "$PACKAGE_VERSION $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | Fail | Test_Fail"
exit 2
echo "------------------$PACKAGE_NAME:install_&_test_both_success-------------------------"
echo "$PACKAGE_URL $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | GitHub | Pass | Both_Install_and_Test_Success"
exit 0
fi

# Deactivate python environment (matplotlib-env)
deactivate