%global srcurl https://github.com/originell/%{name}
%global sum Full access for Python programs to Java class libraries
%if 0%{?fedora}
%bcond_without python3
%bcond_without doc
%else
%if 0%{?rhel} >= 7
%bcond_without python3
# FIXME epel7: mockbuild fails for sphinx_rtd_theme
%bcond_with doc
%endif
%endif
%bcond_without python2
Name: jpype
Version: 0.6.3
Release: 1%{?dist}
Summary: %{sum}
# Some files come from JDK (jni_md.h) and Python (capsulethunk.h)
License: ASL 2.0 and GPLv2 and Python
URL: http://%{name}.sf.net
Source0: %{srcurl}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# issue #331, support Python 3.7 with PEP 432, rebased patch
Patch0: %{name}-0.6.3-python37-pep432.patch
BuildRequires: python-rpm-macros
%if %{with python3}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools
%endif
%if %{with python2}
BuildRequires: python2-devel
BuildRequires: python2-setuptools
BuildRequires: python2-mock
%endif
%if %{with doc}
%if %{with python3}
BuildRequires: python3-sphinx
BuildRequires: python3-sphinx_rtd_theme
%else # python3-sphinx is not available, so fall back to default python
BuildRequires: python2-sphinx
BuildRequires: python2-sphinx_rtd_theme
BuildRequires: fontawesome-fonts-web
%endif
%else
Provides: %{name}-doc
Obsoletes: %{name}-doc < %{version}-%{release}
%endif
BuildRequires: java-devel ant
%description
JPype is an effort to allow python programs full access to
java class libraries. This is achieved not through
re-implementing Python, as Jython/JPython has done, but rather
through interfacing at the native level in both Virtual Machines.
%if %{with python2}
%package -n python2-%{name}
Summary: %{sum}
%{?python_provide:%python_provide python2-%{name}}
%description -n python2-%{name}
JPype is an effort to allow python programs full access to
java class libraries. This is achieved not through
re-implementing Python, as Jython/JPython has done, but rather
through interfacing at the native level in both Virtual Machines.
This is the package with support for Python2.
%endif # python2
%if %{with python3}
%package -n python%{python3_pkgversion}-%{name}
Summary: %{sum}
%{?python_provide:%python_provide python%{python3_pkgversion}-%{name}}
%description -n python%{python3_pkgversion}-%{name}
JPype is an effort to allow python programs full access to
java class libraries. This is achieved not through
re-implementing Python, as Jython/JPython has done, but rather
through interfacing at the native level in both Virtual Machines.
This is the package with support for Python3.
%endif # python3
%package doc
Summary: Documentation files for %{name}
BuildArch: noarch
Requires: js-jquery
%description doc
%{summary}.
%prep
%autosetup -p1 -n%{name}-%{version}
# sanify line delimiters
find . -name '*.py' -or -name '*.java' -or -name '*.TXT' \
-or -name '*.sh' -or -name '*.xml' -or -name '*.js' \
|xargs sed -i "s|\r||g"
# FIXME tests fail to bytecompile with Python 3, https://github.com/originell/jpype/issues/153
#find test -name \*.py |xargs sed -i -r "s|(print) (.*)|\1(\2)|g"
# include test files into bytecompiling for distribution
cp -pr test/%{name}test .
cp -pr test/testsuite.py %{name}test
sed -i -r -e "s|packages=.|\0 '%{name}test',|" setup.py
# classes folder will exist later after build and installed into tests folder
sed -i -r "s|classes|%{name}test/\0|" %{name}test/common.py
# omit import for html generation
sed -i -e "/import %{name}/d" -e "s|%{name}.__version__|'%{version}'|g" doc/conf.py
%build
%if %{with python2}
%py2_build
%endif
%if %{with python3}
%py3_build
%endif
# build test classes
pushd test
ant compile
popd
%if %{with doc}
%if 0%{?fedora} && %{with python3}
# generate html documentation
sphinx-build-3 -d doctrees doc html
%else
# debug
ls %{python2_sitearch}/sphinx*
ls %{python3_sitearch}/sphinx*
sphinx-build -d doctrees doc html
%endif
rm html/.buildinfo
# unbundle jquery, https://fedoraproject.org/wiki/Changes/jQuery
ln -fs %{_jsdir}/jquery/2/jquery.min.js html/_static/jquery.js
%endif
%install
%if %{with python2}
%py2_install
cp -pr test/classes %{buildroot}%{python2_sitearch}/%{name}test
%endif
%if %{with python3}
%py3_install
cp -pr test/classes %{buildroot}%{python3_sitearch}/%{name}test
%endif
find %{buildroot} -name '*.so' |xargs chmod 0755
%check
# fake module import
export PYTHONPATH=..
%if %{with python2}
pushd %{buildroot}%{python2_sitearch}/%{name}test
%{__python2} testsuite.py
%endif
%if %{with python3}
pushd %{buildroot}%{python3_sitearch}/%{name}test
# dirty hack: replace mock with unittest.mock
sed -i -r "s|import mock|from unittest \0|" jvmfinder.py
%{__python3} testsuite.py
%endif
%if %{with python2}
%files -n python2-%{name}
%license LICENSE
%doc AUTHORS.rst README.rst
%{python2_sitearch}/*
%endif
%if %{with python3}
%files -n python%{python3_pkgversion}-%{name}
%license LICENSE
%doc AUTHORS.rst README.rst
%{python3_sitearch}/*
%endif
%if %{with doc}
%files doc
%license LICENSE
%doc examples/ html/
%endif
%changelog
* Thu Jun 21 2018 Raphael Groner <projects.rg@smart.ms> - 0.6.3-1
- new version
- add patch for upcoming python 3.7
- drop compatibility for retired branches
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.6.2-5
- Rebuilt for Python 3.7
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Wed Feb 07 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.6.2-3
- Update Python 2 dependency declarations to new packaging standards
(See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)
* Wed Aug 16 2017 Raphael Groner <projects.rg@smart.ms> - 0.6.2-2
- revert accidently disabled python2
* Tue Aug 15 2017 Raphael Groner <projects.rg@smart.ms> - 0.6.2-1
- new version
- [epel7] enable python3, disable sphinx due to strange bug
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 0.6.1-5
- Rebuild for Python 3.6
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.1-4
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.1-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
* Thu Sep 10 2015 Raphael Groner <projects.rg@smart.ms> - 0.6.1-1
- new upstream release v0.6.1
- make tests work with python3
- deprecation of jpype-py3
- split subpackages for python2 and 3
- use python build and install macros
- ease html generation
- ship _static documentation files
- unbundle jquery
- ship tests folder as an import option w/o execution bits
- restrict documentation to only some .rst files
* Tue Jul 21 2015 Raphael Groner <projects.rg@smart.ms> - 0.6.0-2
- include patch of proxy argument issue
* Tue Jun 23 2015 Raphael Groner <projects.rg@smart.ms> - 0.6.0-1
- based on originally jpype-py3.spec
- official jpype 0.6.0 with python3
- more documentation in subpackage
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0-0.3.20150202gitca6fc96
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Thu Apr 23 2015 Raphael Groner <projects.rg@smart.ms> - 0-0.2.20150202gitca6fc96
- add GPLv2 for bundled source files
- remove wrong sitearch macro
- make tests work
* Thu Apr 02 2015 Raphael Groner <projects.rg@smart.ms> - 0-0.1.20150202gitca6fc96
- initial