Blob Blame Raw
%global encoding UTF-8
#%%global fail_fast 1
# python3 for Fedora only (not available at EPEL)
%if 0%{?fedora}
%bcond_without python3
%endif
# build conditionals for debug performance
%bcond_without test_python
%if 0%{?fail_fast} == 0
%bcond_without test_java
%bcond_without javadoc
%bcond_without html
%endif
Name:           py4j
Version:        0.10.6
Release:        1%{?dist}
Summary:        Dynamically access in Python programs to arbitrary Java objects
License:        BSD
URL:            http://%{name}.sf.net
Source0:        https://github.com/bartdag/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
Patch0:         %{name}-add-hamcrest-in-classpath.patch
Patch1:         %{name}-Base64-java8.patch
Patch2:         %{name}-Base64-java7.patch
BuildArch:      noarch
BuildRequires:  python2-devel python-setuptools
%if %{with python3}
BuildRequires:  python3-devel python3-setuptools
BuildRequires:  python3-sphinx
BuildRequires:  python3-nose
%global python_version_suffix -3
%else
BuildRequires:  python2-nose
%if 0%{?fedora}
BuildRequires:  python2-sphinx
%else
BuildRequires:  python-sphinx
%endif
%endif
BuildRequires:  ant-junit maven-local
BuildRequires:  sonatype-oss-parent
# Fedora unbundles hamcrest from junit
%if 0%{?fedora}
BuildRequires:  hamcrest
%endif
Requires:       %{name}-java = %{version}-%{release}
%description
Py4J enables Python programs running in a Python interpreter
to dynamically access Java objects in a Java Virtual Machine.
Methods are called as if the Java objects resided in the Python
interpreter and Java collections can be accessed through standard
Python collection methods.
Py4J also enables Java programs to call back Python objects.
Py4J is distributed under the BSD license.
%package -n python2-%{name}
Summary:        Py4J enables Python2 programs to dynamically access arbitrary Java objects
Requires:       python2
Requires:       %{name}-java = %{version}-%{release}
%{?python_provide:%python_provide python2-%{name}}
%description -n python2-%{name}
Py4J enables Python2 programs running in a Python interpreter
to dynamically access Java objects in a Java Virtual Machine.
Methods are called as if the Java objects resided in the Python
interpreter and Java collections can be accessed through standard
Python collection methods.
Py4J also enables Java programs to call back Python objects.
Py4J is distributed under the BSD license.
This package is for usage with Python2 only.
%if %{with python3} 
%package -n python3-%{name}
Summary:        Py4J enables Python3 programs to dynamically access arbitrary Java objects
Requires:       python3
Requires:       %{name}-java = %{version}-%{release}
%{?python_provide:%python_provide python3-%{name}}
%description -n python3-%{name}
Py4J enables Python3 programs running in a Python interpreter
to dynamically access Java objects in a Java Virtual Machine.
Methods are called as if the Java objects resided in the Python
interpreter and Java collections can be accessed through standard
Python collection methods.
Py4J also enables Java programs to call back Python objects.
Py4J is distributed under the BSD license.
This package is for usage with Python3 only.
%endif
%package java
Summary:        Py4J Java Library
%description java
%{summary}.
%if %{with javadoc}
%package javadoc
Summary:        Javadoc files for %{name}
%description javadoc
%{summary}.
%endif
%package doc
Summary:        Documentation files for %{name}
%description doc
%{summary}.
%prep
%setup -qn%{name}-%{version}
# remove unneeded stuff
rm -r setup.py
find . -name \*.jar -print -delete
# build jar without version in name
sed -i -r "s|(version=).*|\1|" %{name}-java/ant.properties
sed -i "s|'.*'|''|" %{name}-python/src/%{name}/version.py
# set default java version to avoid some warnings
%if 0%{?fedora}
sed -i "s|1\.6|1.8|g" %{name}-java/build.xml
%else
# java 7 is default for EPEL
sed -i "s|1\.6|1.7|g" %{name}-java/build.xml
%endif
# enable encoding in javadoc
sed -i -r \
 's|<javadoc|\0 encoding="%{encoding}" charset="%{encoding}" docencoding="%{encoding}"|' \
 %{name}-java/build.xml
