#1 Python fixes
Closed 5 years ago by raphgro. Opened 5 years ago by churchyard.
rpms/ churchyard/python-jnius python_fixes  into  master

file modified
+22 -41
@@ -21,10 +21,12 @@ 

  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 @@ 

  %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 @@ 

  %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 @@ 

  

  

  %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}

  • 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

rebased onto 585daf5

5 years ago

Thanks, locally applied this patch. Tests are working now with a (partly) patch from upstream.

Pull-Request has been closed by raphgro

5 years ago