9e48221
%if 0%{?rhel} && 0%{?rhel} <= 6
Björn Esser 2ee6266
# Failsafe backport of Python2-macros for RHEL <= 6
Björn Esser 2ee6266
%{!?python_sitelib:	%global python_sitelib		%(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
Björn Esser 2ee6266
%{!?python_sitearch:	%global python_sitearch		%(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
Björn Esser 2ee6266
%{!?python_version:	%global python_version		%(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")}
Björn Esser 2ee6266
%{!?__python2:		%global __python2		%{__python}}
Björn Esser 2ee6266
%{!?python2_sitelib:	%global python2_sitelib		%{python_sitelib}}
Björn Esser 2ee6266
%{!?python2_sitearch:	%global python2_sitearch	%{python_sitearch}}
Björn Esser 2ee6266
%{!?python2_version:	%global python2_version		%{python_version}}
9e48221
%endif
9e48221
9e48221
%if 0%{?fedora} > 12
9e48221
%global			with_python3	1
9e48221
%endif
Björn Esser 2ee6266
0d9467c
%global upstream_name ase
0d9467c
Marcin Dulak bfc1294
%global upstream_commit 88f25faf32519e6e191d1e702b0554d2e5f43399
0d9467c
0d9467c
Name:			python-ase
Marcin Dulak bfc1294
Version:		3.11.0
dbe0c2c
Release:		20%{?dist}
0d9467c
Summary:		Atomic Simulation Environment
0d9467c
%{?el5:Group:		Applications/Scientific}
0d9467c
0d9467c
0d9467c
# The entire source code is LGPLv2+ except:
0d9467c
# ase/io/fortranfile.py which is MIT
0d9467c
License:		LGPLv2+ and MIT
0d9467c
0d9467c
URL:			https://wiki.fysik.dtu.dk/ase/
Marcin Dulak bfc1294
Source0:		https://gitlab.com/%{upstream_name}/%{upstream_name}/repository/archive.tar.gz?ref=%{version}#/%{upstream_name}-%{version}-%{upstream_commit}.tar.gz
cd13d59
Marcin Dulak bfc1294
%{?el5:BuildRoot:	%(mktemp -ud %{_tmppath}/%{upstream_name}-%{version}-%{upstream_commit}-%{release}-XXXXXX)}
0d9467c
BuildArch:		noarch
0d9467c
Marcin Dulak bfc1294
%global PKG_TOP $RPM_BUILD_DIR/%{upstream_name}-%{version}-%{upstream_commit}
0d9467c
0d9467c
BuildRequires:		python2-devel
9e48221
%if 0%{?with_python3}
9e48221
BuildRequires:		python3-devel
9e48221
%endif # if with_python3
0d9467c
BuildRequires:		gettext
0d9467c
BuildRequires:		desktop-file-utils
0d9467c
0d9467c
BuildRequires:		numpy
9e48221
%if 0%{?with_python3}
9e48221
BuildRequires:		python3-numpy
9e48221
%endif # if with_python3
0d9467c
0d9467c
%if 0%{?rhel} && 0%{?rhel} <= 6
0d9467c
Requires:		pygtk2
0d9467c
%endif
0d9467c
Requires:		python-matplotlib
0d9467c
0d9467c
%description
0d9467c
The Atomic Simulation Environment (ASE) is the common part of the simulation
0d9467c
tools developed at CAMd. ASE provides Python modules for manipulating atoms,
0d9467c
analyzing simulations, visualization etc.
0d9467c
9e48221
%if 0%{?with_python3}
9e48221
%package -n python3-ase
9e48221
Summary:		Atomic Simulation Environment for Python 3
9e48221
Requires:		python3-matplotlib
9e48221
9e48221
%description -n python3-ase
9e48221
The Atomic Simulation Environment (ASE) is the common part of the simulation
9e48221
tools developed at CAMd. ASE provides Python 3 modules for manipulating atoms,
9e48221
analyzing simulations, etc.
9e48221
%endif # with_python3
0d9467c
0d9467c
%prep
Marcin Dulak bfc1294
%setup -qn %{upstream_name}-%{version}-%{upstream_commit}
0d9467c
Marcin Dulak bfc1294
# copy required sources and remove doc directory
Marcin Dulak bfc1294
cp -p doc/static/%{upstream_name}256.png %{upstream_name}.png
Marcin Dulak bfc1294
cp -p doc/%{upstream_name}-gui.desktop %{upstream_name}-gui.desktop
0d9467c
rm -rf doc
0d9467c
9e48221
%if 0%{?with_python3}
9e48221
rm -rf %{py3dir}
9e48221
cp -a . %{py3dir}
9e48221
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
9e48221
%endif # with_python3
9e48221
9e48221
find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python2}|'
9e48221
0d9467c
0d9467c
%build
9e48221
%if 0%{?with_python3}
9e48221
pushd %{py3dir}
9e48221
%{__python3} setup.py build
9e48221
popd
9e48221
%endif # with _python3
9e48221
9e48221
%{__python2} setup.py build
0d9467c
0d9467c
0d9467c
%install
0d9467c
%{?el5:rm -rf $RPM_BUILD_ROOT}
9e48221
9e48221
%if 0%{?with_python3}
9e48221
pushd %{py3dir}
9e48221
%{__python3} setup.py install --skip-build --prefix=%{_prefix} \
9e48221
	   --optimize=1 --root $RPM_BUILD_ROOT
9e48221
popd
9e48221
# Rename Python 3 binaries
9e48221
for file in `find $RPM_BUILD_ROOT/%{_bindir}/ -name "ase-*"`; do
9e48221
  mv -f ${file} $RPM_BUILD_ROOT/%{_bindir}/`basename $file`3
9e48221
done
9e48221
# remove ase-gui3 (not working)
9e48221
rm -f $RPM_BUILD_ROOT/%{_bindir}/ase-gui3
9e48221
# remove .mo files
9e48221
find $RPM_BUILD_ROOT%{python3_sitelib}/%{upstream_name} -type f -name "*.mo" | xargs rm
9e48221
%endif # with_python3
9e48221
9e48221
Björn Esser 2ee6266
%{__python2} setup.py install --skip-build --prefix=%{_prefix} \
9e48221
	   --optimize=1 --root $RPM_BUILD_ROOT
0d9467c
0d9467c
# doc would go under $RPM_BUILD_ROOT%%{_datadir}/%%{name}
0d9467c
# if only we get rid of povray dependency one could build doc with:
dad48a3
# cd $RPM_BUILD_ROOT%%{_datadir}/%%{name}/doc&& sphinx-build . _build
0d9467c
0d9467c
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
0d9467c
desktop-file-install \
0d9467c
--dir $RPM_BUILD_ROOT%{_datadir}/applications \
Björn Esser 76f5a0d
%if (0%{?fedora} && 0%{?fedora} < 20) || (0%{?rhel} && 0%{?rhel} < 7)
Björn Esser 76f5a0d
--vendor "%{upstream_name}" \
Björn Esser 76f5a0d
%endif
Marcin Dulak bfc1294
%{upstream_name}-gui.desktop
0d9467c
0d9467c
mkdir -p $RPM_BUILD_ROOT%{_datadir}/pixmaps
45adf77
install -p -m 644 %{upstream_name}.png $RPM_BUILD_ROOT%{_datadir}/pixmaps
0d9467c
0d9467c
# we store translations in ase/gui/po/*/*/ag.mo
0d9467c
# but /usr/lib/rpm/find-lang.sh wants locale (Fedora) or share/locale (el6)
Björn Esser 2ee6266
mkdir $RPM_BUILD_ROOT%{python2_sitelib}/%{upstream_name}/gui/share
Björn Esser 2ee6266
cp -rp $RPM_BUILD_ROOT%{python2_sitelib}/%{upstream_name}/gui/po $RPM_BUILD_ROOT%{python2_sitelib}/%{upstream_name}/gui/share/locale
0d9467c
%find_lang ag
Björn Esser 2ee6266
rm -rf $RPM_BUILD_ROOT%{python2_sitelib}/%{upstream_name}/gui/share
0d9467c
sed -i "s|share/locale|po|g" %{PKG_TOP}/ag.lang
0d9467c
0d9467c
# create list of all installed dirs/files(exclude *.mo) and concat with ag.lang
9e48221
find $RPM_BUILD_ROOT%{python2_sitelib}/%{upstream_name} -type d | xargs -I _file echo "%dir _file" > %{PKG_TOP}/d2.list
Marcin Dulak bfc1294
find $RPM_BUILD_ROOT%{python2_sitelib}/%{upstream_name} -type f ! -name "*.mo" > %{PKG_TOP}/f2.list
9e48221
cat %{PKG_TOP}/ag.lang %{PKG_TOP}/d2.list %{PKG_TOP}/f2.list > %{PKG_TOP}/files2.list
9e48221
# trim the $RPM_BUILD_ROOT
9e48221
sed -i "s|$RPM_BUILD_ROOT||g" %{PKG_TOP}/files2.list
9e48221
9e48221
9e48221
%if 0%{?with_python3}
9e48221
# create list of all installed dirs/files(exclude *.mo) for Python 3
9e48221
find $RPM_BUILD_ROOT%{python3_sitelib}/%{upstream_name} -type d | xargs -I _file echo "%dir _file" > %{PKG_TOP}/d3.list
9e48221
find $RPM_BUILD_ROOT%{python3_sitelib}/%{upstream_name} -type f ! -name "*.mo"  > %{PKG_TOP}/f3.list
9e48221
cat %{PKG_TOP}/d3.list %{PKG_TOP}/f3.list > %{PKG_TOP}/files3.list
0d9467c
# trim the $RPM_BUILD_ROOT
9e48221
sed -i "s|$RPM_BUILD_ROOT||g" %{PKG_TOP}/files3.list
9e48221
%endif # with_python3
0d9467c
0d9467c
0d9467c
%check
9e48221
%if 0%{?with_python3}
9e48221
pushd %{py3dir}
9e48221
export PYTHONPATH=`pwd`/build/lib
9e48221
export PATH=`pwd`/build/scripts-%{python3_version}:${PATH}
9e48221
mkdir testase && cd testase
Marcin Dulak bfc1294
LC_ALL=C.UTF-8 %{__python3} -c "from ase.test import test; test(verbosity=2, display=False)"
9e48221
cd -
9e48221
popd
9e48221
%endif # with_python3
9e48221
0d9467c
export PYTHONPATH=`pwd`/build/lib
Björn Esser 2ee6266
export PATH=`pwd`/build/scripts-%{python2_version}:${PATH}
9e48221
mkdir testase && cd testase
Marcin Dulak bfc1294
LC_ALL=C.UTF-8 %{__python2} -c "from ase.test import test; test(verbosity=2, display=False)"
0d9467c
cd -
0d9467c
0d9467c
0d9467c
%clean
0d9467c
%{?el5:rm -rf $RPM_BUILD_ROOT}
0d9467c
0d9467c
9e48221
%files -f files2.list
975db4e
%defattr(-,root,root,-)
Marcin Dulak bfc1294
%doc COPYING* LICENSE README*
9e48221
%{_bindir}/ase-*
9e48221
%if 0%{?with_python3}
9e48221
%exclude %{_bindir}/ase-*3
9e48221
%endif # with_python3
Björn Esser 2ee6266
%{?!el5:%{python2_sitelib}/*.egg-info}
0d9467c
%{_datadir}/applications/%{upstream_name}-gui.desktop
0d9467c
%{_datadir}/pixmaps/%{upstream_name}.png
0d9467c
9e48221
%if 0%{?with_python3}
9e48221
%files -n python3-ase -f files3.list
975db4e
%defattr(-,root,root,-)
Marcin Dulak bfc1294
%doc COPYING* LICENSE README*
9e48221
%{_bindir}/ase-*3
9e48221
%{python3_sitelib}/*.egg-info
9e48221
%endif # with_python3
0d9467c
0d9467c
%changelog
dbe0c2c
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.11.0-20
dbe0c2c
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
dbe0c2c
Marcin Dulak bfc1294
* Sat Jun 18 2016 Marcin Dulak <Marcin.Dulak@gmail.com> - 3.11.0-19
Marcin Dulak bfc1294
- upstream moved to gitlab
Marcin Dulak bfc1294
Marcin Dulak bfc1294
* Wed Feb 17 2016 Marcin Dulak <Marcin.Dulak@gmail.com> - 3.10.0-18
Marcin Dulak bfc1294
- upstream 3.10.1, no more upstream_svn
Marcin Dulak bfc1294
- LC_ALL=C.UTF-8 needed by the tests
Marcin Dulak bfc1294
a4afee0
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 3.9.1.4567-17
a4afee0
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
a4afee0
c0295af
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.9.1.4567-16
c0295af
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
c0295af
975db4e
* Wed Jul 22 2015 Marcin Dulak <Marcin.Dulak@gmail.com> - 3.9.1.4567-15
975db4e
- upstream 3.9.1.4567
975db4e
- files-attr
31fabdb
9e48221
* Fri May 29 2015 Marcin Dulak <Marcin.Dulak@gmail.com> - 3.9.0.4465-14
9e48221
- python3, build log files removed
9e48221
- upstream 3.9.0.4465
9e48221
baf9ad5
* Fri Oct 31 2014 Marcin Dulak <Marcin.Dulak@gmail.com> - 3.8.1.3440-13
baf9ad5
- larger icon - https://bugzilla.redhat.com/show_bug.cgi?id=1157516
baf9ad5
933235e
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.8.1.3440-12
933235e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
933235e
Björn Esser 2ee6266
* Sat May 03 2014 Björn Esser <bjoern.esser@gmail.com> - 3.8.1.3440-11
Björn Esser 2ee6266
- failsafe backport of Python2-macros for RHEL <= 6
Björn Esser 2ee6266
45adf77
* Fri Jan 17 2014 Marcin Dulak <Marcin.Dulak@gmail.com> - 3.8.1.3440-10
45adf77
- https://bugzilla.redhat.com/show_bug.cgi?id=1044199
45adf77
- https://bugzilla.redhat.com/show_bug.cgi?id=1044200
45adf77
cd13d59
* Tue Dec 10 2013 Marcin Dulak <Marcin.Dulak@gmail.com> - 3.8.1.3440-9
cd13d59
- upstream patch for launching ase-gui without terminal (gtk-launch ase-gui)
cd13d59
- desktop file in svn
cd13d59
dad48a3
* Sat Nov 30 2013 Marcin Dulak <Marcin.Dulak@gmail.com> - 3.8.1.3440-8
dad48a3
- fix Exec in ase-gui.desktop
dad48a3
- remove MANIFEST.in from %%doc 
dad48a3
- PATH modified for tests to include scripts dir
dad48a3
a70f791
* Fri Nov 22 2013 Marcin Dulak <Marcin.Dulak@gmail.com> - 3.8.1.3440-7
a70f791
- new upstream version, old patches removed
a70f791
Björn Esser 9f175bd
* Thu Sep 19 2013 Björn Esser <bjoern.esser@gmail.com> - 3.7.1.3184-6
Björn Esser 9f175bd
- Devendorized!
Björn Esser 9f175bd
978a251
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.7.1.3184-5
978a251
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
978a251
0d9467c
* Tue Jun 25 2013 Marcin Dulak <Marcin.Dulak@gmail.com> 3.7.1.3184-4
0d9467c
- fix bug #976886 c#9
0d9467c
0d9467c
* Sun Jun 23 2013 Marcin Dulak <Marcin.Dulak@gmail.com> 3.7.1.3184-3
0d9467c
- builds on el5
0d9467c
- remove doc
0d9467c
- %%{upstream_name}.png goes to %%{_datadir}/pixmaps
0d9467c
- fix bug #976886 c#4
0d9467c
0d9467c
* Sat Jun 22 2013 Marcin Dulak <Marcin.Dulak@gmail.com> 3.7.1.3184-2
0d9467c
- include desktop file
0d9467c
- partly fix bug#976886#c1 and #c2
0d9467c
0d9467c
* Fri Jun 21 2013 Marcin Dulak <Marcin.Dulak@gmail.com> 3.7.1.3184-1
0d9467c
- trimmed for Fedora/RHEL
0d9467c
0d9467c
* Mon May 6 2013 Marcin Dulak <Marcin.Dulak@fysik.dtu.dk> 3.6.1-2
0d9467c
- include docs
0d9467c
0d9467c
* Mon Jun 11 2012 Marcin Dulak <Marcin.Dulak@fysik.dtu.dk> 3.6.0-1
0d9467c
- restructured for build.opensuse.org and Fedora based on campos-ase3.spec
0d9467c
0d9467c
* Tue Apr 27 2010 Marcin Dulak <Marcin.Dulak@fysik.dtu.dk>
0d9467c
- common Requires for EL, Fedora, openSUSE
0d9467c
- perform testase.py when building
0d9467c
- removed dependecy in python-lxml
0d9467c
0d9467c
* Wed Jun 18 2008 Marcin Dulak <Marcin.Dulak@fysik.dtu.dk>
0d9467c
- FC 9: set -- ${variable} converts dashes of $1 into underlines so use $2
0d9467c
0d9467c
* Mon Jun 16 2008 Marcin Dulak <Marcin.Dulak@fysik.dtu.dk>
0d9467c
- initial version