# unbundle junit (and hamcrest)
%if 0%{?fedora}
%patch0 -p0
%endif
sed -i "s|junit-.*\.jar|$(build-classpath junit)|g" %{name}-java/ant.properties
sed -i -r "s|(<javadoc.*classpath=)\"\"|\1\"$(build-classpath junit)\"|" %{name}-java/build.xml
# unbundle MiGBase64, https://fedorahosted.org/fpc/ticket/537
rm %{name}-java/src/main/java/%{name}/Base64.java
rm %{name}-java/src/test/java/%{name}/Base64Test.java
%if 0%{?fedora} || 0%{?rhel} >= 7
%patch1 -p1
%else
%patch2 -p1
%endif
%if %{with test_java}
# prevent wrong exception warnings
sed -i 's|FINEST|OFF|' %{name}-java/logging.properties
sed -i 's|<junit.*>|\0 <jvmarg value="-Djava.util.logging.config.file=%{name}-java/logging.properties" />|' \
 %{name}-java/build.xml
# remove duplicated summaries
sed -i 's|printsummary="on"||' %{name}-java/build.xml
%endif
%if %{with test_python}
sed -i "s|%{name}\.tests||" %{name}-python/setup.py
# prevent wrong exception warnings
sed -i "s|instance.gateway.shutdown()|if 'gateway' in dir(instance): \0|" \
 %{name}-python/src/%{name}/tests/java_gateway_test.py
# FIXME tls tends to hang, maybe background application too slow?
rm %{name}-python/src/py4j/tests/java_tls_test.py
%endif
# install jar later with maven
sed -i "/data_files/d" %{name}-python/setup.py
# build separately for python3 in special subfolder
%if %{with python3}
cp -a %{name}-python %{name}-python3
sed -i -r -e 's|(executable=")python|\1%{__python3}|g' \
 -e 's|(executable="nosetests)|\1%{python_version_suffix}|g' \
 -e 's|%{name}-python|%{name}-python3|g' \
 %{name}-java/build.xml
%endif
%build
pushd %{name}-java
ant jar
%if %{with javadoc}
ant javadoc
%endif
popd
pushd %{name}-python
%py2_build
popd
%if %{with python3}
pushd %{name}-python3
%py3_build
popd
%endif
%if %{with html}
# FIXME autodoc does not work for current tarball
sed -i "s|.sphinx.ext.autodoc.* | |" %{name}-web/conf.py
# sphinx is restricted in epel
%if 0%{?fedora}
sphinx-build%{python_version_suffix} %{?_smp_mflags} -a -b html -v -T %{name}-web html
%else
sphinx-build %{name}-web html
%endif
# FIXME do we need following files in release? not sure...
rm -r html/.buildinfo html/.doctrees
find html -name \*.js -print -delete
%endif
%install
pushd %{name}-python
%py2_install
popd
%if %{with python3}
pushd %{name}-python3
%py3_install
popd
%endif
%mvn_artifact %{name}-java/pom.xml %{name}-java/%{name}.jar
%mvn_install -J %{name}-java/javadoc
mkdir -p %{buildroot}%{_datadir}/%{name}
ln -sf %{_javadir}/%{name}/%{name}.jar %{buildroot}%{_datadir}/%{name}
%check
alias comment=true
%if %{with test_java}
comment '----- check test_java -----'
# do build tests only, see above in build for disabled test
#sed -i -r "s|no(test)|\1|" %{name}-java/build.xml
# test go!
ant -f %{name}-java/build.xml java-test
%endif
%if %{with test_python}
comment '----- check test_python -----'
# important: build java tests before, otherwise will not work
sed -i -r "s|no(test)|\1|" %{name}-java/build.xml
ant -f %{name}-java/build.xml build
# FIXME tests fail when in parallel, maybe too few resources?
#export NOSE_PROCESSES=-1
# test go!
ant -f %{name}-java/build.xml python-test 2>&1 |tee python-test.log
# be sure we ran with python3
%if %{with python3}
if [ ! $(grep -c '\[exec\] Python 3' python-test.log) ]; then
 comment 'error: wrong python version!'
 exit 1
