Commit 6dc91e08 authored by Michael Droettboom's avatar Michael Droettboom

First pass at matplotlib support

parent b537908b
......@@ -5,28 +5,18 @@
__pycache__
geckodriver.log
build
downloads
host
installs
/root/
/build/
/emsdk/emsdk
/cpython/build
/cpython/downloads
/cpython/installs
/numpy/build
/numpy/host
/numpy/downloads
/pandas/build
/pandas/host
/pandas/downloads
/dateutil/downloads
/dateutil/python-dateutil-2.7.2
/pytz/downloads
/pytz/pytz-2018.4
/six/downloads
/six/six-1.11.0
/cycler/cycler-0.10.0
/pyparsing/pyparsing-2.2.0
......@@ -23,6 +23,7 @@ LDFLAGS=\
-s EXPORTED_FUNCTIONS='["_main"]' \
-s WASM=1 \
-s SWAPPABLE_ASM_MODULE=1 \
-s USE_FREETYPE=1 \
--memory-init-file 0
NUMPY_ROOT=numpy/build/numpy
......@@ -38,6 +39,10 @@ PANDAS_ROOT=pandas/build/pandas
PANDAS_LIBS=\
$(PANDAS_ROOT)/_libs/lib.so
MATPLOTLIB_ROOT=matplotlib/build/matplotlib
MATPLOTLIB_LIBS=\
$(MATPLOTLIB_ROOT)/_path.so
DATEUTIL_ROOT=dateutil/python-dateutil-2.7.2/build/lib/dateutil
DATEUTIL_LIBS=$(DATEUTIL_ROOT)/__init__.py
......@@ -47,6 +52,15 @@ PYTZ_LIBS=$(PYTZ_ROOT)/__init__.py
SIX_ROOT=six/six-1.11.0/build/lib
SIX_LIBS=$(SIX_ROOT)/six.py
PYPARSING_ROOT=pyparsing/pyparsing-2.2.0/build/lib
PYPARSING_LIBS=$(PYPARSING_ROOT)/pyparsing.py
CYCLER_ROOT=cycler/cycler-0.10.0/build/lib
CYCLER_LIBS=$(CYCLER_ROOT)/cycler.py
KIWISOLVER_ROOT=kiwisolver/build
KIWISOLVER_LIBS=$(KIWISOLVER_ROOT)/kiwisolver.so
SITEPACKAGES=root/lib/python$(PYMINOR)/site-packages
all: build/pyodide.asm.js \
......@@ -57,7 +71,8 @@ all: build/pyodide.asm.js \
build/numpy.data \
build/dateutil.data \
build/pytz.data \
build/pandas.data
build/pandas.data \
build/matplotlib.data
build/pyodide.asm.js: src/main.bc src/jsimport.bc src/jsproxy.bc src/js2python.bc \
......@@ -134,9 +149,16 @@ build/pandas.data: $(PANDAS_LIBS)
python2 $(FILEPACKAGER) build/pandas.data --preload $(PANDAS_ROOT)@/lib/python3.6/site-packages/pandas --js-output=build/pandas.js --export-name=pyodide --exclude \*.wasm.pre --exclude __pycache__
build/matplotlib.data: $(MATPLOTLIB_LIBS)
python2 $(FILEPACKAGER) build/matplotlib.data --preload $(MATPLOTLIB_ROOT)@/lib/python3.6/site-packages/matplotlib --js-output=build/matplotlib.js --export-name=pyodide --exclude \*.wasm.pre --exclude __pycache__
root/.built: \
$(CPYTHONLIB) \
$(SIX_LIBS) \
$(PYPARSING_LIBS) \
$(CYCLER_LIBS) \
$(KIWISOLVER_LIBS) \
src/lazy_import.py \
src/sitecustomize.py \
src/webbrowser.py \
......@@ -146,6 +168,9 @@ root/.built: \
mkdir -p root/lib
cp -a $(CPYTHONLIB)/ root/lib
cp $(SIX_LIBS) $(SITEPACKAGES)
cp $(PYPARSING_LIBS) $(SITEPACKAGES)
cp $(CYCLER_LIBS) $(SITEPACKAGES)
cp $(KIWISOLVER_LIBS) $(SITEPACKAGES)
cp src/lazy_import.py $(SITEPACKAGES)
cp src/sitecustomize.py $(SITEPACKAGES)
cp src/webbrowser.py root/lib/python$(PYMINOR)
......@@ -156,7 +181,6 @@ root/.built: \
cd root/lib/python$(PYMINOR); \
rm -fr `cat ../../../remove_modules.txt`; \
rm encodings/cp*.py; \
rm encodings/mac_*.py; \
find . -name "*.wasm.pre" -type f -delete ; \
find -type d -name __pycache__ -prune -exec rm -rf {} \; \
)
......@@ -175,6 +199,10 @@ $(PANDAS_LIBS): $(NUMPY_LIBS)
make -C pandas
$(MATPLOTLIB_LIBS): $(NUMPY_LIBS)
make -C matplotlib
$(DATEUTIL_LIBS): $(CPYTHONLIB)
make -C dateutil
......@@ -187,5 +215,17 @@ $(SIX_LIBS): $(CPYTHONLIB)
make -C six
$(PYPARSING_LIBS): $(CPYTHONLIB)
make -C pyparsing
$(CYCLER_LIBS): $(CPYTHONLIB)
make -C cycler
$(KIWISOLVER_LIBS): $(CPYTHONLIB)
make -C kiwisolver
emsdk/emsdk/emsdk:
make -C emsdk
PYODIDE_ROOT=$(abspath ..)
include ../Makefile.envs
CYCLERVERSION=0.10.0
ROOT=$(abspath .)
SRC=$(ROOT)/cycler-$(CYCLERVERSION)
BUILD=$(SRC)/build/lib/dateutil
TARBALL=$(ROOT)/downloads/cycler-$(CYCLERVERSION).tgz
URL=https://files.pythonhosted.org/packages/c2/4b/137dea450d6e1e3d474e1d873cd1d4f7d3beed7e0dc973b06e8e10d32488/cycler-0.10.0.tar.gz
all: $(BUILD)/__init__.py
clean:
-rm -fr downloads
-rm -fr $(SRC)
$(TARBALL):
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
wget -q -O $@ $(URL)
md5sum --quiet --check checksums || (rm $@; false)
$(SRC)/setup.py: $(TARBALL)
tar -C . -xf $(TARBALL)
touch $(SRC)/setup.py
$(BUILD)/__init__.py: $(ROOT)/.patched
( \
cd $(SRC) ; \
$(HOSTPYTHON) setup.py build ; \
touch build/lib/cycler.py \
)
$(ROOT)/.patched: $(SRC)/setup.py
cat patches/*.patch | (cd $(SRC) ; patch -p1)
touch $@
4cb42917ac5007d1cdff6cccfe2d016b downloads/cycler-0.10.0.tgz
......@@ -42,3 +42,37 @@ diff -ru python-dateutil-2.7.2.orig/dateutil/tz/tz.py python-dateutil-2.7.2/date
def __call__(self, name=None):
with self._cache_lock:
diff -ur python-dateutil-2.7.2/dateutil/rrule.py python-dateutil-2.7.2.bak/dateutil/rrule.py
--- python-dateutil-2.7.2/dateutil/rrule.py 2018-03-24 11:53:31.000000000 -0400
+++ python-dateutil-2.7.2.bak/dateutil/rrule.py 2018-05-17 09:36:33.295290743 -0400
@@ -17,7 +17,20 @@
from fractions import gcd
from six import advance_iterator, integer_types
-from six.moves import _thread, range
+try:
+ from six.moves._thread import allocate_lock
+except ModuleNotFoundError:
+ class allocate_lock:
+ def locked(self):
+ return False
+
+ def release(self):
+ pass
+
+ def acquire(self):
+ pass
+
+from six.moves import range
import heapq
from ._common import weekday as weekdaybase
@@ -94,7 +107,7 @@
def __init__(self, cache=False):
if cache:
self._cache = []
- self._cache_lock = _thread.allocate_lock()
+ self._cache_lock = allocate_lock()
self._invalidate_cache()
else:
self._cache = None
\ No newline at end of file
PYODIDE_ROOT=$(abspath ..)
include ../Makefile.envs
KIWIVERSION=1.0.1
NPYVERSION=1.14.1
ROOT=$(abspath .)
HOSTROOT=$(ROOT)/host
HOSTDIR=$(HOSTROOT)/kiwisolver-$(KIWIVERSION)
HOSTBUILD=$(HOSTDIR)/build
HOSTSRC=$(HOSTDIR)/src
BUILD=$(ROOT)/build
TARBALL=$(ROOT)/downloads/kiwisolver-$(KIWIVERSION).tar.gz
URL=https://files.pythonhosted.org/packages/31/60/494fcce70d60a598c32ee00e71542e52e27c978e5f8219fae0d4ac6e2864/kiwisolver-1.0.1.tar.gz
CC=emcc
CXX=em++
AR=emar
CFLAGS=-Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I$(HOSTSRC) -I../numpy/host/numpy-$(NPYVERSION)/build/src.$(PLATFORMSLUG)/numpy/core/include/numpy -I$(PYTHONINCLUDE) -I$(HOSTDIR) -Wno-unused-function
OBJECTS= \
$(BUILD)/kiwisolver.so
all:
make $(ROOT)/.patched
make $(OBJECTS)
clean:
rm -fr $(HOSTROOT)
rm -fr $(BUILD)
$(TARBALL):
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
wget -q -O $@ $(URL)
md5sum --quiet --check checksums || (rm $@; false)
$(HOSTDIR)/setup.py: $(TARBALL)
[ -d $(HOSTROOT) ] || mkdir $(HOSTROOT)
tar -xf $(TARBALL) -C $(HOSTROOT)
touch $(HOSTDIR)/setup.py
$(BUILD)/kiwisolver.so: \
$(HOSTDIR)/py/kiwisolver.bc \
$(HOSTDIR)/py/constraint.bc \
$(HOSTDIR)/py/expression.bc \
$(HOSTDIR)/py/solver.bc \
$(HOSTDIR)/py/strength.bc \
$(HOSTDIR)/py/term.bc \
$(HOSTDIR)/py/variable.bc \
| .patched
[ -d $(ROOT)/build ] || mkdir $(ROOT)/build
$(CC) $(SIDE_LDFLAGS) $^ -o $@.wasm
mv $@.wasm $@
$(ROOT)/.patched: $(HOSTDIR)/setup.py
cat patches/*.patch | (cd $(HOSTDIR) ; patch -p1)
touch $@
%.bc: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.bc: %.cpp
$(CXX) $(CFLAGS) -c $< -o $@
e2a1718b837e2cd001f7c06934616fcd downloads/kiwisolver-1.0.1.tar.gz
PYODIDE_ROOT=$(abspath ..)
include ../Makefile.envs
MPLVERSION=2.2.2
NPYVERSION=1.14.1
ROOT=$(abspath .)
HOSTROOT=$(ROOT)/host
HOSTDIR=$(HOSTROOT)/matplotlib-$(MPLVERSION)
HOSTBUILD=$(HOSTDIR)/build
HOSTSRC=$(HOSTDIR)/src
AGGINC=$(HOSTDIR)/extern/agg24-svn/include
AGGSRC=$(HOSTDIR)/extern/agg24-svn/src
TTCONVSRC=$(HOSTDIR)/extern/ttconv
QHULLSRC=$(HOSTDIR)/extern/libqhull
BUILD=$(ROOT)/build/matplotlib
TARBALL=$(ROOT)/downloads/matplotlib-$(MPLVERSION).tar.gz
URL=https://files.pythonhosted.org/packages/ec/ed/46b835da53b7ed05bd4c6cae293f13ec26e877d2e490a53a709915a9dcb7/matplotlib-2.2.2.tar.gz
CC=emcc
CXX=em++
AR=emar
CFLAGS=-Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I$(HOSTSRC) -I../numpy/host/numpy-$(NPYVERSION)/numpy/core/include -I../numpy/config -I../numpy/host/numpy-$(NPYVERSION)/build/src.$(PLATFORMSLUG)/numpy/core/include/numpy -I$(PYTHONINCLUDE) -Wno-unused-function -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s USE_ZLIB=1 -I$(AGGINC) -I$(HOSTDIR)/extern -I$(HOSTDIR)
OBJECTS= \
$(BUILD)/ft2font.so \
$(BUILD)/_png.so \
$(BUILD)/_image.so \
$(BUILD)/ttconv.so \
$(BUILD)/_path.so \
$(BUILD)/_contour.so \
$(BUILD)/backends/_backend_agg.so
AGGOBJECTS = \
$(AGGSRC)/agg_bezier_arc.bc \
$(AGGSRC)/agg_curves.bc \
$(AGGSRC)/agg_image_filters.bc \
$(AGGSRC)/agg_trans_affine.bc \
$(AGGSRC)/agg_vcgen_contour.bc \
$(AGGSRC)/agg_vcgen_dash.bc \
$(AGGSRC)/agg_vcgen_stroke.bc \
$(AGGSRC)/agg_vpgen_segmentator.bc
all:
make $(BUILD)/__init__.py
make $(OBJECTS)
clean:
rm -fr $(HOSTROOT)
rm -fr $(BUILD)
$(TARBALL):
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
wget -q -O $@ $(URL)
md5sum --quiet --check checksums || (rm $@; false)
$(HOSTDIR)/setup.py: $(TARBALL)
[ -d $(HOSTROOT) ] || mkdir $(HOSTROOT)
tar -xf $(TARBALL) -C $(HOSTROOT)
touch $(HOSTDIR)/setup.py
$(HOSTBUILD)/lib.$(PLATFORMSLUG)/matplotlib/__init__.py: $(ROOT)/.patched
( \
cd $(HOSTDIR); \
$(HOSTPYTHON) setup.py build \
)
$(BUILD)/__init__.py: $(HOSTBUILD)/lib.$(PLATFORMSLUG)/matplotlib/__init__.py
[ -d $(ROOT)/build ] || mkdir $(ROOT)/build
cp -r $(HOSTBUILD)/lib.$(PLATFORMSLUG)/matplotlib $(ROOT)/build && \
cd $(BUILD); find . -name "*.so" -type f -delete
$(ROOT)/.patched: $(HOSTDIR)/setup.py
cat patches/*.patch | (cd $(HOSTDIR) ; patch -p1)
touch $@
$(BUILD)/ft2font.so: \
$(HOSTSRC)/ft2font.bc \
$(HOSTSRC)/ft2font_wrapper.bc \
$(HOSTSRC)/mplutils.bc
$(CC) $(SIDE_LDFLAGS) -lfreetype $^ -o $@.wasm
mv $@.wasm $@
$(BUILD)/_png.so: \
$(HOSTSRC)/_png.bc
$(CC) /home/mdboom/Work/builds/compiling/pyodide/emsdk/emsdk/.emscripten_cache/asmjs/libpng.bc $^ -o $@.wasm $(SIDE_LDFLAGS)
mv $@.wasm $@
$(BUILD)/_image.so: \
$(HOSTSRC)/_image.bc \
$(HOSTSRC)/_image_wrapper.bc \
$(HOSTSRC)/mplutils.bc \
$(HOSTSRC)/py_converters.bc \
$(AGGOBJECTS)
$(CC) $(SIDE_LDFLAGS) $^ -o $@.wasm
mv $@.wasm $@
$(BUILD)/ttconv.so: \
$(HOSTSRC)/_ttconv.bc \
$(TTCONVSRC)/pprdrv_tt.bc \
$(TTCONVSRC)/pprdrv_tt2.bc \
$(TTCONVSRC)/ttutil.bc
$(CC) $(SIDE_LDFLAGS) $^ -o $@.wasm
mv $@.wasm $@
$(BUILD)/_path.so: \
$(HOSTSRC)/py_converters.bc \
$(HOSTSRC)/_path_wrapper.bc \
$(AGGOBJECTS)
$(CC) $(SIDE_LDFLAGS) --profiling $^ -o $@.wasm
mv $@.wasm $@
$(BUILD)/_contour.so: \
$(HOSTSRC)/_contour.bc \
$(HOSTSRC)/_contour_wrapper.bc
$(CC) $(SIDE_LDFLAGS) $^ -o $@.wasm
mv $@.wasm $@
$(BUILD)/_qhull.so: \
$(HOSTSRC)/qhull_wrap.bc \
$(QHULLSRC)/geom.bc \
$(QHULLSRC)/geom2.bc \
$(QHULLSRC)/global.bc \
$(QHULLSRC)/io.bc \
$(QHULLSRC)/libqhull.bc \
$(QHULLSRC)/mem.bc \
$(QHULLSRC)/merge.bc \
$(QHULLSRC)/poly.bc \
$(QHULLSRC)/poly2.bc \
$(QHULLSRC)/qset.bc \
$(QHULLSRC)/random.bc \
$(QHULLSRC)/rboxlib.bc \
$(QHULLSRC)/stat.bc \
$(QHULLSRC)/user.bc \
$(QHULLSRC)/usermem.bc \
$(QHULLSRC)/userprintf.bc \
$(QHULLSRC)/userprintf_rbox.bc
$(CC) $(SIDE_LDFLAGS) $^ -o $@.wasm
mv $@.wasm $@
$(BUILD)/_tri.so: \
$(HOSTSRC)/tri/_tri.bc \
$(HOSTSRC)/tri/_tri_wrapper.bc \
$(HOSTSRC)/mplutils.bc
$(CC) $(SIDE_LDFLAGS) $^ -o $@.wasm
mv $@.wasm $@
$(BUILD)/backends/_backend_agg.so: \
$(HOSTSRC)/mplutils.bc \
$(HOSTSRC)/py_converters.bc \
$(HOSTSRC)/_backend_agg.bc \
$(HOSTSRC)/_backend_agg_wrapper.bc \
$(AGGOBJECTS)
$(CC) $(SIDE_LDFLAGS) $^ -o $@.wasm
mv $@.wasm $@
%.bc: %.c
$(CC) -DPY_ARRAY_UNIQUE_SYMBOL=_path_array_api $(CFLAGS) -c $< -o $@
%.bc: %.cpp
$(CXX) -DPY_ARRAY_UNIQUE_SYMBOL=_path_array_api $(CFLAGS) -c $< -o $@
dd1e49e041309a7fd4e32be8bf17c3b6 ./downloads/matplotlib-2.2.2.tar.gz
\ No newline at end of file
diff -ur matplotlib-2.2.2/lib/matplotlib/cbook/__init__.py matplotlib-2.2.2/lib/matplotlib/cbook/__init__.py
--- a/lib/matplotlib/cbook/__init__.py 2018-03-05 23:47:09.000000000 -0500
+++ b/lib/matplotlib/cbook/__init__.py 2018-05-17 09:39:11.514431317 -0400
@@ -10,7 +10,7 @@
import six
from six.moves import xrange, zip
-import bz2
+# import bz2
import collections
import contextlib
import datetime
@@ -601,10 +601,10 @@
# get rid of 'U' in flag for gzipped files.
flag = flag.replace('U', '')
fh = gzip.open(fname, flag)
- elif fname.endswith('.bz2'):
- # get rid of 'U' in flag for bz2 files
- flag = flag.replace('U', '')
- fh = bz2.BZ2File(fname, flag)
+ # elif fname.endswith('.bz2'):
+ # # get rid of 'U' in flag for bz2 files
+ # flag = flag.replace('U', '')
+ # fh = bz2.BZ2File(fname, flag)
else:
fh = io.open(fname, flag, encoding=encoding)
opened = True
diff -ur matplotlib-2.2.2/lib/matplotlib/axes/_axes.py matplotlib-2.2.2/lib/matplotlib/axes/_axes.py
--- a/lib/matplotlib/axes/_axes.py 2018-03-17 14:03:23.000000000 -0400
+++ b/lib/matplotlib/axes/_axes.py 2018-05-17 09:42:02.998583676 -0400
@@ -37,7 +37,7 @@
import matplotlib.text as mtext
import matplotlib.ticker as mticker
import matplotlib.transforms as mtransforms
-import matplotlib.tri as mtri
+# import matplotlib.tri as mtri
from matplotlib.cbook import (
_backports, mplDeprecation, warn_deprecated,
STEP_LOOKUP_MAP, iterable, safe_first_element)
@@ -8017,18 +8017,18 @@
return artists
- def tricontour(self, *args, **kwargs):
- return mtri.tricontour(self, *args, **kwargs)
- tricontour.__doc__ = mtri.tricontour.__doc__
-
- def tricontourf(self, *args, **kwargs):
- return mtri.tricontourf(self, *args, **kwargs)
- tricontourf.__doc__ = mtri.tricontour.__doc__
-
- def tripcolor(self, *args, **kwargs):
- return mtri.tripcolor(self, *args, **kwargs)
- tripcolor.__doc__ = mtri.tripcolor.__doc__
-
- def triplot(self, *args, **kwargs):
- return mtri.triplot(self, *args, **kwargs)
- triplot.__doc__ = mtri.triplot.__doc__
+ # def tricontour(self, *args, **kwargs):
+ # return mtri.tricontour(self, *args, **kwargs)
+ # tricontour.__doc__ = mtri.tricontour.__doc__
+
+ # def tricontourf(self, *args, **kwargs):
+ # return mtri.tricontourf(self, *args, **kwargs)
+ # tricontourf.__doc__ = mtri.tricontour.__doc__
+
+ # def tripcolor(self, *args, **kwargs):
+ # return mtri.tripcolor(self, *args, **kwargs)
+ # tripcolor.__doc__ = mtri.tripcolor.__doc__
+
+ # def triplot(self, *args, **kwargs):
+ # return mtri.triplot(self, *args, **kwargs)
+ # triplot.__doc__ = mtri.triplot.__doc__
diff -ur matplotlib-2.2.2/lib/matplotlib/pyplot.py host/matplotlib-2.2.2/lib/matplotlib/pyplot.py
--- matplotlib-2.2.2/lib/matplotlib/pyplot.py 2018-03-17 14:03:23.000000000 -0400
+++ host/matplotlib-2.2.2/lib/matplotlib/pyplot.py 2018-05-17 09:45:27.193765098 -0400
@@ -3630,85 +3630,85 @@
sci(ret.lines)
return ret
-# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
-@_autogen_docstring(Axes.tricontour)
-def tricontour(*args, **kwargs):
- ax = gca()
- # Deprecated: allow callers to override the hold state
- # by passing hold=True|False
- washold = ax._hold
- hold = kwargs.pop('hold', None)
- if hold is not None:
- ax._hold = hold
- from matplotlib.cbook import mplDeprecation
- warnings.warn("The 'hold' keyword argument is deprecated since 2.0.",
- mplDeprecation)
- try:
- ret = ax.tricontour(*args, **kwargs)
- finally:
- ax._hold = washold
- if ret._A is not None: sci(ret)
- return ret
-
-# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
-@_autogen_docstring(Axes.tricontourf)
-def tricontourf(*args, **kwargs):
- ax = gca()
- # Deprecated: allow callers to override the hold state
- # by passing hold=True|False
- washold = ax._hold
- hold = kwargs.pop('hold', None)
- if hold is not None:
- ax._hold = hold
- from matplotlib.cbook import mplDeprecation
- warnings.warn("The 'hold' keyword argument is deprecated since 2.0.",
- mplDeprecation)
- try:
- ret = ax.tricontourf(*args, **kwargs)
- finally:
- ax._hold = washold
- if ret._A is not None: sci(ret)
- return ret
+# # Autogenerated by boilerplate.py. Do not edit as changes will be lost.
+# @_autogen_docstring(Axes.tricontour)
+# def tricontour(*args, **kwargs):
+# ax = gca()
+# # Deprecated: allow callers to override the hold state
+# # by passing hold=True|False
+# washold = ax._hold
+# hold = kwargs.pop('hold', None)
+# if hold is not None:
+# ax._hold = hold
+# from matplotlib.cbook import mplDeprecation
+# warnings.warn("The 'hold' keyword argument is deprecated since 2.0.",
+# mplDeprecation)
+# try:
+# ret = ax.tricontour(*args, **kwargs)
+# finally:
+# ax._hold = washold
+# if ret._A is not None: sci(ret)
+# return ret
+
+# # Autogenerated by boilerplate.py. Do not edit as changes will be lost.
+# @_autogen_docstring(Axes.tricontourf)
+# def tricontourf(*args, **kwargs):
+# ax = gca()
+# # Deprecated: allow callers to override the hold state
+# # by passing hold=True|False
+# washold = ax._hold
+# hold = kwargs.pop('hold', None)
+# if hold is not None:
+# ax._hold = hold
+# from matplotlib.cbook import mplDeprecation
+# warnings.warn("The 'hold' keyword argument is deprecated since 2.0.",
+# mplDeprecation)
+# try:
+# ret = ax.tricontourf(*args, **kwargs)
+# finally:
+# ax._hold = washold
+# if ret._A is not None: sci(ret)
+# return ret
+
+# # Autogenerated by boilerplate.py. Do not edit as changes will be lost.
+# @_autogen_docstring(Axes.tripcolor)
+# def tripcolor(*args, **kwargs):
+# ax = gca()
+# # Deprecated: allow callers to override the hold state
+# # by passing hold=True|False
+# washold = ax._hold
+# hold = kwargs.pop('hold', None)
+# if hold is not None:
+# ax._hold = hold
+# from matplotlib.cbook import mplDeprecation
+# warnings.warn("The 'hold' keyword argument is deprecated since 2.0.",
+# mplDeprecation)
+# try:
+# ret = ax.tripcolor(*args, **kwargs)
+# finally:
+# ax._hold = washold
+# sci(ret)
+# return ret
+
+# # Autogenerated by boilerplate.py. Do not edit as changes will be lost.
+# @_autogen_docstring(Axes.triplot)
+# def triplot(*args, **kwargs):
+# ax = gca()
+# # Deprecated: allow callers to override the hold state
+# # by passing hold=True|False
+# washold = ax._hold
+# hold = kwargs.pop('hold', None)
+# if hold is not None:
+# ax._hold = hold
+# from matplotlib.cbook import mplDeprecation
+# warnings.warn("The 'hold' keyword argument is deprecated since 2.0.",
+# mplDeprecation)
+# try:
+# ret = ax.triplot(*args, **kwargs)
+# finally:
+# ax._hold = washold
-# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
-@_autogen_docstring(Axes.tripcolor)
-def tripcolor(*args, **kwargs):
- ax = gca()
- # Deprecated: allow callers to override the hold state
- # by passing hold=True|False
- washold = ax._hold
- hold = kwargs.pop('hold', None)
- if hold is not None:
- ax._hold = hold
- from matplotlib.cbook import mplDeprecation
- warnings.warn("The 'hold' keyword argument is deprecated since 2.0.",
- mplDeprecation)
- try:
- ret = ax.tripcolor(*args, **kwargs)
- finally:
- ax._hold = washold
- sci(ret)
- return ret
-
-# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
-@_autogen_docstring(Axes.triplot)
-def triplot(*args, **kwargs):
- ax = gca()
- # Deprecated: allow callers to override the hold state
- # by passing hold=True|False
- washold = ax._hold
- hold = kwargs.pop('hold', None)
- if hold is not None:
- ax._hold = hold
- from matplotlib.cbook import mplDeprecation
- warnings.warn("The 'hold' keyword argument is deprecated since 2.0.",
- mplDeprecation)
- try:
- ret = ax.triplot(*args, **kwargs)
- finally:
- ax._hold = washold
-
- return ret
+# return ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_autogen_docstring(Axes.violinplot)
\ No newline at end of file
diff -ur matplotlib-2.2.2/lib/matplotlib/backends/backend_agg.py matplotlib-2.2.2/lib/matplotlib/backends/backend_agg.py
--- a/lib/matplotlib/backends/backend_agg.py 2018-03-17 14:03:23.000000000 -0400
+++ b/lib/matplotlib/backends/backend_agg.py 2018-05-17 09:43:34.710665159 -0400
@@ -24,7 +24,10 @@
import six
-import threading
+try:
+ import threading
+except ImportError:
+ import dummy_threading as threading
import numpy as np
from collections import OrderedDict
from math import radians, cos, sin
diff -ur matplotlib-2.2.2/lib/matplotlib/font_manager.py matplotlib-2.2.2/lib/matplotlib/font_manager.py
--- a/lib/matplotlib/font_manager.py 2018-03-17 14:03:23.000000000 -0400
+++ b/lib/matplotlib/font_manager.py 2018-05-16 16:56:49.399466649 -0400
@@ -48,7 +48,10 @@
import json
import os
import sys
-from threading import Timer
+try:
+ from threading import Timer
+except ImportError:
+ from dummy_threading import Timer
import warnings
import logging
diff -ur matplotlib-2.2.2/lib/matplotlib/font_manager.py matplotlib-2.2.2/lib/matplotlib/font_manager.py
--- a/lib/matplotlib/font_manager.py 2018-03-17 14:03:23.000000000 -0400
+++ b/lib/matplotlib/font_manager.py 2018-05-16 16:56:49.399466649 -0400
@@ -416,11 +419,17 @@
sfnt2 = sfnt.get((1,0,0,2))
sfnt4 = sfnt.get((1,0,0,4))
if sfnt2:
- sfnt2 = sfnt2.decode('mac_roman').lower()
+ try:
+ sfnt2 = sfnt2.decode('mac_roman').lower()
+ except LookupError:
+ sfnt2 = sfnt2.decode('latin1').lower()
else:
sfnt2 = ''
if sfnt4:
- sfnt4 = sfnt4.decode('mac_roman').lower()
+ try:
+ sfnt4 = sfnt4.decode('mac_roman').lower()
+ except LoopupError:
+ sfnt4 = sfnt4.decode('latin1').lower()
else:
sfnt4 = ''
if sfnt4.find('oblique') >= 0:
\ No newline at end of file
diff -ur matplotlib-2.2.2/src/_png.cpp host/matplotlib-2.2.2/src/_png.cpp
--- matplotlib-2.2.2/src/_png.cpp 2018-03-17 14:03:23.000000000 -0400
+++ host/matplotlib-2.2.2/src/_png.cpp 2018-05-16 17:37:38.065033586 -0400
@@ -774,6 +774,10 @@
INITERROR;
}
+ volatile long x;
+ x = (long)malloc(0);
+ free((void*)x);
+
import_array();
if (PyModule_AddIntConstant(m, "PNG_FILTER_NONE", PNG_FILTER_NONE) ||
diff -ur matplotlib-2.2.2/lib/matplotlib/figure.py matplotlib-2.2.2/lib/matplotlib/figure.py
--- a/lib/matplotlib/figure.py 2018-03-05 23:47:09.000000000 -0500
+++ b/lib/matplotlib/figure.py 2018-05-17 10:46:52.355306452 -0400
@@ -420,6 +420,17 @@
from matplotlib.backends import backend_webagg
return backend_webagg.ipython_inline_display(self)
+ def _repr_html_(self):
+ from js import document
+ import io
+ import base64
+ png_data = io.BytesIO()
+ self.savefig(png_data, format='png')
+ img = document.createElement('img')
+ img.src = 'data:image/png;base64,' + \
+ base64.b64encode(png_data.getvalue()).decode('ascii')
+ return img
+
def show(self, warn=True):
"""
If using a GUI backend with pyplot, display the figure window.
\ No newline at end of file
PYODIDE_ROOT=$(abspath ..)
include ../Makefile.envs
PYPARSINGVERSION=2.2.0
ROOT=$(abspath .)
SRC=$(ROOT)/pyparsing-$(PYPARSINGVERSION)
BUILD=$(SRC)/build/lib/dateutil
TARBALL=$(ROOT)/downloads/pyparsing-$(PYPARSINGVERSION).tgz
URL=https://files.pythonhosted.org/packages/3c/ec/a94f8cf7274ea60b5413df054f82a8980523efd712ec55a59e7c3357cf7c/pyparsing-2.2.0.tar.gz
all: $(BUILD)/__init__.py
clean:
-rm -fr downloads
-rm -fr $(SRC)
$(TARBALL):
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
wget -q -O $@ $(URL)
md5sum --quiet --check checksums || (rm $@; false)
$(SRC)/setup.py: $(TARBALL)
tar -C . -xf $(TARBALL)
touch $(SRC)/setup.py
$(BUILD)/__init__.py: $(ROOT)/.patched
( \
cd $(SRC) ; \
$(HOSTPYTHON) setup.py build ; \
touch build/lib/pyparsing.py \
)
$(ROOT)/.patched: $(SRC)/setup.py
cat patches/*.patch | (cd $(SRC) ; patch --binary -p1)
touch $@
0214e42d63af850256962b6744c948d9 downloads/pyparsing-2.2.0.tgz
diff -ur pyparsing-2.2.0/pyparsing.py pyparsing-2.2.0.bak/pyparsing.py
--- pyparsing-2.2.0/pyparsing.py 2017-03-05 21:06:06.000000000 -0500
+++ pyparsing-2.2.0.bak/pyparsing.py 2018-05-17 11:25:17.960270391 -0400
@@ -80,7 +80,10 @@
try:
from _thread import RLock
except ImportError:
- from threading import RLock
+ try:
+ from threading import RLock
+ except ImportError:
+ from dummy_threading import RLock
try:
from collections import OrderedDict as _OrderedDict
......@@ -3,6 +3,7 @@ var languagePluginLoader = new Promise((resolve, reject) => {
const packages = {
'dateutil': [],
'matplotlib': ['numpy', 'dateutil', 'pytz'],
'numpy': [],
'pandas': ['numpy', 'dateutil', 'pytz'],
'pytz': [],
......@@ -118,15 +119,23 @@ var languagePluginLoader = new Promise((resolve, reject) => {
render: (val) => {
let div = document.createElement('div');
div.className = 'rendered_html';
var element;
if ('_repr_html_' in val) {
div.appendChild(new DOMParser().parseFromString(
val._repr_html_(), 'text/html').body.firstChild);
let result = val._repr_html_();
if (typeof result === 'string') {
div.appendChild(new DOMParser().parseFromString(
result, 'text/html').body.firstChild);
element = div;
} else {
element = result;
}
} else {
let pre = document.createElement('pre');
pre.textContent = window.pyodide.repr(val);
div.appendChild(pre);
element = div;
}
return div;
return element;
}
});
}
......
def test_matplotlib(selenium):
selenium.load_package("matplotlib")
img = selenium.run(
"from matplotlib import pyplot as plt\n"
"plt.plot([1,2,3])\n"
"plt.gcf()._repr_html_().src"
)
assert img.startswith('data:image/png;base64,')
assert len(img) == 42
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