File easybuild.spec of Package easybuild

#
# spec file for package easybuild
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define pname easybuild
%define vsc_base_ver 2.8.3
%define vsc_install_ver 0.11.2
%define installdir %{_prefix}/lib/software
%define eb_group easybuild

%define skip_python2 1

Name:           easybuild
Version:        4.6.2
Release:        0
Summary:        Scientific software compilation utility
License:        GPL-2.0-only
Group:          Development/Tools/Building
URL:            http://easybuilders.github.io/easybuild

Source0:   https://pypi.io/packages/source/e/easybuild/easybuild-%{version}.tar.gz
Source1:   https://pypi.io/packages/source/e/easybuild-easyblocks/easybuild-easyblocks-%{version}.tar.gz
Source2:   https://pypi.io/packages/source/e/easybuild-easyconfigs/easybuild-easyconfigs-%{version}.tar.gz
Source3:   https://pypi.io/packages/source/e/easybuild-framework/easybuild-framework-%{version}.tar.gz
Source10:       easybuild-rpmlintrc
Requires:       bison
Requires:       bzip2
Requires:       easyconfigs
Requires:       openssl-devel
Requires:       python3
Requires:       rdma-core-devel
%if 0%{?suse_version} > 1500  ||  0%{?sle_version} == 150300
BuildRequires:  openmpi4-devel
Requires:       openmpi4-devel
%endif
%if 0%{?suse_version} > 1500
# we need gcc7 to build the tool chains
Requires:       gcc7-c++
%endif
Requires:       autoconf
Requires:       gcc-c++
Requires:       gmp-devel
Requires:       make
Requires:       patch
Requires:       perl
Requires:       tcsh
# needed to build minimal toolchains
Requires:       isl-devel
BuildRequires:  fdupes
BuildRequires:  lua-lmod
Requires:       lua-lmod
BuildRequires: python3 python3-pip
BuildRequires: python3-setuptools
BuildArch:      noarch

%description
EasyBuild is a software build and installation framework for
managing (scientific) software on High Performance Computing (HPC)
systems.

%package easyconfigs
Summary:        Concrete configs for building software with easybuild
Group:          System/Packages
Requires:       %name
Provides:       easyconfigs

%description easyconfigs
The easyconfigs are needed by EasyBuild for building the software and contain
information for building and installing. The
easyconfigs do not include the required sources. These sources are downloaded
by EasyBuild or need to be provided in case of propriatory software.

%prep
%setup -q -n %{pname}-%{version} -a1 -a2 -a3

%install
for eb in framework easyblocks easyconfigs; do
	cd %{pname}-${eb}-%{version}
	pip3 install --prefix=%{installdir} --root=%{buildroot} .
	cd ..
done

# Create /etc/profile.d/easybuild.sh
# This file properly sets MODULEPATH so lua-lmod can find the modules created by spack
mkdir -p %{buildroot}/%{_sysconfdir}/profile.d
cat > %{buildroot}/%{_sysconfdir}/profile.d/easybuild.sh <<EOFOUTER

# copy local configuration, if its not there
# test if user is in easybuild group by touching the location
if ! touch %{installdir}/software &> /dev/null ; then
  export MODULEPATH=~/.local/easybuild/modules/all:\${MODULEPATH}
else
  test -d \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild || mkdir -p \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild
  test -e \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild/location.cfg || cat > \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild/location.cfg <<EOF
[main]
installpath=%{installdir}/software/EasyBuild/%{version}/software
EOF
fi
MODULEPATH=%{installdir}/software/EasyBuild/%version/software/modules/all:\${MODULEPATH}
EOFOUTER
# Same for csh
cat > %{buildroot}/%{_sysconfdir}/profile.d/easybuild.csh <<EOFOUTER
touch %{installdir}/software >& /dev/null
if ( \$? == 1  ) then
  set MODULEPATH="~/.local/easybuild/modules/all:\${MODULEPATH}"
else
  test -d \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild || mkdir -p \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild
  test -e \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild/location.cfg || cat > \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild/location.cfg <<EOF
[main]
installpath=%{installdir}/software/EasyBuild/%{version}/software
EOF
endif
EOFOUTER

# create a config, so that not too much stuff is build
mkdir -p %{buildroot}/%{_sysconfdir}/xdg/easybuild.d/
cat > %{buildroot}/%{_sysconfdir}/xdg/easybuild.d/suse.cfg <<EOF
[override]
%if 0%{?suse_version} > 1500
minimal-build-env=CC:gcc-7,CXX:g++-7
%endif
filter-deps=binutils,Bison,M4,flex,Perl,Autoconf,Automake,Autotools
EOF
mkdir -p %{buildroot}/%{installdir}/software/EasyBuild/%version/modules

