Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
sudo: false

os:
- linux
- osx

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-matplotlib
- python3-matplotlib

before_install:
- if [ $TRAVIS_OS_NAME = osx ]; then brew install python$PYTHON_VER; brew install homebrew/science/matplotlib; fi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis seems to fail due to this line. It seems better to specify Python's version by using pyenv, but I have no experience on travis with pyenv. Can you solve this?


script:
- dub test --compiler=${DC}
- MATPLOTLIB_D_PYTHON=python$PYTHON_VER dub test --compiler=${DC}
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recognize that "preBuildCommands" is executed when users install this library by using dub. Is this wrong? If it's right, we had better not use any environment variables to specify the version of Python.

}
4 changes: 2 additions & 2 deletions python/prebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion source/matplotlibd/pyplot.d
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 2 additions & 9 deletions views/pyplot_functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -82,6 +73,7 @@ csd
cycler
dedent
delaxes
deprecated
disconnect
draw
draw_all
Expand Down Expand Up @@ -145,6 +137,7 @@ matshow
minorticks_off
minorticks_on
new_figure_manager
nipy_spectral
over
pause
pcolor
Expand Down