91577cb
%bcond_with python2
91577cb
91577cb
%global srcname jep
91577cb
91577cb
%global desc \
91577cb
Java Embedded Python\
91577cb
JEP embeds CPython in Java through JNI and is safe to use in a\
91577cb
heavily threaded environment.\
91577cb
\
91577cb
Some benefits of embedding CPython in a JVM:\
91577cb
    Using the native Python interpreter may be much faster than\
91577cb
    alternatives.\
91577cb
    Python is mature, well supported, and well documented.\
91577cb
    Access to high quality Python modules, both native CPython\
91577cb
    extensions and Python-based.\
91577cb
    Compilers and assorted Python tools are as mature as the\
91577cb
    language.\
91577cb
    Python is an interpreted language, enabling scripting of\
91577cb
    established Java code without requiring recompilation.\
91577cb
    Both Java and Python are cross platform, enabling deployment\
91577cb
    to different operating system.
91577cb
91577cb
Name:           python-%{srcname}
91577cb
Version:        3.7.0
91577cb
Release:        2%{?dist}
91577cb
Summary:        Embed Python in Java
91577cb
91577cb
License:        zlib
91577cb
URL:            https://github.com/ninia/%{srcname}
91577cb
Source0:        %{url}/archive/v%{version}.tar.gz
91577cb
91577cb
%if %{with python2}
91577cb
BuildRequires:  python2-devel
91577cb
BuildRequires:  python2-numpy
91577cb
%endif # with python2
91577cb
BuildRequires:  python3-devel
91577cb
BuildRequires:  python3-numpy
91577cb
91577cb
BuildRequires:  java-devel
91577cb
91577cb
Requires:       java-headless
91577cb
91577cb
%description %desc
91577cb
91577cb
%package     -n python2-%{srcname}
91577cb
Summary:        Embed Python in Java
91577cb
%{?python_provide:%python_provide python2-%{srcname}}
91577cb
91577cb
%description -n python2-%{srcname} %desc
91577cb
91577cb
%package     -n python3-%{srcname}
91577cb
Summary:        Embed Python in Java
91577cb
%{?python_provide:%python_provide python3-%{srcname}}
91577cb
91577cb
%description -n python3-%{srcname} %desc
91577cb
91577cb
%package javadoc
91577cb
Summary:        Javadoc files for %{name}
91577cb
BuildArch:      noarch
91577cb
91577cb
%description javadoc
91577cb
%{summary}.
91577cb
91577cb
91577cb
%prep
91577cb
%autosetup -c
91577cb
find . -name \*.jar -print -delete
91577cb
91577cb
mv %{srcname}-%{version} python3
91577cb
# don't confuse rpmbuild
91577cb
(pushd python3 ; mv -t.. LICENSE AUTHORS release_notes javadoc )
91577cb
# be more verbose about tests, FIXME ugly hack!
91577cb
sed -i -r 's:TextTestRunner\(:\0verbosity=2:' python3/tests/runtests.py
91577cb
91577cb
%if %{with python2}
91577cb
cp -a python3 python2
91577cb
%endif # with python2
91577cb
91577cb
91577cb
%build
91577cb
export JAVA_HOME=%{_prefix}/lib/jvm/java
91577cb
%if %{with python2}
91577cb
pushd python2
91577cb
CFLAGS="$RPM_OPT_FLAGS" %py2_build
91577cb
popd
91577cb
%endif # with python2
91577cb
91577cb
pushd python3
91577cb
CFLAGS="$RPM_OPT_FLAGS" %py3_build
91577cb
popd
91577cb
91577cb
91577cb
%install
91577cb
export JAVA_HOME=%{_prefix}/lib/jvm/java
91577cb
pushd python3
91577cb
%py3_install
91577cb
popd
91577cb
91577cb
%if %{with python2}
91577cb
pushd python2
91577cb
%py2_install
91577cb
popd
91577cb
%endif
91577cb
91577cb
# install javadoc
91577cb
install -dm755 %{buildroot}%{_javadocdir}/%{name}
91577cb
cp -pr javadoc/* %{buildroot}%{_javadocdir}/%{name}
91577cb
91577cb
91577cb
%check
91577cb
export JAVA_HOME=%{_prefix}/lib/jvm/java
91577cb
%if %{with python2}
91577cb
pushd python2
91577cb
%{__python2} setup.py test
91577cb
popd
91577cb
%endif
91577cb
91577cb
pushd python3
91577cb
%{__python3} setup.py test
91577cb
popd
91577cb
91577cb
91577cb
%if %{with python2}
91577cb
%files -n python2-%{srcname}
91577cb
%license LICENSE
91577cb
%doc python2/README.rst
91577cb
%doc AUTHORS release_notes/
91577cb
%{python2_sitearch}/*
91577cb
%endif
91577cb
91577cb
%files -n python3-%{srcname}
91577cb
%license LICENSE
91577cb
%doc python3/README.rst
91577cb
%doc AUTHORS release_notes/
91577cb
%{python3_sitearch}/*
91577cb
%{_bindir}/%{srcname}
91577cb
91577cb
%files javadoc
91577cb
%license LICENSE
91577cb
%{_javadocdir}/%{name}/
91577cb
91577cb
91577cb
%changelog
91577cb
* Sat Sep 02 2017 Raphael Groner <projects.rg@smart.ms> - 3.7.0-2
91577cb
- drop precompiled jar files
91577cb
- be more verbose about tests
91577cb
- add javadoc subpackage
91577cb
- move interpreter script into python3 subpackage
91577cb
- add release_notes folder to documentation
91577cb
- handle readme file properly
91577cb
91577cb
* Tue Aug 15 2017 Raphael Groner <projects.rg@smart.ms> - 3.7.0-1
91577cb
- initial