kivy-ios/recipes/numpy/__init__.py
Richard Larkin 64bd692632
Flake8 CI fixes (#451)
* Pep8 fixes

* tox Pep8 compliance

* Excluded external tools folder from flake 8 tests

* Added Flake 8 exclusions

* Pep8 fixes

* Pep8 fixes

* Corrected type

* Pep8 fixes

* Pep 8 compliance

* Pep8 fixes

* Pep8  fixes

* Pep8 fixes

* Pep8 fixes

* Pep 8 fixes

* Pep 8 fixes

* Pep8 fixes

* Pep8 fixes

* Pep8 fixes

* Pep8

* Pep8

* Pep 8

* Pep 8

* Pep8 fixes

* Pep8

* Pep8

* Pep8

* Pep8 fixes

* Pep8 fixes

* Pep8 fixes

* Pep8 fixes

* Pep8 fixes

* Revert chagnes

* Revert changes to kivy/__init.py

* Revert changes

* REvert changes

* Revert changes

* Revert changes to toolchain

* Add files exclusions to tox.ini

* Added exclusions for alias recipes

* Remove dead code

* Added py extension to recipes

* Removed recipe build skip

* Improves recipe matching

Previous expression was matching all the following three lines of a `git diff --name-only` output.
```
recipes/hostlibffi/__init__.py
recipes/hostpython.py
recipes/hostpython2/__init__.py
```
This was resulting to a bug when later splitting with `recipe = file_path.split('/')[1]` the `recipes/hostpython.py` string would return including the `\n` new line char, see:
 ```
>>> 'recipes/hostpython.py\n'.split('/')[1]
'hostpython.py\n'
>>> 'recipes/hostlibffi/__init__.py\n'.split('/')[1]
'hostlibffi'
>>> 
```

Co-authored-by: Andre Miras <AndreMiras@users.noreply.github.com>
2020-04-25 18:28:16 +02:00

55 lines
2.1 KiB
Python

from toolchain import CythonRecipe
from os.path import join
import sh
import shutil
class NumpyRecipe(CythonRecipe):
version = "1.16.4"
url = "https://pypi.python.org/packages/source/n/numpy/numpy-{version}.zip"
library = "libnumpy.a"
libraries = ["libnpymath.a", "libnpysort.a"]
include_dir = "numpy/core/include"
depends = ["python"]
pbx_frameworks = ["Accelerate"]
cythonize = False
def prebuild_arch(self, arch):
if self.has_marker("patched"):
return
self.apply_patch("numpy-1.16.4.patch")
self.set_marker("patched")
def get_recipe_env(self, arch):
env = super(NumpyRecipe, self).get_recipe_env(arch)
# CC must have the CFLAGS with arm arch, because numpy tries first to
# 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"
return env
def build_arch(self, arch):
super(NumpyRecipe, self).build_arch(arch)
sh.cp(sh.glob(join(self.build_dir, "build", "temp.*", "libnpy*.a")),
self.build_dir)
def reduce_python_package(self):
dest_dir = join(self.ctx.site_packages_dir, "numpy")
shutil.rmtree(join(dest_dir, "core", "include"))
shutil.rmtree(join(dest_dir, "core", "tests"))
shutil.rmtree(join(dest_dir, "distutils"))
shutil.rmtree(join(dest_dir, "doc"))
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, "ma", "tests"))
shutil.rmtree(join(dest_dir, "matrixlib", "tests"))
shutil.rmtree(join(dest_dir, "polynomial", "tests"))
shutil.rmtree(join(dest_dir, "random", "tests"))
shutil.rmtree(join(dest_dir, "tests"))
recipe = NumpyRecipe()