Commit 280de281 authored by Michael Droettboom's avatar Michael Droettboom

First working Numpy

parent 12bd22ba
......@@ -3,6 +3,12 @@ build/pyodide.js
build/pyodide.asm.*
*.bc
*.a
cpython/build
cpython/downloads
cpython/installs
numpy/build
numpy/host
numpy/downloads
numpy/.patched
\ No newline at end of file
......@@ -7,50 +7,72 @@ CPYTHONINC=$(CPYTHONROOT)/installs/python-$(PYVERSION)/include/python$(PYMINOR)
CC=emcc
CXX=em++
OPTFLAGS=-O3
CXXFLAGS=-std=c++14 $(OPTFLAGS) -g -I $(CPYTHONINC) -Wno-warn-absolute-paths
CXXFLAGS=-std=c++14 $(OPTFLAGS) -g -I$(CPYTHONINC) -Wno-warn-absolute-paths
LDFLAGS=$(OPTFLAGS) \
$(CPYTHONROOT)/installs/python-$(PYVERSION)/lib/libpython$(PYMINOR).a \
-s "BINARYEN_METHOD='native-wasm,interpret-binary,interpret-asm2wasm'" \
-s "BINARYEN_METHOD='native-wasm'" \
-s TOTAL_MEMORY=268435456 \
-s MAIN_MODULE=1 \
-s ASSERTIONS=2 \
-s EMULATED_FUNCTION_POINTERS=1 \
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
-s EXPORTED_FUNCTIONS='["_main"]' \
-s WASM=1 \
--memory-init-file 0
NUMPY_ROOT=numpy/build/numpy
NUMPY_LIBS=\
$(NUMPY_ROOT)/core/multiarray.so \
$(NUMPY_ROOT)/core/umath.so \
$(NUMPY_ROOT)/linalg/lapack_lite.so \
$(NUMPY_ROOT)/linalg/_umath_linalg.so \
$(NUMPY_ROOT)/fft/fftpack_lite.so \
$(NUMPY_ROOT)/random/mtrand.so
all: build/pyodide.asm.html build/pyodide.js
build:
[ -d build ] || mkdir build
build/pyodide.asm.html: src/main.bc src/jsimport.bc src/jsproxy.bc src/js2python.bc \
src/pyimport.bc src/pyproxy.bc src/python2js.bc \
src/runpython.bc root
src/runpython.bc root/.built build
$(CC) -s EXPORT_NAME="'pyodide'" --bind -o $@ $(filter %.bc,$^) $(LDFLAGS) \
$(foreach d,$(wildcard root/*),--preload-file $d@/$(notdir $d))
build/pyodide.js: src/pyodide.js
build/pyodide.js: src/pyodide.js build
cp $< $@
clean:
-rm -fr root
-rm build/*
-rm src/*.bc
make -C $(CPYTHONROOT) clean
rm -fr root
rm build/*
rm src/*.bc
echo "CPython and Numpy builds were not cleaned"
%.bc: %.cpp $(CPYTHONLIB)
$(CXX) --bind -o $@ $< $(CXXFLAGS)
root: $(CPYTHONLIB)
root/.built: $(CPYTHONLIB) $(NUMPY_LIBS)
mkdir -p root/lib
cp -a $(CPYTHONLIB)/ root/lib
cp -a numpy/build/numpy root/lib/python$(PYMINOR)/site-packages
rm -fr root/lib/python$(PYMINOR)/site-packages/numpy/distutils
( \
cd root/lib/python$(PYMINOR); \
rm -fr test distutils ensurepip idlelib __pycache__ tkinter; \
)
touch root/.built
$(CPYTHONLIB):
make -C $(CPYTHONROOT)
$(NUMPY_LIBS):
make -C numpy
......@@ -15,13 +15,14 @@ URL=https://www.python.org/ftp/python/$(PYVERSION)/Python-$(PYVERSION).tgz
LIB=libpython$(PYMINOR).a
all: install
all: $(INSTALL)/lib/$(LIB)
install: $(BUILD)/$(LIB)
$(INSTALL)/lib/$(LIB): $(BUILD)/$(LIB)
( \
cd $(BUILD); \
sed -i -e 's/libinstall:.*/libinstall:/' Makefile; \
touch $(BUILD)/$(LIB) ; \
emmake make HOSTPYTHON=$(HOSTPYTHON) PYTHON_FOR_BUILD=$(HOSTPYTHON) CROSS_COMPILE=yes inclinstall libinstall $(LIB) && \
cp $(LIB) $(INSTALL)/lib/ && \
cp $(HOSTINSTALL)/lib/python$(PYMINOR)/`$(HOSTPYTHON) -c "import sysconfig; print(sysconfig._get_sysconfigdata_name())"`.py $(INSTALL)/lib/python$(PYMINOR)/_sysconfigdata__emscripten_.py \
......@@ -76,3 +77,4 @@ $(BUILD)/$(LIB): $(BUILD)/Makefile $(HOSTPYTHON) $(HOSTPGEN) Setup.local
cd $(BUILD); \
emmake make HOSTPYTHON=$(HOSTPYTHON) HOSTPGEN=$(HOSTPGEN) CROSS_COMPILE=yes $(LIB) \
)
touch $(BUILD)/$(LIB)
......@@ -9,8 +9,10 @@ math mathmodule.c _math.c # -lm # math library functions, e.g. sin()
_struct _struct.c # binary structure packing/unpacking
_random _randommodule.c # Random number generator
_bisect _bisectmodule.c # Bisection algorithms
_datetime _datetimemodule.c
_heapq _heapqmodule.c
_json _json.c
_csv _csv.c
binascii binascii.c
......@@ -19,7 +21,8 @@ zlib zlibmodule.c -IModules/zlib zlib/adler32.c zlib/crc32.c zlib/deflate.c zlib
_sha1 sha1module.c
_sha256 sha256module.c
_sha512 sha512module.c
_sha3 _sha3/sha3module.c
_md5 md5module.c
#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
_datetime _datetimemodule.c
#future_builtins future_builtins.c
ac_cv_file__dev_ptmx=no
ac_cv_file__dev_ptc=no
ac_cv_func_dlopen=yes
PYVERSION=3.6.4
PYMINOR=$(basename $(PYVERSION))
NPYVERSION=1.14.1
ROOT=$(abspath .)
HOSTPYTHONINSTALL=$(ROOT)/../cpython/build/$(PYVERSION)/host
HOSTPYTHON=$(HOSTPYTHONINSTALL)/bin/python3$(EXE)
PYTHONINCLUDE=$(ROOT)/../cpython/installs/python-$(PYVERSION)/include/python$(PYMINOR)
HOSTROOT=$(ROOT)/host
HOSTDIR=$(HOSTROOT)/numpy-$(NPYVERSION)
HOSTBUILD=$(HOSTDIR)/build
BUILD=$(ROOT)/build
BUILDCORE=$(BUILD)/numpy/core
BUILDLINALG=$(BUILD)/numpy/linalg
BUILDFFT=$(BUILD)/numpy/fft
BUILDRANDOM=$(BUILD)/numpy/random
ZIPFILE=$(ROOT)/downloads/numpy-$(NPYVERSION).zip
URL=https://pypi.python.org/packages/a3/99/74aa456fc740a7e8f733af4e8302d8e61e123367ec660cd89c53a3cd4d70/numpy-1.14.1.zip
PLATFORMSLUG=$(shell $(HOSTPYTHON) -c "import sysconfig; print(sysconfig.get_platform())")-$(PYMINOR)
INCLUDE=$(HOSTDIR)/numpy/core/include
SRC=$(HOSTDIR)/numpy/core/src
GENINCLUDE=$(HOSTBUILD)/src.$(PLATFORMSLUG)/numpy/core/include
GENSRC=$(HOSTBUILD)/src.$(PLATFORMSLUG)/numpy/core/src
LINALG_SRC=$(HOSTDIR)/numpy/linalg
LINALG_GENSRC=$(HOSTBUILD)/src.$(PLATFORMSLUG)/numpy/linalg
FFT_SRC=$(HOSTDIR)/numpy/fft
RANDOM_SRC=$(HOSTDIR)/numpy/random
CC=emcc
AR=emar
CFLAGS=-O3 -Werror -std=c99 -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -I$(ROOT)/config -I$(INCLUDE) -I$(GENINCLUDE)/numpy -I$(INCLUDE)/private -I$(SRC) -I$(SRC)/.. -I$(SRC)/private -I$(SRC)/npymath -I$(SRC)/multiarray -I$(SRC)/umath -I$(SRC)/npysort -I$(PYTHONINCLUDE) -I$(GENSRC)/private -I$(GENSRC)/npymath -I$(GENSRC)/umath
LDFLAGS=-Werror \
-s EMULATED_FUNCTION_POINTERS=1 \
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
-s ASSERTIONS=2 \
-s SIDE_MODULE=1 \
--memory-init-file 0
all: \
$(BUILDCORE)/multiarray.so \
$(BUILDCORE)/umath.so \
$(BUILDLINALG)/lapack_lite.so \
$(BUILDLINALG)/_umath_linalg.so \
$(BUILDFFT)/fftpack_lite.so \
$(BUILDRANDOM)/mtrand.so
clean:
rm -fr $(HOSTROOT)
rm -fr $(BUILD)
$(ZIPFILE):
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
wget -q -O $@ $(URL)
md5sum --quiet --check checksums || (rm $@; false)
$(HOSTDIR)/setup.py: $(ZIPFILE)
[ -d $(HOSTROOT) ] || mkdir $(HOSTROOT)
unzip $(ZIPFILE) -d $(HOSTROOT)
touch $(HOSTDIR)/setup.py
$(GENSRC)/multiarray/arraytypes.c: $(ROOT)/.patched
( \
cd $(HOSTDIR); \
$(HOSTPYTHON) setup.py build \
)
$(BUILD)/numpy/__init__.py: $(GENSRC)/multiarray/arraytypes.c
[ -d $(BUILD) ] || mkdir $(BUILD)
cp -r $(HOSTBUILD)/lib.$(PLATFORMSLUG)/numpy $(BUILD) && \
cd $(BUILD); find . -name "*.so" -type f -delete
$(ROOT)/.patched: $(HOSTDIR)/setup.py
cat patches/*.patch | (cd $(HOSTDIR) ; patch -p1)
touch $@
NPYMATH_SRC=\
$(GENSRC)/npymath/ieee754.bc \
$(GENSRC)/npymath/npy_math_complex.bc \
$(SRC)/npymath/halffloat.bc \
$(SRC)/npymath/npy_math.bc \
NPYSORT_SRC=\
$(GENSRC)/npysort/binsearch.bc \
$(GENSRC)/npysort/heapsort.bc \
$(GENSRC)/npysort/mergesort.bc \
$(GENSRC)/npysort/quicksort.bc \
$(GENSRC)/npysort/selection.bc \
MULTIARRAY_SRC=\
$(GENSRC)/multiarray/arraytypes.bc \
$(GENSRC)/multiarray/einsum.bc \
$(GENSRC)/multiarray/lowlevel_strided_loops.bc \
$(GENSRC)/multiarray/nditer_templ.bc \
$(GENSRC)/multiarray/scalartypes.bc \
$(SRC)/multiarray/alloc.bc \
$(SRC)/multiarray/array_assign.bc \
$(SRC)/multiarray/array_assign_array.bc \
$(SRC)/multiarray/array_assign_scalar.bc \
$(SRC)/multiarray/arrayobject.bc \
$(SRC)/multiarray/buffer.bc \
$(SRC)/multiarray/calculation.bc \
$(SRC)/multiarray/common.bc \
$(SRC)/multiarray/compiled_base.bc \
$(SRC)/multiarray/conversion_utils.bc \
$(SRC)/multiarray/convert.bc \
$(SRC)/multiarray/convert_datatype.bc \
$(SRC)/multiarray/ctors.bc \
$(SRC)/multiarray/datetime.bc \
$(SRC)/multiarray/datetime_busday.bc \
$(SRC)/multiarray/datetime_busdaycal.bc \
$(SRC)/multiarray/datetime_strings.bc \
$(SRC)/multiarray/descriptor.bc \
$(SRC)/multiarray/dragon4.bc \
$(SRC)/multiarray/dtype_transfer.bc \
$(SRC)/multiarray/flagsobject.bc \
$(SRC)/multiarray/getset.bc \
$(SRC)/multiarray/hashdescr.bc \
$(SRC)/multiarray/item_selection.bc \
$(SRC)/multiarray/iterators.bc \
$(SRC)/multiarray/mapping.bc \
$(SRC)/multiarray/methods.bc \
$(SRC)/multiarray/multiarraymodule.bc \
$(SRC)/multiarray/nditer_api.bc \
$(SRC)/multiarray/nditer_constr.bc \
$(SRC)/multiarray/nditer_pywrap.bc \
$(SRC)/multiarray/number.bc \
$(SRC)/multiarray/numpyos.bc \
$(SRC)/multiarray/refcount.bc \
$(SRC)/multiarray/scalarapi.bc \
$(SRC)/multiarray/sequence.bc \
$(SRC)/multiarray/shape.bc \
$(SRC)/multiarray/strfuncs.bc \
$(SRC)/multiarray/temp_elide.bc \
$(SRC)/multiarray/ucsnarrow.bc \
$(SRC)/multiarray/usertypes.bc \
$(SRC)/multiarray/vdot.bc \
$(SRC)/private/mem_overlap.bc \
$(SRC)/private/npy_longdouble.bc \
$(SRC)/private/ufunc_override.bc
UMATH_SRC=\
$(GENSRC)/umath/loops.bc \
$(GENSRC)/umath/scalarmath.bc \
$(SRC)/private/mem_overlap.bc \
$(SRC)/private/npy_longdouble.bc \
$(SRC)/private/ufunc_override.bc \
$(SRC)/umath/extobj.bc \
$(SRC)/umath/override.bc \
$(SRC)/umath/reduction.bc \
$(SRC)/umath/ufunc_object.bc \
$(SRC)/umath/ufunc_type_resolution.bc \
$(SRC)/umath/umathmodule.bc \
LAPACK_LITE_SRC=\
$(LINALG_SRC)/lapack_litemodule.bc \
$(LINALG_SRC)/lapack_lite/python_xerbla.bc \
$(LINALG_SRC)/lapack_lite/f2c_z_lapack.bc \
$(LINALG_SRC)/lapack_lite/f2c_d_lapack.bc \
$(LINALG_SRC)/lapack_lite/f2c_s_lapack.bc \
$(LINALG_SRC)/lapack_lite/f2c_lapack.bc \
$(LINALG_SRC)/lapack_lite/f2c_blas.bc \
$(LINALG_SRC)/lapack_lite/f2c_config.bc \
$(LINALG_SRC)/lapack_lite/f2c.bc
UMATH_LINALG_SRC=\
$(LINALG_GENSRC)/umath_linalg.bc
FFTPACK_LITE_SRC=\
$(FFT_SRC)/fftpack_litemodule.bc \
$(FFT_SRC)/fftpack.bc
MTRAND_SRC=\
$(RANDOM_SRC)/mtrand/mtrand.bc \
$(RANDOM_SRC)/mtrand/randomkit.bc \
$(RANDOM_SRC)/mtrand/initarray.bc \
$(RANDOM_SRC)/mtrand/distributions.bc
$(BUILDCORE)/multiarray.so: $(MULTIARRAY_SRC) $(NPYMATH_SRC) $(NPYSORT_SRC)
$(CC) $(LDFLAGS) $^ -o $(BUILDCORE)/multiarray.js
mv $(BUILDCORE)/multiarray.js $(BUILDCORE)/multiarray.so
$(BUILDCORE)/umath.so: $(UMATH_SRC) $(NPYMATH_SRC)
$(CC) $(LDFLAGS) $^ -o $(BUILDCORE)/umath.js
mv $(BUILDCORE)/umath.js $(BUILDCORE)/umath.so
$(BUILDLINALG)/lapack_lite.so: $(LAPACK_LITE_SRC)
$(CC) $(LDFLAGS) $^ -o $(BUILDLINALG)/lapack_lite.js
mv $(BUILDLINALG)/lapack_lite.js $(BUILDLINALG)/lapack_lite.so
$(BUILDLINALG)/_umath_linalg.so: $(UMATH_LINALG_SRC)
$(CC) $(LDFLAGS) $^ -o $(BUILDLINALG)/_umath_linalg.js
mv $(BUILDLINALG)/_umath_linalg.js $(BUILDLINALG)/_umath_linalg.so
$(BUILDFFT)/fftpack_lite.so: $(FFTPACK_LITE_SRC)
$(CC) $(LDFLAGS) $^ -o $(BUILDFFT)/fftpack_lite.js
mv $(BUILDFFT)/fftpack_lite.js $(BUILDFFT)/fftpack_lite.so
$(BUILDRANDOM)/mtrand.so: $(MTRAND_SRC)
$(CC) $(LDFLAGS) $^ -o $(BUILDRANDOM)/mtrand.js
mv $(BUILDRANDOM)/mtrand.js $(BUILDRANDOM)/mtrand.so
%.bc: %.c $(BUILD)/numpy/__init__.py
$(CC) $(CFLAGS) -include math.h -c $< -o $@
b8324ef90ac9064cd0eac46b8b388674 ./downloads/numpy-1.14.1.zip
\ No newline at end of file
#define NPY_HAVE_ENDIAN_H 1
#define NPY_SIZEOF_SHORT 2
#define NPY_SIZEOF_INT 4
#define NPY_SIZEOF_LONG 4
#define NPY_SIZEOF_FLOAT 4
#define NPY_SIZEOF_COMPLEX_FLOAT 8
#define NPY_SIZEOF_DOUBLE 8
#define NPY_SIZEOF_COMPLEX_DOUBLE 16
#define NPY_SIZEOF_LONGDOUBLE 8
#define NPY_SIZEOF_COMPLEX_LONGDOUBLE 16
#define NPY_SIZEOF_PY_INTPTR_T 4
#define NPY_SIZEOF_OFF_T 4
#define NPY_SIZEOF_PY_LONG_LONG 8
#define NPY_SIZEOF_LONGLONG 8
#define NPY_NO_SMP 0
#define NPY_HAVE_DECL_ISNAN
#define NPY_HAVE_DECL_ISINF
#define NPY_HAVE_DECL_ISFINITE
#define NPY_HAVE_DECL_SIGNBIT
#define NPY_USE_C99_COMPLEX 1
#define NPY_HAVE_COMPLEX_DOUBLE 1
#define NPY_HAVE_COMPLEX_FLOAT 1
#define NPY_HAVE_COMPLEX_LONG_DOUBLE 1
#define NPY_RELAXED_STRIDES_CHECKING 1
#define NPY_USE_C99_FORMATS 1
#define NPY_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
#define NPY_ABI_VERSION 0x01000009
#define NPY_API_VERSION 0x0000000C
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1
#endif
#define HAVE_ENDIAN_H 1
#define SIZEOF_PY_INTPTR_T 4
#define SIZEOF_OFF_T 4
#define SIZEOF_PY_LONG_LONG 8
#define MATHLIB m
#define HAVE_SIN 1
#define HAVE_COS 1
#define HAVE_TAN 1
#define HAVE_SINH 1
#define HAVE_COSH 1
#define HAVE_TANH 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_CEIL 1
#define HAVE_SQRT 1
#define HAVE_LOG10 1
#define HAVE_LOG 1
#define HAVE_EXP 1
#define HAVE_ASIN 1
#define HAVE_ACOS 1
#define HAVE_ATAN 1
#define HAVE_FMOD 1
#define HAVE_MODF 1
#define HAVE_FREXP 1
#define HAVE_LDEXP 1
#define HAVE_RINT 1
#define HAVE_TRUNC 1
#define HAVE_EXP2 1
#define HAVE_LOG2 1
#define HAVE_ATAN2 1
#define HAVE_POW 1
#define HAVE_NEXTAFTER 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_CBRT 1
#define HAVE_STRTOLD_L 1
#define HAVE_FALLOCATE 1
#undef HAVE_BACKTRACE
#undef HAVE_XMMINTRIN_H
#undef HAVE_EMMINTRIN_H
#define HAVE_FEATURES_H 1
#define HAVE_DLFCN_H 1
#define HAVE___BUILTIN_ISNAN 1
#define HAVE___BUILTIN_ISINF 1
#define HAVE___BUILTIN_ISFINITE 1
#define HAVE___BUILTIN_BSWAP32 1
#define HAVE___BUILTIN_BSWAP64 1
#define HAVE___BUILTIN_EXPECT 1
#define HAVE___BUILTIN_MUL_OVERFLOW 1
#undef HAVE___BUILTIN_CPU_SUPPORTS
#define HAVE__M_FROM_INT64 1
#define HAVE__MM_LOAD_PS 1
#define HAVE__MM_PREFETCH 1
#define HAVE__MM_LOAD_PD 1
#define HAVE___BUILTIN_PREFETCH 1
#define HAVE_LINK_AVX 1
#define HAVE_LINK_AVX2 1
#undef HAVE_ATTRIBUTE_OPTIMIZE_UNROLL_LOOPS
#undef HAVE_ATTRIBUTE_OPTIMIZE_OPT_3
#define HAVE_ATTRIBUTE_NONNULL 1
#define HAVE_ATTRIBUTE_TARGET_AVX 1
#define HAVE_ATTRIBUTE_TARGET_AVX2 1
#define HAVE___THREAD 1
#define HAVE_SINF 1
#define HAVE_COSF 1
#define HAVE_TANF 1
#define HAVE_SINHF 1
#define HAVE_COSHF 1
#define HAVE_TANHF 1
#define HAVE_FABSF 1
#define HAVE_FLOORF 1
#define HAVE_CEILF 1
#define HAVE_RINTF 1
#define HAVE_TRUNCF 1
#define HAVE_SQRTF 1
#define HAVE_LOG10F 1
#define HAVE_LOGF 1
#define HAVE_LOG1PF 1
#define HAVE_EXPF 1
#define HAVE_EXPM1F 1
#define HAVE_ASINF 1
#define HAVE_ACOSF 1
#define HAVE_ATANF 1
#define HAVE_ASINHF 1
#define HAVE_ACOSHF 1
#define HAVE_ATANHF 1
#define HAVE_HYPOTF 1
#define HAVE_ATAN2F 1
#define HAVE_POWF 1
#define HAVE_FMODF 1
#define HAVE_MODFF 1
#define HAVE_FREXPF 1
#define HAVE_LDEXPF 1
#define HAVE_EXP2F 1
#define HAVE_LOG2F 1
#define HAVE_COPYSIGNF 1
#define HAVE_NEXTAFTERF 1
#define HAVE_CBRTF 1
#undef HAVE_SINL
#undef HAVE_COSL
#undef HAVE_TANL
#undef HAVE_SINHL
#undef HAVE_COSHL
#undef HAVE_TANHL
#undef HAVE_FABSL
#undef HAVE_FLOORL
#undef HAVE_CEILL
#undef HAVE_RINTL
#undef HAVE_TRUNCL
#undef HAVE_SQRTL
#undef HAVE_LOG10L
#undef HAVE_LOGL
#undef HAVE_LOG1PL
#undef HAVE_EXPL
#undef HAVE_EXPM1L
#undef HAVE_ASINL
#undef HAVE_ACOSL
#undef HAVE_ATANL
#undef HAVE_ASINHL
#undef HAVE_ACOSHL
#undef HAVE_ATANHL
#undef HAVE_HYPOTL
#undef HAVE_ATAN2L
#undef HAVE_POWL
#undef HAVE_FMODL
#undef HAVE_MODFL
#undef HAVE_FREXPL
#undef HAVE_LDEXPL
#undef HAVE_EXP2L
#undef HAVE_LOG2L
#undef HAVE_COPYSIGNL
#undef HAVE_NEXTAFTERL
#undef HAVE_CBRTL
#define HAVE_DECL_SIGNBIT
#undef HAVE_COMPLEX_H
#define HAVE_CABS 1
#define HAVE_CACOS 1
#define HAVE_CACOSH 1
#define HAVE_CARG 1
#define HAVE_CASIN 1
#define HAVE_CASINH 1
#define HAVE_CATAN 1
#define HAVE_CATANH 1
#define HAVE_CCOS 1
#define HAVE_CCOSH 1
#define HAVE_CEXP 1
#define HAVE_CIMAG 1
#define HAVE_CLOG 1
#define HAVE_CONJ 1
#define HAVE_CPOW 1
#define HAVE_CPROJ 1
#define HAVE_CREAL 1
#define HAVE_CSIN 1
#define HAVE_CSINH 1
#define HAVE_CSQRT 1
#define HAVE_CTAN 1
#define HAVE_CTANH 1
#define HAVE_CABSF 1
#define HAVE_CACOSF 1
#define HAVE_CACOSHF 1
#define HAVE_CARGF 1
#define HAVE_CASINF 1
#define HAVE_CASINHF 1
#define HAVE_CATANF 1
#define HAVE_CATANHF 1
#define HAVE_CCOSF 1
#define HAVE_CCOSHF 1
#define HAVE_CEXPF 1
#define HAVE_CIMAGF 1
#define HAVE_CLOGF 1
#define HAVE_CONJF 1
#define HAVE_CPOWF 1
#define HAVE_CPROJF 1
#define HAVE_CREALF 1
#define HAVE_CSINF 1
#define HAVE_CSINHF 1
#define HAVE_CSQRTF 1
#define HAVE_CTANF 1
#define HAVE_CTANHF 1
#undef HAVE_CABSL
#undef HAVE_CACOSL
#undef HAVE_CACOSHL
#undef HAVE_CARGL
#undef HAVE_CASINL
#undef HAVE_CASINHL
#undef HAVE_CATANL
#undef HAVE_CATANHL
#undef HAVE_CCOSL
#undef HAVE_CCOSHL
#undef HAVE_CEXPL
#undef HAVE_CIMAGL
#undef HAVE_CLOGL
#undef HAVE_CONJL
#undef HAVE_CPOWL
#undef HAVE_CPROJL
#undef HAVE_CREALL
#undef HAVE_CSINL
#undef HAVE_CSINHL
#undef HAVE_CSQRTL
#undef HAVE_CTANL
#undef HAVE_CTANHL
#define NPY_RESTRICT restrict
#define NPY_RELAXED_STRIDES_CHECKING 1
#define HAVE_LDOUBLE_IEEE_DOUBLE_LE 1
#define NPY_PY3K 1
#ifndef __cplusplus
/* #undef inline */
#endif
#ifndef _NPY_NPY_CONFIG_H_
#error config.h should never be included directly, include npy_config.h instead
#endif
diff --git a/numpy/core/include/numpy/npy_cpu.h b/numpy/core/include/numpy/npy_cpu.h
index 84653ea18..ca25a5715 100644
--- a/numpy/core/include/numpy/npy_cpu.h
+++ b/numpy/core/include/numpy/npy_cpu.h
@@ -82,6 +82,8 @@
#define NPY_CPU_ARCEL
#elif defined(__arc__) && defined(__BIG_ENDIAN__)
#define NPY_CPU_ARCEB
+#elif defined(__EMSCRIPTEN__)
+ #define NPY_CPU_EMSCRIPTEN
#else
#error Unknown CPU, please report this to numpy maintainers with \
information about your platform (OS, CPU and compiler)
diff --git a/numpy/core/include/numpy/npy_endian.h b/numpy/core/include/numpy/npy_endian.h
index 1a42121db..5a43b14a8 100644
--- a/numpy/core/include/numpy/npy_endian.h
+++ b/numpy/core/include/numpy/npy_endian.h
@@ -46,7 +46,8 @@
|| defined(NPY_CPU_SH_LE) \
|| defined(NPY_CPU_MIPSEL) \
|| defined(NPY_CPU_PPC64LE) \
- || defined(NPY_CPU_ARCEL)
+ || defined(NPY_CPU_ARCEL) \
+ || defined(NPY_CPU_EMSCRIPTEN)
#define NPY_BYTE_ORDER NPY_LITTLE_ENDIAN
#elif defined(NPY_CPU_PPC) \
|| defined(NPY_CPU_SPARC) \
diff --git a/numpy/linalg/umath_linalg.c.src b/numpy/linalg/umath_linalg.c.src
index 36b99b522..7c2d21189 100644
--- a/numpy/linalg/umath_linalg.c.src
+++ b/numpy/linalg/umath_linalg.c.src
@@ -797,7 +797,6 @@ update_pointers(npy_uint8** bases, ptrdiff_t* offsets, size_t count)
positives with this warning
*/
#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
/*
*****************************************************************************
diff --git a/numpy/core/src/multiarray/temp_elide.c b/numpy/core/src/multiarray/temp_elide.c
index e5175f162..13850b18b 100644
--- a/numpy/core/src/multiarray/temp_elide.c
+++ b/numpy/core/src/multiarray/temp_elide.c
@@ -82,9 +82,9 @@
* during in-place operations
*/
#define NPY_MIN_ELIDE_BYTES (32)
+#include <execinfo.h>
#endif
#include <dlfcn.h>
-#include <execinfo.h>
/*
* linear search pointer in table
diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h
index 19bbc7435..ecab1d52a 100644
--- a/numpy/core/include/numpy/ndarraytypes.h
+++ b/numpy/core/include/numpy/ndarraytypes.h
@@ -252,7 +252,8 @@ typedef enum {
NPY_FR_ps = 11,/* picoseconds */
NPY_FR_fs = 12,/* femtoseconds */
NPY_FR_as = 13,/* attoseconds */
- NPY_FR_GENERIC = 14 /* Generic, unbound units, can convert to anything */
+ NPY_FR_GENERIC = 14, /* Generic, unbound units, can convert to anything */
+ NPY_DATETIMEUNIT_NULL = -1
} NPY_DATETIMEUNIT;
/*
diff --git a/numpy/core/src/multiarray/datetime_strings.c b/numpy/core/src/multiarray/datetime_strings.c
index b9aeda508..263ef96a1 100644
--- a/numpy/core/src/multiarray/datetime_strings.c
+++ b/numpy/core/src/multiarray/datetime_strings.c
@@ -795,6 +795,8 @@ get_datetime_iso_8601_strlen(int local, NPY_DATETIMEUNIT base)
case NPY_FR_Y:
len += 21; /* 64-bit year */
break;
+ case NPY_DATETIMEUNIT_NULL:
+ return 0;
}
if (base >= NPY_FR_h) {
diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c
index 486eb43ce..4e3181fc0 100644
--- a/numpy/core/src/multiarray/item_selection.c
+++ b/numpy/core/src/multiarray/item_selection.c
@@ -1113,7 +1113,7 @@ PyArray_Sort(PyArrayObject *op, int axis, NPY_SORTKIND which)
return -1;
}
- if (which < 0 || which >= NPY_NSORTS) {
+ if (which >= NPY_NSORTS) {
PyErr_SetString(PyExc_ValueError, "not a valid sort kind");
return -1;
}
@@ -1221,10 +1221,6 @@ PyArray_Partition(PyArrayObject *op, PyArrayObject * ktharray, int axis,
return -1;
}
- if (which < 0 || which >= NPY_NSELECTS) {
- PyErr_SetString(PyExc_ValueError, "not a valid partition kind");
- return -1;
- }
part = get_partition_func(PyArray_TYPE(op), which);
if (part == NULL) {
/* Use sorting, slower but equivalent */
@@ -1263,7 +1259,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which)
PyArray_ArgSortFunc *argsort;
PyObject *ret;
- if (which < 0 || which >= NPY_NSORTS) {
+ if (which >= NPY_NSORTS) {
PyErr_SetString(PyExc_ValueError,
"not a valid sort kind");
return NULL;
@@ -1316,12 +1312,6 @@ PyArray_ArgPartition(PyArrayObject *op, PyArrayObject *ktharray, int axis,
PyArray_ArgSortFunc *argsort;
PyObject *ret;
- if (which < 0 || which >= NPY_NSELECTS) {
- PyErr_SetString(PyExc_ValueError,
- "not a valid partition kind");
- return NULL;
- }
-
argpart = get_argpartition_func(PyArray_TYPE(op), which);
if (argpart == NULL) {
/* Use sorting, slower but equivalent */
diff --git a/numpy/core/src/private/npy_binsearch.h.src b/numpy/core/src/private/npy_binsearch.h.src
index 3b2c59487..7d7099d24 100644
--- a/numpy/core/src/private/npy_binsearch.h.src
+++ b/numpy/core/src/private/npy_binsearch.h.src
@@ -106,10 +106,6 @@ get_@arg@binsearch_func(PyArray_Descr *dtype, NPY_SEARCHSIDE side)
npy_intp max_idx = num_funcs;
int type = dtype->type_num;
- if (side >= NPY_NSEARCHSIDES) {
- return NULL;
- }
-
/*
* It seems only fair that a binary search function be searched for
* using a binary search...
diff --git a/numpy/core/src/private/npy_partition.h.src b/numpy/core/src/private/npy_partition.h.src
index 07aecd4f8..8345546cc 100644
--- a/numpy/core/src/private/npy_partition.h.src
+++ b/numpy/core/src/private/npy_partition.h.src
@@ -92,9 +92,6 @@ static NPY_INLINE PyArray_PartitionFunc *
get_partition_func(int type, NPY_SELECTKIND which)
{
npy_intp i;
- if (which >= NPY_NSELECTS) {
- return NULL;
- }
for (i = 0; i < sizeof(_part_map)/sizeof(_part_map[0]); i++) {
if (type == _part_map[i].typenum) {
return _part_map[i].part[which];
@@ -108,9 +105,6 @@ static NPY_INLINE PyArray_ArgPartitionFunc *
get_argpartition_func(int type, NPY_SELECTKIND which)
{
npy_intp i;
- if (which >= NPY_NSELECTS) {
- return NULL;
- }
for (i = 0; i < sizeof(_part_map)/sizeof(_part_map[0]); i++) {
if (type == _part_map[i].typenum) {
return _part_map[i].argpart[which];
diff --git a/numpy/core/src/npymath/npy_math_complex.c.src b/numpy/core/src/npymath/npy_math_complex.c.src
index fb31e8e6a..36e7fa095 100644
--- a/numpy/core/src/npymath/npy_math_complex.c.src
+++ b/numpy/core/src/npymath/npy_math_complex.c.src
@@ -1515,11 +1515,9 @@ _sum_squares@c@(@type@ x, @type@ y)
{
#if @precision@ == 1
const npy_float SQRT_MIN = 1.0842022e-19f;
-#endif
-#if @precision@ == 2
+#elif @precision@ == 2 || NPY_SIZEOF_LONGDOUBLE < 16
const npy_double SQRT_MIN = 1.4916681462400413e-154; /* sqrt(DBL_MIN) */
-#endif
-#if @precision@ == 3
+#elif @precision@ == 3
/* this is correct for 80 bit long doubles */
const npy_longdouble SQRT_MIN = 1.8336038675548471656e-2466l;
#endif
diff --git a/numpy/core/src/multiarray/nditer_pywrap.c b/numpy/core/src/multiarray/nditer_pywrap.c
index 0d318178f..2d3de0247 100644
--- a/numpy/core/src/multiarray/nditer_pywrap.c
+++ b/numpy/core/src/multiarray/nditer_pywrap.c
@@ -2481,7 +2481,7 @@ NPY_NO_EXPORT PyTypeObject NpyIter_Type = {
0, /* tp_iter */
(iternextfunc)npyiter_next, /* tp_iternext */
npyiter_methods, /* tp_methods */
- npyiter_members, /* tp_members */
+ 0, /* tp_members */
npyiter_getsets, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
diff --git a/numpy/core/src/multiarray/alloc.c b/numpy/core/src/multiarray/alloc.c
index f8305d115..369a14012 100644
--- a/numpy/core/src/multiarray/alloc.c
+++ b/numpy/core/src/multiarray/alloc.c
@@ -277,3 +277,9 @@ PyDataMem_RENEW(void *ptr, size_t size)
}
return result;
}
+
+NPY_NO_EXPORT void npy_init_cache() {
+ memset(datacache, 0, sizeof(cache_bucket) * NBUCKETS);
+ memset(dimcache, 0, sizeof(cache_bucket) * NBUCKETS_DIM);
+ _PyDataMem_eventhook = NULL;
+}
diff --git a/numpy/core/src/multiarray/alloc.h b/numpy/core/src/multiarray/alloc.h
index 2b69efc35..10069503d 100644
--- a/numpy/core/src/multiarray/alloc.h
+++ b/numpy/core/src/multiarray/alloc.h
@@ -33,4 +33,7 @@ npy_free_cache_dim_array(PyArrayObject * arr)
npy_free_cache_dim(PyArray_DIMS(arr), PyArray_NDIM(arr));
}
+NPY_NO_EXPORT void
+npy_init_cache(void);
+
#endif
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index 8e7352e4f..a713679e8 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -4747,6 +4747,8 @@ PyMODINIT_FUNC initmultiarray(void) {
goto err;
}
+ npy_init_cache();
+
#if defined(MS_WIN64) && defined(__GNUC__)
PyErr_WarnEx(PyExc_Warning,
"Numpy built with MINGW-W64 on Windows 64 bits is experimental, " \
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index a713679e8..ddb4ca0e0 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -4728,7 +4728,7 @@ static struct PyModuleDef moduledef = {
/* Initialization function for the module */
#if defined(NPY_PY3K)
-#define RETVAL m
+#define RETVAL retval
PyMODINIT_FUNC PyInit_multiarray(void) {
#else
#define RETVAL
@@ -4736,6 +4736,7 @@ PyMODINIT_FUNC initmultiarray(void) {
#endif
PyObject *m, *d, *s;
PyObject *c_api;
+ PyObject *retval = NULL;
/* Create the module and add the functions */
#if defined(NPY_PY3K)
@@ -4761,6 +4762,10 @@ PyMODINIT_FUNC initmultiarray(void) {
/* Initialize access to the PyDateTime API */
numpy_pydatetime_import();
+ if (PyErr_Occurred()) {
+ goto err;
+ }
+
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
if (!d) {
@@ -4888,6 +4893,8 @@ PyMODINIT_FUNC initmultiarray(void) {
if (set_typeinfo(d) != 0) {
goto err;
}
+ retval = m;
+
return RETVAL;
err:
diff --git a/numpy/core/src/umath/umathmodule.c b/numpy/core/src/umath/umathmodule.c
index 1a6cee030..0706d2bad 100644
--- a/numpy/core/src/umath/umathmodule.c
+++ b/numpy/core/src/umath/umathmodule.c
@@ -310,7 +310,7 @@ static struct PyModuleDef moduledef = {
#include <stdio.h>
#if defined(NPY_PY3K)
-#define RETVAL m
+#define RETVAL retval
PyMODINIT_FUNC PyInit_umath(void)
#else
#define RETVAL
@@ -318,6 +318,7 @@ PyMODINIT_FUNC initumath(void)
#endif
{
PyObject *m, *d, *s, *s2, *c_api;
+ PyObject *retval = NULL;
int UFUNC_FLOATING_POINT_SUPPORT = 1;
#ifdef NO_UFUNC_FLOATING_POINT_SUPPORT
@@ -428,6 +429,8 @@ PyMODINIT_FUNC initumath(void)
goto err;
}
+ retval = m;
+
return RETVAL;
err:
diff --git a/numpy/fft/helper.py b/numpy/fft/helper.py
index 0856d6759..7238b74a2 100644
--- a/numpy/fft/helper.py
+++ b/numpy/fft/helper.py
@@ -5,7 +5,10 @@ Discrete Fourier Transforms - helper.py
from __future__ import division, absolute_import, print_function
import collections
-import threading
+try:
+ import threading
+except ImportError:
+ import dummy_threading as threading
from numpy.compat import integer_types
from numpy.core import (
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment