From 585daf5204fdfb5408970f23c6f5ef8abf4f77d8 Mon Sep 17 00:00:00 2001 From: Miro HronĨok Date: Jul 17 2018 23:15:09 +0000 Subject: Python fixes: * avoid Makefile * it calls "python" * it builds Python extenstion inplace * require and buildrequire six, as it is used in the production code * stop creating separete py2 and py3 dirs * it is not needed * just make sure .c file(s) get cythonized again for the latter build * run tests on installed modules, not on the inplace built ones * note that there is one more failing test on py3 --- diff --git a/python-jnius.spec b/python-jnius.spec index f61884a..1e5a8f5 100644 --- a/python-jnius.spec +++ b/python-jnius.spec @@ -21,10 +21,12 @@ BuildRequires: gcc BuildRequires: python2-devel BuildRequires: python2-Cython BuildRequires: python2-nose +BuildRequires: python2-six %if %{with python3} BuildRequires: python3-devel BuildRequires: python3-Cython BuildRequires: python3-nose +BuildRequires: python3-six %endif # with python3 BuildRequires: ant BuildRequires: java-devel @@ -41,6 +43,7 @@ ExcludeArch: i686 ppc64 ppc64le s390x armv7hl aarch64 %package -n python2-%{srcname} Summary: %{sum} Requires: java-headless +Requires: python2-six %{?python_provide:%python_provide python2-%{srcname}} Provides: python2-%{modname} @@ -51,6 +54,7 @@ Provides: python2-%{modname} %package -n python3-%{srcname} Summary: %{sum} Requires: java-headless +Requires: python3-six %{?python_provide:%python_provide python3-%{srcname}} Provides: python3-%{modname} @@ -68,68 +72,45 @@ BuildArch: noarch %prep -%autosetup -c -mv %{srcname}-%{version} python2 -pushd python2 -# don't confuse rpmbuild -mv -t.. LICENSE *.md docs -# use Fedora policy -find -name Makefile |xargs \ - sed -i -r -e 's:\$(MAKE):\0 %{_smp_mflags}:g' -e /NOSETESTS=/d -popd - -%if %{with python3} -cp -a python2 python3 -%endif # with python3 - +%autosetup -n %{srcname}-%{version} %build -pushd python2 -CFLAGS="$RPM_OPT_FLAGS" %py2_build -make -popd +%py2_build %if %{with python3} -pushd python3 -export PYTHON3=1 -CFLAGS="$RPM_OPT_FLAGS" %py3_build -make -popd -%endif # with python3 +# force regenerate (cythonize) as there are python version dependent parts +rm %{modname}/*.c +%py3_build +%endif make -C docs html +# build java classes for tests +# there is also Makefile, but it calls python setup.py build_ext --inplace +# together with ant, so we don't use it not to build python bits twice +ant all -%install -%if %{with python3} -pushd python3 -%py3_install -popd -%endif # with python3 -pushd python2 +%install %py2_install -popd - +%{?with_python3:%py3_install} %check -export MAKE='make %{_smp_mflags}' +pushd tests +export CLASSPATH=../build/test-classes:../build/classes export JAVA_HOME=%{_prefix}/lib/jvm/java -pushd python2 -NOSETESTS=nosetests make tests -popd +PYTHONPATH=%{buildroot}%{python2_sitearch} %{__python2} -m nose -v %if %{with python3} -pushd python3 -export PYTHON3=1 # FIXME some tests fail with python3: # https://github.com/kivy/pyjnius/issues/305 # test_multiple_methods +# test_instances_methods_params # test_create_bytearray # test_stack -NOSETESTS=nosetests-3 make tests ||: -popd +PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} -m nose -v ||: %endif +popd %files -n python2-%{srcname}