## now the module file for EasyBuild
#%define MODULES_PATH /usr/share/lmod/modulefiles
#%{__mkdir} -p %{buildroot}%{MODULES_PATH}/easybuild
#%{__cat} << EOF > %{buildroot}/%{MODULES_PATH}/easybuild/%{version}
##%Module1.0#####################################################################
#
#proc ModulesHelp { } {
#
#puts stderr " "
#puts stderr "This module loads %{pname}"
#puts stderr "\nVersion %{version}\n"
#
#}
#module-whatis "Name: %{pname}"
#module-whatis "Version: %{version}"
#module-whatis "Category: system tool"
#module-whatis "Description: %{summary}"
#module-whatis "URL: https://easybuilders.github.io/easybuild/"
#
#set             version                 %{version}
#set             home                    \$::env(HOME)
#
#prepend-path    PATH                    %{install_path}/bin
#prepend-path    PATH                    ${LMOD_DIR}
#module          use                     \$home/.local/easybuild/modules/all
#
#setenv          EBROOTEASYBUILD         %{install_path}
#setenv          EBVERSIONEASYBUILD      %{version}
#setenv          EB_PYTHON               python3
#
#prepend-path	PYTHONPATH	    %{install_path}/lib/python%{python3_version}/site-packages
#
#EOF
#
#%{__cat} << EOF > %{buildroot}/%{MODULES_PATH}/easybuild/.version.%{version}
##%Module1.0#####################################################################
###
### version file for %{pname}-%{version}
###
#set     ModulesVersion      "%{version}"
#EOF
# Change ambiguous python shebangs into python3

for file in \
	easybuild/easyconfigs/p/PyTorch/PyTorch-check-cpp-extension.py \
	easybuild/scripts/bootstrap_eb.py \
	easybuild/scripts/clean_gists.py \
	easybuild/scripts/findPythonDeps.py \
	easybuild/scripts/fix_docs.py \
	easybuild/scripts/mk_tmpl_easyblock_for.py \
	easybuild/scripts/rpath_args.py; do
	sed -e "s,^#\!/usr/bin/env python,#\!/usr/bin/env python3,g" \
		-i %{buildroot}/%{installdir}/${file}
done


%pre
getent group %eb_group >/dev/null || groupadd -r %eb_group

%post
# create the system toolchain modules, but only if mpicc can be found
#test -e /usr/lib64/mpi/gcc/openmpi4/bin || exit 0
#source /etc/profile.d/lmod.sh
#USER=root PATH=/usr/lib64/mpi/gcc/openmpi4/bin:$PATH \
#PYTHONPATH=%{installdir}/software/EasyBuild/%{version}/lib/python%{python_version}/site-packages:$PYTHONPATH \
#%{installdir}/software/EasyBuild/%{version}/bin/eb \
#--installpath %{installdir}/software/EasyBuild/%{version}/software/ gompi-system-2.29.eb -r --allow-use-as-root-and-accept-consequences \
#--filter-deps=binutils,Bison,M4,flex,Perl,Autoconf,Automake,Autotools
#
%files
#%%doc ChangeLog README COPYING
#%%dir %{installdir}/software
%dir %{installdir}/
%dir %{installdir}/lib
#%%exclude %{installdir}/%{_datadir}
#%%exclude %{installdir}/software/EasyBuild/%version/easybuild/easyconfigs
#%%dir %{_datadir}/lmod/modulefiles/%{name}
#%%{_datadir}/lmod/modulefiles/%{name}/%{version}
#%{installdir}/modules
%dir %{_sysconfdir}/xdg/easybuild.d
%config %{_sysconfdir}/xdg/easybuild.d/suse.cfg
%config %{_sysconfdir}/profile.d/easybuild.*sh
#attr(0775, root, %eb_group) %{installdir}/software/EasyBuild/%version/modules
%{installdir}/bin
%{installdir}/contrib
%{installdir}/easybuild
%{installdir}/etc/
%{installdir}/lib/python%{python_version}
%exclude %{installdir}/%{pname}/easyconfigs
%files easyconfigs
%dir %{installdir}/software
%{installdir}/%{pname}/easyconfigs

%changelog
openSUSE Build Service is sponsored by