Skip to content

Commit 715069b

Browse files
SomberNightaccumulator
authored andcommitted
recipes: pyqt5 recipe to use "hostpython" instead of system python
Previously the "PyQt-builder" pip package was assumed to be installed in the system python, and there was an implicit assumption that the system python has the same major+minor version as the "targetpython" (which is bundled in the apk). It is cleaner to try to have p4a handle all this internally.
1 parent 2157ed5 commit 715069b

File tree

7 files changed

+89
-6
lines changed

7 files changed

+89
-6
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class PackagingRecipe(PythonRecipe):
5+
version = "21.3"
6+
url = "https://pypi.python.org/packages/source/p/packaging/packaging-{version}.tar.gz"
7+
depends = ["setuptools", "pyparsing"]
8+
9+
call_hostpython_via_targetpython = False
10+
install_in_hostpython = True
11+
12+
13+
recipe = PackagingRecipe()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class PyparsingRecipe(PythonRecipe):
5+
version = "3.0.7"
6+
url = "https://pypi.python.org/packages/source/p/pyparsing/pyparsing-{version}.tar.gz"
7+
depends = ["setuptools"]
8+
9+
call_hostpython_via_targetpython = False
10+
install_in_hostpython = True
11+
12+
13+
recipe = PyparsingRecipe()

pythonforandroid/recipes/pyqt5/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22
from os.path import join
33
from pathlib import Path
44
from multiprocessing import cpu_count
5+
import shutil
6+
import copy
57
import toml
68

79
from pythonforandroid.logger import (shprint, info, logger, debug)
8-
from pythonforandroid.recipe import CythonRecipe, Recipe
10+
from pythonforandroid.recipe import Recipe
911
from pythonforandroid.toolchain import current_directory
1012

1113
class PyQt5Recipe(Recipe):
1214
version = '5.15.6'
13-
url = 'https://files.pythonhosted.org/packages/3b/27/fd81188a35f37be9b3b4c2db1654d9439d1418823916fe702ac3658c9c41/PyQt5-5.15.6.tar.gz'
15+
url = "https://pypi.python.org/packages/source/P/PyQt5/PyQt5-{version}.tar.gz"
1416
name = 'pyqt5'
1517

16-
depends = ['qt5', 'pyjnius', 'setuptools', 'pyqt5sip']
18+
depends = ['qt5', 'pyjnius', 'setuptools', 'pyqt5sip', 'hostpython3', 'pyqt_builder']
1719

1820
def get_recipe_env(self, arch):
1921
env = super().get_recipe_env(arch)
20-
recipe = Recipe.get_recipe('qt5', self.ctx)
22+
recipe = self.get_recipe('qt5', self.ctx)
2123
qt5_env = recipe.get_recipe_env(arch)
2224
env['TARGET_QMAKEPATH'] = qt5_env['TARGET_QMAKEPATH']
2325

@@ -63,7 +65,16 @@ def build_arch(self, arch):
6365
with current_directory(build_dir):
6466
info("compiling pyqt5")
6567

66-
buildcmd = sh.Command('sip-install')
68+
hostpython = self.get_recipe('hostpython3', self.ctx)
69+
pythondir = hostpython.get_path_to_python()
70+
site_packages = join(pythondir, 'Lib', 'site-packages')
71+
env = copy.copy(env)
72+
env['PYTHONPATH'] = f'{site_packages}:' + env.get('PYTHONPATH', '')
73+
74+
buildcmd = sh.Command(self.ctx.hostpython)
75+
# buildcmd = buildcmd.bake('-m', 'sipbuild.tools.install')
76+
sip_install = join(pythondir, 'usr', 'local', 'bin', 'sip-install')
77+
buildcmd = buildcmd.bake(sip_install)
6778
buildcmd = buildcmd.bake('--confirm-license', '--qt-shared', '--verbose')
6879
buildcmd = buildcmd.bake('--no-tools', '--no-qml-plugin', '--no-designer-plugin', '--no-dbus-python')
6980

pythonforandroid/recipes/pyqt5sip/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class PyQt5SipRecipe(PythonRecipe):
1010
version = '12.9.0'
11-
url = 'https://files.pythonhosted.org/packages/b1/40/dd8f081f04a12912b65417979bf2097def0af0f20c89083ada3670562ac5/PyQt5_sip-12.9.0.tar.gz'
11+
url = "https://pypi.python.org/packages/source/P/PyQt5_sip/PyQt5_sip-{version}.tar.gz"
1212
name = 'pyqt5sip'
1313

1414
depends = ['setuptools']
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
class PyQtBuilderRecipe(PythonRecipe):
4+
version = '1.12.2'
5+
url = "https://pypi.python.org/packages/source/P/PyQt-builder/PyQt-builder-{version}.tar.gz"
6+
name = 'pyqt_builder'
7+
8+
depends = ['sip', 'packaging']
9+
10+
call_hostpython_via_targetpython = False
11+
install_in_hostpython = True
12+
install_in_targetpython = False # FIXME broken
13+
site_packages_name = 'pyqtbuild'
14+
15+
16+
recipe = PyQtBuilderRecipe()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
2+
3+
4+
class SipRecipe(CompiledComponentsPythonRecipe):
5+
version = '6.5.1'
6+
url = "https://pypi.python.org/packages/source/s/sip/sip-{version}.tar.gz"
7+
name = 'sip'
8+
9+
depends = ['setuptools', 'packaging', 'toml']
10+
11+
call_hostpython_via_targetpython = False
12+
install_in_hostpython = True
13+
install_in_targetpython = False # FIXME broken
14+
site_packages_name = 'sipbuild'
15+
16+
17+
recipe = SipRecipe()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class TomlRecipe(PythonRecipe):
5+
version = "0.10.2"
6+
url = "https://pypi.python.org/packages/source/t/toml/toml-{version}.tar.gz"
7+
depends = ["setuptools"]
8+
9+
call_hostpython_via_targetpython = False
10+
install_in_hostpython = True
11+
12+
13+
recipe = TomlRecipe()

0 commit comments

Comments
 (0)