Skip to content

Commit 13bac6c

Browse files
akshmakovleouieda
authored andcommitted
Pass in NULL pointer to GMT_Get_Enum (GenericMappingTools#224)
The GMT API added a void API pointer to GMT_Get_Enum. We pass in a NULL pointer because we need to call it in order to create a session (and get the API pointer). It's not used in the function, just there for consistency. Fixes GenericMappingTools#222
1 parent efabb47 commit 13bac6c

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ env:
2323
- DEPLOY_DOCS=false
2424
- DEPLOY_PYPI=false
2525
- CONDA_REQUIREMENTS="requirements.txt"
26+
# Get GMT6 from the development channel
27+
- CONDA_EXTRA_CHANNEL=conda-forge/label/dev
2628

2729
matrix:
2830
# Build under the following configurations
@@ -55,8 +57,6 @@ before_install:
5557
# Download and install miniconda and setup dependencies
5658
# Need to source the script to set the PATH variable globaly
5759
- source continuous-integration/travis/setup-miniconda.sh
58-
# Install GMT from the dev channel to get development builds of GMT 6
59-
- conda install --yes --quiet -c conda-forge/label/dev gmt=6.0.0a*
6060
- if [ "$COVERAGE" == "true" ]; then
6161
pip install codecov codacy-coverage codeclimate-test-reporter;
6262
fi
@@ -70,7 +70,9 @@ install:
7070

7171
script:
7272
# Check code for style and lint for code quality
73+
# Black is Python 3.6 only so it can't be in the requirements file.
7374
- if [ "$CHECK" == "true" ]; then
75+
conda install --yes --quiet black python=$PYTHON;
7476
make check;
7577
fi
7678
# Run the test suite. Make pytest report any captured output on stdout or stderr.

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: gmt-python
22
channels:
33
- conda-forge
44
- conda-forge/label/dev
5-
- defaults
65
dependencies:
76
- python=3.6
87
- pip

gmt/clib/session.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,17 @@ def __getitem__(self, name):
214214
215215
"""
216216
c_get_enum = self.get_libgmt_func(
217-
"GMT_Get_Enum", argtypes=[ctp.c_char_p], restype=ctp.c_int
217+
"GMT_Get_Enum", argtypes=[ctp.c_void_p, ctp.c_char_p], restype=ctp.c_int
218218
)
219219

220-
value = c_get_enum(name.encode())
220+
# The C lib introduced the void API pointer to GMT_Get_Enum so that it's
221+
# consistent with other functions. It doesn't use the pointer so we can pass in
222+
# None (NULL pointer). We can't give it the actual pointer because we need to
223+
# call GMT_Get_Enum when creating a new API session pointer (chicken-and-egg
224+
# type of thing).
225+
session = None
226+
227+
value = c_get_enum(session, name.encode())
221228

222229
if value is None or value == -99999:
223230
raise GMTCLibError("Constant '{}' doesn't exits in libgmt.".format(name))
@@ -336,6 +343,7 @@ def print_func(file_pointer, message): # pylint: disable=unused-argument
336343

337344
padding = self["GMT_PAD_DEFAULT"]
338345
session_type = self["GMT_SESSION_EXTERNAL"]
346+
339347
session = c_create_session(name.encode(), padding, session_type, print_func)
340348

341349
if session is None:

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GMT isn't included because it needs to be downloaded from a separate channel
1+
gmt=6.0.0*
22
numpy
33
pandas
44
xarray
@@ -11,7 +11,6 @@ pytest
1111
pytest-cov
1212
pytest-mpl
1313
coverage
14-
black
1514
pylint
1615
sphinx
1716
sphinx_rtd_theme
@@ -20,3 +19,5 @@ numpydoc
2019
twine
2120
# The following are installed for checking possible conflicts
2221
basemap
22+
# Black is not included because it requires Python 3.6
23+
#black

0 commit comments

Comments
 (0)