fi
%endif
%endif
%files -n python2-%{name}
%license %{name}-python/LICENSE.txt
%doc README.rst
%{python2_sitelib}/*.egg-info
%{python2_sitelib}/%{name}/
%if %{with python3}
%files -n python3-%{name}
%license %{name}-python/LICENSE.txt
%doc README.rst
%{python3_sitelib}/*.egg-info
%{python3_sitelib}/%{name}/
%endif
%files java -f .mfiles
%license %{name}-java/LICENSE.txt
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*.jar
%files doc
%license %{name}-web/LICENSE.txt
%doc %{name}-web/TODO
%if %{with html}
%doc html/
%endif
%if %{with javadoc}
%files javadoc -f .mfiles-javadoc
%license %{name}-java/LICENSE.txt
%endif
%changelog
* Tue Sep 19 2017 Raphael Groner <projects.rg@smart.ms> - 0.10.6-1
- new version
* Mon Sep 18 2017 Raphael Groner <projects.rg@smart.ms> - 0.10.5-3
- enforce explicitly python3 for sphinx and nosetests
- add more debugging for check
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Sat Jun 10 2017 Raphael Groner <projects.rg@smart.ms> - 0.10.5-1
- bump version, rhbz#1385653
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 0.10.4-2
- Rebuild for Python 3.6
* Sat Dec 10 2016 Raphael Groner <projects.rg@smart.ms> - 0.10.4-1
- new version
* Thu Sep 01 2016 Raphael Groner <projects.rg@smart.ms> - 0.10.3-1
- new version
- add python3 subpackage
- add python_provide macro
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.10.2.1-2
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
* Sun Jul 10 2016 Raphael Groner <projects.rg@smart.ms> - 0.10.2.1-1
- new version
* Wed May 11 2016 Raphael Groner <projects.rg@smart.ms> - 0.10.1-1
- new version
* Thu Apr 21 2016 Raphael Groner <projects.rg@smart.ms> - 0.10-1
- bump to v0.10, rhbz#1327918
* Fri Mar 25 2016 Raphael Groner <projects.rg@smart.ms> - 0.9.2-1
- new version
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Tue Jan 12 2016 Fedora Release Monitoring <release-monitoring@fedoraproject.org> - 0.9.1-1
- Update to 0.9.1 (#1297698)
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
* Thu Nov 05 2015 Raphael Groner <projects.rg@smart.ms> - 0.9-1
- official upstream release
* Tue Jul 21 2015 Raphael Groner <projects.rg@smart.ms> - 0.9-0.5.pre.20150720git1cda77a
- new snapshot of upstream
- run tests with python3
- use sed with regions
* Sat May 23 2015 Raphael Groner <projects.rg@smart.ms> - 0.9-0.4.pre.20150503gitd9a950d
- unbundle MiGBase64
- improve checks
- improve sphinx html
- add build conditionals
* Wed May 06 2015 Raphael Groner <projects.rg@smart.ms> - 0.9-0.3.pre.20150503gitd9a950d
- new snapshot of upstream
- remove some obsolete files
- fix Summary and URL
- fix rpmlint warnings
* Thu Apr 30 2015 Raphael Groner <projects.rg@smart.ms> - 0.9-0.2.pre.20141101git9a8ab93
- fix pathes and maven
- add python-sphinx to generate additional documentation
* Mon Apr 27 2015 Raphael Groner <projects.rg@smart.ms> - 0.9-0.1.pre.20141101git9a8ab93
- initial