From f9b39f2505e64f4808d2f93441987a98e9a118fd Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 14 Sep 2017 16:28:26 +0800 Subject: [PATCH 1/5] support python3 --- dub.json | 2 +- python/prebuild.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dub.json b/dub.json index beb426b..8c7b499 100644 --- a/dub.json +++ b/dub.json @@ -8,5 +8,5 @@ "targetType": "staticLibrary", "targetPath": "build", "workingDirectory": "build", - "preBuildCommands": ["python $PACKAGE_DIR/python/prebuild.py $PACKAGE_DIR"] + "preBuildCommands": ["$MATPLOTLIB_D_PYTHON $PACKAGE_DIR/python/prebuild.py $PACKAGE_DIR"] } diff --git a/python/prebuild.py b/python/prebuild.py index 7a30fb1..caa7c35 100644 --- a/python/prebuild.py +++ b/python/prebuild.py @@ -23,9 +23,9 @@ def gen_pyplot_functions(dub_root): generate 'pyplot_functions.txt' for matplotlibd.pyplot. ''' import matplotlib.pyplot - from string import lowercase + from string import ascii_lowercase - functions = filter(lambda i: i[0] != '_' or i[0] in lowercase, + functions = filter(lambda i: i[0] != '_' or i[0] in ascii_lowercase, extract_function_names(matplotlib.pyplot)) with open(dub_root + "/views/pyplot_functions.txt", "w") as f: From b7ef13cd7ceb8ad48eb99504ce3d860954fd2dc1 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 14 Sep 2017 16:28:47 +0800 Subject: [PATCH 2/5] update for matplotlib 2.0.2 --- source/matplotlibd/pyplot.d | 6 +++++- views/pyplot_functions.txt | 11 ++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/source/matplotlibd/pyplot.d b/source/matplotlibd/pyplot.d index 5d7949f..123485c 100644 --- a/source/matplotlibd/pyplot.d +++ b/source/matplotlibd/pyplot.d @@ -8,8 +8,12 @@ string py_script = "import matplotlib.pyplot as plt\n"; immutable string plt_funcs = (){ import std.string: splitLines; + import std.meta : staticMap, aliasSeqOf; + + enum isValidIdentifier(string s) = __traits(compiles, { mixin(`auto ` ~ s ~ ` = 3;` ); }); + enum fixIdentifier(string s) = isValidIdentifier!s ? s : s ~ '_'; + auto method_names = staticMap!(fixIdentifier, aliasSeqOf!(import("pyplot_functions.txt").splitLines)); - string[] method_names = import("pyplot_functions.txt").splitLines; string plt_funcs; foreach(name; method_names) { diff --git a/views/pyplot_functions.txt b/views/pyplot_functions.txt index 0aec43d..e928061 100644 --- a/views/pyplot_functions.txt +++ b/views/pyplot_functions.txt @@ -36,15 +36,6 @@ SubplotTool Text TickHelper Widget -_auto_draw_if_interactive -_autogen_docstring -_backend_selection -_imread -_imsave -_setp -_setup_pyplot_info_docstrings -_show -_string_to_bool acorr angle_spectrum annotate @@ -82,6 +73,7 @@ csd cycler dedent delaxes +deprecated disconnect draw draw_all @@ -145,6 +137,7 @@ matshow minorticks_off minorticks_on new_figure_manager +nipy_spectral over pause pcolor From f66a4f145e61748645cd9f487d0745c61892d67c Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 19 Sep 2017 12:35:16 +0100 Subject: [PATCH 3/5] fix travis and test for python3 --- .travis.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7a5ee5b..f89d83d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +sudo: false + os: - linux - osx @@ -5,13 +7,24 @@ os: language: d d: - - ldc2 + - ldc - dmd -before_install: - - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install python-tk; fi - - sudo pip install matplotlib +env: + - PYTHON_VER=2 + - PYTHON_VER=3 +addons: + apt: + packages: + - python-tk + - python3-tk + - python-pip + - python3-pip + +before_install: + - if [ $TRAVIS_OS_NAME = osx ]; then brew install python$PYTHON_VER; fi + - pip$PYTHON_VER install matplotlib --user script: - - dub test --compiler=${DC} + - MATPLOTLIB_D_PYTHON=python$PYTHON_VER dub test --compiler=${DC} From b98fdf425e2ea44fdd996e039acbc8cdbce824d8 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 19 Sep 2017 13:20:51 +0100 Subject: [PATCH 4/5] simplify travis deps --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f89d83d..9ecd1e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,12 +19,11 @@ addons: packages: - python-tk - python3-tk - - python-pip - - python3-pip + - python-matplotlib + - python3-matplotlib before_install: - - if [ $TRAVIS_OS_NAME = osx ]; then brew install python$PYTHON_VER; fi - - pip$PYTHON_VER install matplotlib --user + - if [ $TRAVIS_OS_NAME = osx ]; then brew install python$PYTHON_VER homebrew/science/matplotlib; fi script: - MATPLOTLIB_D_PYTHON=python$PYTHON_VER dub test --compiler=${DC} From 9f0712bbb291678266df793699718a44ce62596c Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 28 Sep 2017 15:54:39 +0100 Subject: [PATCH 5/5] split brew installs --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9ecd1e7..ba1bf1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ addons: - python3-matplotlib before_install: - - if [ $TRAVIS_OS_NAME = osx ]; then brew install python$PYTHON_VER homebrew/science/matplotlib; fi + - if [ $TRAVIS_OS_NAME = osx ]; then brew install python$PYTHON_VER; brew install homebrew/science/matplotlib; fi script: - MATPLOTLIB_D_PYTHON=python$PYTHON_VER dub test --compiler=${DC}