File jython.spec of Package jython

#
# spec file for package jython
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%{expand: %%define pyver %(python -c 'import sys;print(sys.version[0:3])')}

%global cpython_version    %{pyver}
%global pyxml_version      0.8.3
%global svn_tag            Release_2_2_1
%global _python_bytecompile_errors_terminate_build 0

Name:           jython
Version:        2.2.1
Release:        0
Summary:        A Java implementation of the Python language
License:        Python-2.0 and Apache-2.0
Group:          Development/Languages/Python
Url:            http://www.jython.org/
# Use the included fetch-jython.sh script to generate the source drop
# for jython 2.2.1
# sh fetch-jython.sh \
#   jython https://jython.svn.sourceforge.net/svnroot Release_2_2_1
#
Source0:        %{name}-fetched-src-%{svn_tag}.tar.bz2
Source2:        fetch-%{name}.sh
Patch0:         %{name}-cachedir.patch
# Make javadoc and copy-full tasks not depend upon "full-build"
# Also, copy python's license from source directory and not
# ${python.home}
Patch1:         %{name}-nofullbuildpath.patch
Requires:       jakarta-oro
Requires:       javapackages-tools
Requires:       libreadline-java >= 0.8.0-16
Requires:       python >= %{cpython_version}
Requires:       servletapi5
Recommends:     mysql-connector-java
Requires:       java >= 1.6.0
BuildRequires:  ant
BuildRequires:  ht2html
BuildRequires:  jakarta-oro
BuildRequires:  java-devel >= 1.6.0
BuildRequires:  libreadline-java >= 0.8.0-16
BuildRequires:  mysql-connector-java
BuildRequires:  python >= %{cpython_version}
BuildRequires:  pyxml >= %{pyxml_version}
BuildRequires:  servletapi5
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
Jython is an implementation of the high-level, dynamic, object-oriented
language Python seamlessly integrated with the Java platform. The
predecessor to Jython, JPython, is certified as 100% Pure Java. Jython
is freely available for both commercial and noncommercial use and is
distributed with source code. Jython is complementary to Java and is
especially suited for the following tasks: Embedded scripting--Java
programmers can add the Jython libraries to their system to allow end
users to write simple or complicated scripts that add functionality to
the application. Interactive experimentation--Jython provides an
interactive interpreter that can be used to interact with Java packages
or with running Java applications. This allows programmers to
experiment and debug any Java system using Jython. Rapid application
development--Python programs are typically 2-10X shorter than the
equivalent Java program. This translates directly to increased
programmer productivity. The seamless interaction between Python and
Java allows developers to freely mix the two languages both during
development and in shipping products.

%package manual
Summary:        Manual for jython
Group:          Development/Libraries/Java

%description manual
This package contains the manual for Jython.

Jython is an implementation of the high-level, dynamic, object-oriented
language Python seamlessly integrated with the Java platform. The
predecessor to Jython, JPython, is certified as 100% Pure Java. Jython
is freely available for both commercial and non-commercial use and is
distributed with source code. Jython is complementary to Java and is
especially suited for the following tasks: Embedded scripting - Java
programmers can add the Jython libraries to their system to allow end
users to write simple or complicated scripts that add functionality to
the application. Interactive experimentation - Jython provides an
interactive interpreter that can be used to interact with Java packages
or with running Java applications. This allows programmers to
experiment and debug any Java system using Jython. Rapid application
development - Python programs are typically 2-10X shorter than the
equivalent Java program. This translates directly to increased
programmer productivity. The seamless interaction between Python and
Java allows developers to freely mix the two languages both during
development and in shipping products.



%package javadoc
Summary:        Javadoc for jython
Group:          Development/Libraries/Java

%description javadoc
This package contains the javadoc documentation for jython.

Jython is an implementation of the high-level, dynamic, object-oriented
language Python seamlessly integrated with the Java platform. The
predecessor to Jython, JPython, is certified as 100% Pure Java. Jython
is freely available for both commercial and non-commercial use and is
distributed with source code. Jython is complementary to Java and is
especially suited for the following tasks: Embedded scripting - Java
programmers can add the Jython libraries to their system to allow end
users to write simple or complicated scripts that add functionality to
the application. Interactive experimentation - Jython provides an
interactive interpreter that can be used to interact with Java packages
or with running Java applications. This allows programmers to
experiment and debug any Java system using Jython. Rapid application
development - Python programs are typically 2-10X shorter than the
equivalent Java program. This translates directly to increased
programmer productivity. The seamless interaction between Python and
Java allows developers to freely mix the two languages both during
development and in shipping products.



%package demo
Summary:        Demonstration and samples for jython
Group:          Development/Libraries/Java
Requires:       %{name} = %{version}-%{release}

%description demo
This package contains demonstration and sample files for Jython.

