Use .pth files to set the python path

https://fedorahosted.org/fpc/ticket/563
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2015-08-27 17:35:04 -04:00
parent 842456ff9d
commit 5d4ee7ee9f
4 changed files with 28 additions and 13 deletions

View File

@ -1,6 +1,6 @@
--- src/packaging/envmods/mpich.module.in 2013-01-30 14:45:08.000000000 -0500
+++ src/packaging/envmods/mpich.module.in.new 2013-02-21 18:28:01.218528398 -0500
@@ -3,12 +3,22 @@
--- src/packaging/envmods/mpich.module.in 2015-02-20 15:48:13.000000000 -0500
+++ src/packaging/envmods/mpich.module.in.new 2015-08-27 15:27:43.667837212 -0400
@@ -3,12 +3,23 @@
# MPICH module for use with 'environment-modules' package:
#
@ -16,16 +16,17 @@
+setenv MPI_INCLUDE @includedir@
+setenv MPI_LIB @libdir@
+setenv MPI_MAN @mandir@
+setenv MPI_PYTHON_SITEARCH @pysitearch@/@MPINAME@
+setenv MPI_PYTHON_SITEARCH @py2sitearch@/@MPINAME@
+setenv MPI_PYTHON2_SITEARCH @py2sitearch@/@MPINAME@
+setenv MPI_PYTHON3_SITEARCH @py3sitearch@/@MPINAME@
+setenv MPI_COMPILER @MPINAME@-@ARCH@
+setenv MPI_SUFFIX _@MPINAME@
+setenv MPI_HOME @LIBDIR@
prepend-path PATH @bindir@
+prepend-path LD_LIBRARY_PATH @libdir@
prepend-path MANPATH @mandir@
+prepend-path PKG_CONFIG_PATH @LIBDIR@/lib/pkgconfig
-
-# Undefine prefix and exec_prefix which are too generic environment variables.
-unsetenv prefix
-unsetenv exec_prefix
+prepend-path PYTHONPATH @pysitearch@/@MPINAME@
+prepend-path PKG_CONFIG_PATH @LIBDIR@/lib/pkgconfig

1
mpich.pth.py2 Normal file
View File

@ -0,0 +1 @@
import sys, os; s = os.getenv('MPI_PYTHON2_SITEARCH'); s and (s in sys.path or sys.path.append(s))

1
mpich.pth.py3 Normal file
View File

@ -0,0 +1 @@
import sys, os; s = os.getenv('MPI_PYTHON3_SITEARCH'); s and (s in sys.path or sys.path.append(s))

View File

@ -1,13 +1,15 @@
Summary: A high-performance implementation of MPI
Name: mpich
Version: 3.1.4
Release: 5%{?dist}
Release: 6%{?dist}
License: MIT
Group: Development/Libraries
URL: http://www.mpich.org/
Source0: http://www.mpich.org/static/downloads/%{version}/%{name}-%{version}.tar.gz
Source1: mpich.macros
Source2: mpich.pth.py2
Source3: mpich.pth.py3
Patch0: mpich-modules.patch
BuildRequires: gcc-gfortran
@ -15,8 +17,9 @@ BuildRequires: hwloc-devel >= 1.8
%ifnarch s390
BuildRequires: valgrind-devel
%endif
# For python_sitearch
BuildRequires: python-devel
# For python[23]_sitearch
BuildRequires: python2-devel
BuildRequires: python3-devel
BuildRequires: rpm-mpi-hooks
Provides: mpi
Provides: mpich2 = 3.0.1
@ -169,7 +172,8 @@ mkdir -p %{buildroot}%{_sysconfdir}/modulefiles/mpi
sed 's#%{_bindir}#%{_libdir}/%{name}/bin#;
s#@LIBDIR@#%{_libdir}/%{name}#;
s#@MPINAME@#%{name}#;
s#@pysitearch@#%{python_sitearch}#;
s#@py2sitearch@#%{python2_sitearch}#;
s#@py3sitearch@#%{python3_sitearch}#;
s#@ARCH@#%{_arch}#' \
<src/packaging/envmods/mpich.module \
>%{buildroot}%{_sysconfdir}/modulefiles/mpi/%{name}-%{_arch}
@ -184,7 +188,11 @@ cp -p %{buildroot}%{_sysconfdir}/profile.d/mpich-%{_arch}.{sh,csh}
# Install the RPM macros
install -pDm0644 %{SOURCE1} %{buildroot}%{_rpmconfigdir}/macros.d/macros.%{name}
mkdir -p %{buildroot}%{python_sitearch}/%{name}
# Install the .pth files
mkdir -p %{buildroot}%{python2_sitearch}/%{name}
install -pDm0644 %{SOURCE2} %{buildroot}%{python2_sitearch}/%{name}.pth
mkdir -p %{buildroot}%{python3_sitearch}/%{name}
install -pDm0644 %{SOURCE3} %{buildroot}%{python3_sitearch}/%{name}.pth
find %{buildroot} -type f -name "*.la" -delete
@ -203,7 +211,10 @@ make check VERBOSE=1
%dir %{_libdir}/%{name}/bin
%{_libdir}/%{name}/lib/*.so.*
%{_libdir}/%{name}/bin/*
%dir %{python_sitearch}/%{name}
%dir %{python2_sitearch}/%{name}
%{python2_sitearch}/%{name}.pth
%dir %{python3_sitearch}/%{name}
%{python3_sitearch}/%{name}.pth
%dir %{_mandir}/%{name}
%doc %{_mandir}/%{name}/man1/
%{_sysconfdir}/modulefiles/mpi/
@ -225,6 +236,7 @@ make check VERBOSE=1
%changelog
* Thu Aug 27 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 3.1.4-6
- Use .pth files to set the python path (https://fedorahosted.org/fpc/ticket/563)
- Cleanups to the spec file
* Sun Jul 26 2015 Sandro Mani <manisandro@gmail.com> - 3.1.4-5