14
0

Accepting request 848670 from home:jayvdb:py-submit

Python android tools

OBS-URL: https://build.opensuse.org/request/show/848670
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-for-android?expand=0&rev=1
This commit is contained in:
2020-11-19 15:27:18 +00:00
committed by Git OBS Bridge
commit e6a74228ca
7 changed files with 273 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

110
arch-tests.patch Normal file
View File

@@ -0,0 +1,110 @@
commit 02df176254d687e073243fbb8d9264412b423abd
Author: John Vandenberg <jayvdb@gmail.com>
Date: Sun Nov 15 14:49:34 2020 +0700
Support tests on varied arch
diff --git a/tests/recipes/test_icu.py b/tests/recipes/test_icu.py
index 00cfbdbb..39c29047 100644
--- a/tests/recipes/test_icu.py
+++ b/tests/recipes/test_icu.py
@@ -1,10 +1,10 @@
import os
import unittest
from unittest import mock
-from platform import system
from tests.recipes.recipe_ctx import RecipeCtx
from pythonforandroid.recipes.icu import ICURecipe
+from pythonforandroid.util import build_platform
class TestIcuRecipe(RecipeCtx, unittest.TestCase):
@@ -48,7 +48,7 @@ class TestIcuRecipe(RecipeCtx, unittest.TestCase):
):
mock_find_executable.return_value = os.path.join(
self.ctx._ndk_dir,
- f"toolchains/llvm/prebuilt/{system().lower()}-x86_64/bin/clang",
+ f"toolchains/llvm/prebuilt/{build_platform}/bin/clang",
)
mock_archs_glob.return_value = [
os.path.join(self.ctx._ndk_dir, "toolchains", "llvm")
diff --git a/tests/test_archs.py b/tests/test_archs.py
index 61887e0e..62ea711d 100644
--- a/tests/test_archs.py
+++ b/tests/test_archs.py
@@ -8,7 +8,7 @@ from pythonforandroid.bootstrap import Bootstrap
from pythonforandroid.distribution import Distribution
from pythonforandroid.recipe import Recipe
from pythonforandroid.build import Context
-from pythonforandroid.util import BuildInterruptingException
+from pythonforandroid.util import BuildInterruptingException, build_platform
from pythonforandroid.archs import (
Arch,
ArchARM,
@@ -72,7 +72,7 @@ class ArchSetUpBaseClass(object):
# should be the same for all the tests (no more gcc compiler)
self.expected_compiler = (
f"/opt/android/android-ndk/toolchains/"
- f"llvm/prebuilt/{system().lower()}-x86_64/bin/clang"
+ f"llvm/prebuilt/{build_platform}/bin/clang"
)
diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py
index f1cff914..8fcedb53 100644
--- a/tests/test_bootstrap.py
+++ b/tests/test_bootstrap.py
@@ -4,7 +4,6 @@ import sh
import unittest
from unittest import mock
-from platform import system
from pythonforandroid.bootstrap import (
_cmp_bootstraps_by_priority, Bootstrap, expand_dependencies,
@@ -13,7 +12,7 @@ from pythonforandroid.distribution import Distribution, generate_dist_folder_nam
from pythonforandroid.recipe import Recipe
from pythonforandroid.archs import ArchARMv7_a
from pythonforandroid.build import Context
-from pythonforandroid.util import BuildInterruptingException
+from pythonforandroid.util import BuildInterruptingException, build_platform
from test_graph import get_fake_recipe
@@ -531,7 +530,7 @@ class GenericBootstrapTest(BaseClassSetupBootstrap):
):
mock_find_executable.return_value = os.path.join(
self.ctx._ndk_dir,
- f"toolchains/llvm/prebuilt/{system().lower()}-x86_64/bin/clang",
+ f"toolchains/llvm/prebuilt/{build_platform}/bin/clang",
)
mock_glob.return_value = [
os.path.join(self.ctx._ndk_dir, "toolchains", "llvm")
diff --git a/tests/test_recipe.py b/tests/test_recipe.py
index ef5e1ad4..ffe254cb 100644
--- a/tests/test_recipe.py
+++ b/tests/test_recipe.py
@@ -5,12 +5,12 @@ import unittest
import warnings
from unittest import mock
from backports import tempfile
-from platform import system
from pythonforandroid.build import Context
from pythonforandroid.recipe import Recipe, import_recipe
from pythonforandroid.archs import ArchAarch_64
from pythonforandroid.bootstrap import Bootstrap
+from pythonforandroid.util import build_platform
from test_bootstrap import BaseClassSetupBootstrap
@@ -284,7 +284,7 @@ class TesSTLRecipe(BaseClassSetupBootstrap, unittest.TestCase):
"""
expected_compiler = (
f"/opt/android/android-ndk/toolchains/"
- f"llvm/prebuilt/{system().lower()}-x86_64/bin/clang"
+ f"llvm/prebuilt/{build_platform}/bin/clang"
)
mock_find_executable.return_value = expected_compiler
mock_glob.return_value = ["llvm"]

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ffeb70e722674e8e6ed1db5dd18a46ba43d8e2cc90c7afdb1d7d014f9f9ade2c
size 1605367

View File

@@ -0,0 +1,4 @@
addFilter("devel-file-in-non-devel-package")
addFilter("zero-length")
addFilter("hidden-file-or-dir")
addFilter("script-without-shebang .*/site-packages/pythonforandroid/recipes/android/src/setup.py")

View File

@@ -0,0 +1,4 @@
-------------------------------------------------------------------
Sun Nov 15 01:29:33 AM UTC 2020 - John Vandenberg <jayvdb@gmail.com>
- Initial spec for v2020.6.2

View File

@@ -0,0 +1,128 @@
#
# spec file for package python-python-for-android
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define version_with_zeros 2020.06.02
%define skip_python2 1
Name: python-python-for-android
Version: 2020.6.2
Release: 0
Summary: Android APK packager for Python scripts and apps
License: MIT
URL: https://github.com/kivy/python-for-android
Source: https://github.com/kivy/python-for-android/archive/v%{version_with_zeros}.tar.gz#/python-for-android-%{version}.tar.gz
Source1: python-python-for-android-rpmlintrc
# https://github.com/kivy/python-for-android/pull/2355
Patch0: arch-tests.patch
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-Jinja2
Requires: python-appdirs
Requires: python-colorama >= 0.3.3
Requires: python-pep517
Requires: python-six
Requires: python-toml
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends: cmake
Recommends: python-pip
Recommends: python-setuptools
Recommends: python-wheel
BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module Jinja2}
BuildRequires: %{python_module appdirs}
BuildRequires: %{python_module colorama >= 0.3.3}
BuildRequires: %{python_module pep517}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module sh >= 1.10}
BuildRequires: %{python_module six}
BuildRequires: %{python_module toml}
BuildRequires: %{python_module wheel}
BuildRequires: clang
BuildRequires: cmake
BuildRequires: dos2unix
BuildRequires: unzip
# /SECTION
%python_subpackages
%description
Android APK packager for Python scripts and apps
%prep
%setup -q -n python-for-android-%{version_with_zeros}
%patch0 -p1
sed -i "1{s:#!.*$:#!%{_bindir}/bash:}" pythonforandroid/bootstraps/common/build/gradlew
find pythonforandroid/bootstraps/common/build/src/ -type f | xargs dos2unix
find pythonforandroid/bootstraps/common/build/src/ -type f | xargs chmod a-x
chmod a+x pythonforandroid/bootstraps/common/build/build.py
touch tests/__init__.py tests/recipes/__init__.py
sed -i 's/from backports import tempfile/import tempfile/' tests/test_recipe.py
sed -i 's/pep517<0.7.0/pep517/' setup.py tests/test_pythonpackage_basic.py
# https://github.com/kivy/python-for-android/pull/2354
sed -i "s/'pep517.',/'pep517',/" setup.py
%build
%python_build
%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/python-for-android
%python_clone -a %{buildroot}%{_bindir}/p4a
%{python_expand rm -r %{buildroot}%{$python_sitelib}/ci/ %{buildroot}%{$python_sitelib}/tests/
sed -i "1{s:#!.*$:#!%{_bindir}/$python:}" \
%{buildroot}%{$python_sitelib}/pythonforandroid/tools/*link \
%{buildroot}%{$python_sitelib}/pythonforandroid/bootstraps/common/build/build.py \
%{buildroot}%{$python_sitelib}/pythonforandroid/toolchain.py
chmod a+x %{buildroot}%{$python_sitelib}/pythonforandroid/toolchain.py
%fdupes %{buildroot}%{$python_sitelib}
}
%check
export PYTHONPATH=${PWD}:${PWD}/tests/
# Five failures due to venv attempting download of pip, wheel, setuptools
skip_tests="test_get_dep_names_of_package or test_get_package_dependencies or test_venv or test_get_package_as_folder or test_extract_metainfo_files_from_package"
%pytest -rs tests -k "not ($skip_tests)"
%post
%python_install_alternative python-for-android p4a
%postun
%python_uninstall_alternative python-for-android
%files %{python_files}
%doc README.md
%license LICENSE
%python_alternative %{_bindir}/python-for-android
%python_alternative %{_bindir}/p4a
%{python_sitelib}/*
%changelog