Jython is an implementation of the high-level, dynamic, object-oriented
language Python seamlessly integrated with the Java platform. The
predecessor to Jython, JPython, is certified as 100% Pure Java. Jython
is freely available for both commercial and non-commercial use and is
distributed with source code. Jython is complementary to Java and is
especially suited for the following tasks: Embedded scripting - Java
programmers can add the Jython libraries to their system to allow end
users to write simple or complicated scripts that add functionality to
the application. Interactive experimentation - Jython provides an
interactive interpreter that can be used to interact with Java packages
or with running Java applications. This allows programmers to
experiment and debug any Java system using Jython. Rapid application
development - Python programs are typically 2-10X shorter than the
equivalent Java program. This translates directly to increased
programmer productivity. The seamless interaction between Python and
Java allows developers to freely mix the two languages both during
development and in shipping products.



%prep
%setup -q -n %{name}-svn-%{svn_tag}
%patch0 -p1
%patch1 -p1

%build
export CLASSPATH=$(build-classpath mysql-connector-java oro servlet)
# FIXME: fix jpackage-utils to handle multilib correctly
export CLASSPATH=$CLASSPATH:%{_libdir}/libreadline-java/libreadline-java.jar

rm -rf org/apache
perl -p -i -e 's|execon|apply|g' build.xml

ant \
  -Dpython.home=%{_bindir} \
  -Dht2html.dir=%{_datadir}/ht2html \
  -Dpython.lib=./CPythonLib \
  -Dpython.exe=%{_bindir}/python \
  -DPyXmlHome=%{_libdir}/python%pyver \
  -Dtargetver=1.3 \
  copy-dist

# remove #! from python files
pushd dist
  for f in `find . -name '*.py'`
  do
    sed --in-place  "s:#!\s*/usr.*::" $f
  done
popd

%install
# jar
install -d -m 755 $RPM_BUILD_ROOT%{_javadir}
install -m 644 dist/%{name}.jar \
  $RPM_BUILD_ROOT%{_javadir}/%{name}.jar
# javadoc
install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}
cp -pr dist/Doc/javadoc/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}
# data
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/%{name}
# these are not supposed to be distributed
find dist/Lib -type d -name test | xargs rm -rf

cp -pr dist/Lib $RPM_BUILD_ROOT%{_datadir}/%{name}
cp -pr dist/Tools $RPM_BUILD_ROOT%{_datadir}/%{name}
# demo
cp -pr dist/Demo $RPM_BUILD_ROOT%{_datadir}/%{name}
# manual
rm -rf dist/Doc/javadoc
mv dist/Doc %{name}-manual-%{version}

# registry
install -m 644 registry $RPM_BUILD_ROOT%{_datadir}/%{name}
# scripts
install -d $RPM_BUILD_ROOT%{_bindir}

cat > $RPM_BUILD_ROOT%{_bindir}/%{name} << EOF
#!/bin/sh
#
# %{name} script
# JPackage Project (http://jpackage.sourceforge.net)
# 
# Source functions library
. %{_datadir}/java-utils/java-functions

# Source system prefs
if [ -f %{_sysconfdir}/%{name}.conf ] ; then
  . %{_sysconfdir}/%{name}.conf
fi

# Source user prefs
if [ -f \$HOME/.%{name}rc ] ; then
  . \$HOME/.%{name}rc
fi

# Arch-specific location of dependency
case \$(uname -m) in
   x86_64 | ia64 | s390x | ppc64 | sparc64 )
      JYTHONLIBDIR="/usr/lib64" ;;
   * )
      JYTHONLIBDIR="/usr/lib" ;;
esac

# Configuration
MAIN_CLASS=org.python.util.%{name}
BASE_FLAGS=-Dpython.home=%{_datadir}/%{name}
BASE_JARS="%{name} oro servlet mysql-connector-java"

BASE_FLAGS="\$BASE_FLAGS -Dpython.console=org.python.util.ReadlineConsole"
BASE_FLAGS="\$BASE_FLAGS -Djava.library.path=\$JYTHONLIBDIR/libreadline-java"
BASE_FLAGS="\$BASE_FLAGS -Dpython.console.readlinelib=Editline"

# Set parameters
set_jvm
CLASSPATH=$CLASSPATH:\$JYTHONLIBDIR/libreadline-java/libreadline-java.jar
set_classpath \$BASE_JARS
set_flags \$BASE_FLAGS
set_options \$BASE_OPTIONS

# Let's start
run "\$@"
EOF

cat > $RPM_BUILD_ROOT%{_bindir}/%{name}c << EOF
#!/bin/sh
#
# %{name}c script
# JPackage Project (http://jpackage.sourceforge.net)

%{_bindir}/%{name} %{_datadir}/%{name}/Tools/%{name}c/%{name}c.py "\$@"
EOF

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc ACKNOWLEDGMENTS NEWS LICENSE.txt README.txt
%attr(0755,root,root) %{_bindir}/%{name}
%attr(0755,root,root) %{_bindir}/%{name}c
%{_javadir}/*
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/Lib
%{_datadir}/%{name}/Tools
%{_datadir}/%{name}/registry

%files javadoc
%defattr(-,root,root)
%doc LICENSE.txt
%{_javadocdir}/%{name}

%files manual
%defattr(-,root,root)
%doc LICENSE.txt README.txt
%doc %{name}-manual-%{version}

%files demo
%defattr(-,root,root)
%doc ACKNOWLEDGMENTS NEWS LICENSE.txt README.txt
%{_datadir}/%{name}/Demo

%changelog
openSUSE Build Service is sponsored by