Skip to content

Commit b129f20

Browse files
committed
numpy: fix build
1 parent ef829d5 commit b129f20

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
1+
from pythonforandroid.recipe import CompiledComponentsPythonRecipe, Recipe
22
from pythonforandroid.logger import shprint, info
33
from pythonforandroid.util import current_directory
44
from multiprocessing import cpu_count
@@ -13,7 +13,11 @@ class NumpyRecipe(CompiledComponentsPythonRecipe):
1313
version = '1.22.3'
1414
url = 'https://pypi.python.org/packages/source/n/numpy/numpy-{version}.zip'
1515
site_packages_name = 'numpy'
16-
depends = ['setuptools', 'cython']
16+
depends = ["cython"]
17+
18+
# This build specifically requires setuptools version 59.2.0
19+
hostpython_prerequisites = ["setuptools==59.2.0"]
20+
1721
install_in_hostpython = True
1822
call_hostpython_via_targetpython = False
1923

@@ -36,6 +40,16 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
3640

3741
return env
3842

43+
def build_arch(self, arch):
44+
self.install_hostpython_prerequisites()
45+
super().build_arch(arch)
46+
47+
# Post build step to restore setuptools version
48+
self.hostpython_prerequisites = ["setuptools=={}".format(
49+
Recipe.get_recipe("setuptools", self.ctx).version)
50+
]
51+
self.install_hostpython_prerequisites()
52+
3953
def _build_compiled_components(self, arch):
4054
info('Building compiled components in {}'.format(self.name))
4155

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
from os.path import exists, join
2+
from pythonforandroid.logger import info
13
from pythonforandroid.recipe import PythonRecipe
24

35

46
class SetuptoolsRecipe(PythonRecipe):
57
version = '69.0.3'
6-
url = 'https://pypi.python.org/packages/source/s/setuptools/setuptools-{version}.tar.gz'
7-
call_hostpython_via_targetpython = False
8-
install_in_hostpython = True
8+
hostpython_prerequisites = ["setuptools=={}".format(version)]
9+
10+
def should_build(self, arch):
11+
if exists(join(self.hostpython_site_dir, "setuptools")):
12+
info('Python package already exists in site-packages')
13+
return False
14+
info('setuptools apparently isn\'t already in site-packages')
15+
return True
16+
17+
def build_arch(self, arch):
18+
self.install_hostpython_prerequisites()
919

1020

1121
recipe = SetuptoolsRecipe()

0 commit comments

Comments
 (0)