Skip to content

Commit

Permalink
Merge pull request #604 from misl6/feat/upgrade-numpy
Browse files Browse the repository at this point in the history
Update numpy to version 1.20.2
  • Loading branch information
AndreMiras authored Apr 4, 2021
2 parents 6b245b1 + 84595ab commit e38cd58
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 137 deletions.
15 changes: 8 additions & 7 deletions kivy_ios/recipes/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@


class NumpyRecipe(CythonRecipe):
version = "1.16.4"
version = "1.20.2"
url = "https://pypi.python.org/packages/source/n/numpy/numpy-{version}.zip"
library = "libnumpy.a"
libraries = ["libnpymath.a", "libnpysort.a"]
libraries = ["libnpymath.a", "libnpyrandom.a"]
include_dir = "numpy/core/include"
depends = ["python"]
pbx_frameworks = ["Accelerate"]
hostpython_prerequisites = ["Cython"]
cythonize = False

def prebuild_arch(self, arch):
if self.has_marker("patched"):
return
self.apply_patch("numpy-1.16.4.patch")
self.apply_patch("duplicated_symbols.patch")
self.set_marker("patched")

def get_recipe_env(self, arch):
Expand All @@ -26,9 +26,9 @@ def get_recipe_env(self, arch):
# compile and execute an empty C to see if the compiler works. This is
# obviously not working when crosscompiling
env["CC"] = "{} {}".format(env["CC"], env["CFLAGS"])
# Numpy configuration. Don't try to compile anything related to it,
# we're going to use the Accelerate framework
env["NPYCONFIG"] = "env BLAS=None LAPACK=None ATLAS=None"
# Disable Accelerate.framework by disabling the optimized BLAS and LAPACK libraries cause it's now unsupported
env["NPY_BLAS_ORDER"] = ""
env["NPY_LAPACK_ORDER"] = ""
return env

def build_arch(self, arch):
Expand All @@ -45,6 +45,7 @@ def reduce_python_package(self):
shutil.rmtree(join(dest_dir, "f2py", "tests"))
shutil.rmtree(join(dest_dir, "fft", "tests"))
shutil.rmtree(join(dest_dir, "lib", "tests"))
shutil.rmtree(join(dest_dir, "linalg", "tests"))
shutil.rmtree(join(dest_dir, "ma", "tests"))
shutil.rmtree(join(dest_dir, "matrixlib", "tests"))
shutil.rmtree(join(dest_dir, "polynomial", "tests"))
Expand Down
23 changes: 23 additions & 0 deletions kivy_ios/recipes/numpy/duplicated_symbols.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff -Naur numpy-1.20.2.orig/numpy/linalg/setup.py numpy-1.20.2/numpy/linalg/setup.py
--- numpy-1.20.2.orig/numpy/linalg/setup.py 2021-04-04 11:04:17.000000000 +0200
+++ numpy-1.20.2/numpy/linalg/setup.py 2021-04-04 11:04:54.000000000 +0200
@@ -75,7 +75,7 @@
# umath_linalg module
config.add_extension(
'_umath_linalg',
- sources=['umath_linalg.c.src', get_lapack_lite_sources],
+ sources=['umath_linalg.c.src'],
depends=['lapack_lite/f2c.h'],
extra_info=lapack_info,
libraries=['npymath'],
diff -Naur numpy-1.20.2.orig/numpy/random/setup.py numpy-1.20.2/numpy/random/setup.py
--- numpy-1.20.2.orig/numpy/random/setup.py 2021-04-04 11:04:17.000000000 +0200
+++ numpy-1.20.2/numpy/random/setup.py 2021-04-04 11:05:22.000000000 +0200
@@ -127,7 +127,6 @@
config.add_extension('mtrand',
sources=['mtrand.c',
'src/legacy/legacy-distributions.c',
- 'src/distributions/distributions.c',
],
include_dirs=['.', 'src', 'src/legacy'],
libraries=['m'] if os.name != 'nt' else [],
128 changes: 0 additions & 128 deletions kivy_ios/recipes/numpy/numpy-1.16.4.patch

This file was deleted.

19 changes: 17 additions & 2 deletions kivy_ios/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ class Recipe:
"frameworks": [],
"sources": [],
"pbx_frameworks": [],
"pbx_libraries": []
"pbx_libraries": [],
"hostpython_prerequisites": []
}

def __new__(cls):
Expand Down Expand Up @@ -696,6 +697,7 @@ def execute(self):
self.ctx.state.remove_all(self.name)
self.download()
self.extract()
self.install_hostpython_prerequisites()
self.build_all()

@property
Expand Down Expand Up @@ -757,6 +759,11 @@ def extract_arch(self, arch):
ensure_dir(build_dir)
self.extract_file(self.archive_fn, build_dir)

@cache_execution
def install_hostpython_prerequisites(self):
for prerequisite in self.hostpython_prerequisites:
_hostpython_pip(["install", prerequisite])

@cache_execution
def build(self, arch):
self.build_dir = self.get_build_dir(arch.arch)
Expand Down Expand Up @@ -1166,11 +1173,19 @@ def _pip(args):
pip_args = ["--isolated", "--prefix", ctx.python_prefix]
args = ["install"] + pip_args + args[1:]

logger.error("Executing pip with: {}".format(args))
logger.info("Executing pip with: {}".format(args))
pip_cmd = sh.Command(pip_path)
shprint(pip_cmd, *args, _env=pip_env)


def _hostpython_pip(args):
ctx = Context()
pip_path = join(ctx.dist_dir, 'hostpython3', 'bin', 'pip3')
logger.info("Executing pip for hostpython with: {}".format(args))
pip_cmd = sh.Command(pip_path)
shprint(pip_cmd, *args)


def update_pbxproj(filename, pbx_frameworks=None):
# list all the compiled recipes
ctx = Context()
Expand Down

0 comments on commit e38cd58

Please sign in to comment.