Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build GMT master instead of using conda-forge #261

Merged
merged 24 commits into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2bd6da9
Test gmt-python with GMT master branch
seisman Dec 4, 2018
3779968
Fix stickler-ci
seisman Jan 16, 2019
a04bf4b
Fix travis.yml
seisman Jan 16, 2019
af904da
Check GMT install
seisman Jan 16, 2019
f19318e
Source gmt install script
seisman Jan 16, 2019
7950c56
Update the build script with the new GMT build
leouieda Jan 21, 2019
988bab0
Avoid the name conflict with the Python package
leouieda Jan 21, 2019
d3e76f0
No line break
leouieda Jan 21, 2019
82cabf6
Delegate building GMT to a helper script
leouieda Jan 21, 2019
69b740a
Build on testing
leouieda Jan 21, 2019
436ea2d
Get around cloning into the cached directory
leouieda Jan 21, 2019
98c2185
Set the environment variables globaly
leouieda Jan 21, 2019
ae6029b
Don't try to set TEST
leouieda Jan 21, 2019
2d85ad6
Try using the experimental branch from GMT
leouieda Jan 21, 2019
3dd2719
Revert back to the master branch of GMT
leouieda Jan 21, 2019
be4378d
Remove GMT and twine from the dependencies
leouieda Jan 21, 2019
58da665
Merge branch 'master' into test-gmt-master
leouieda Jan 21, 2019
1ef43f3
Fix failure of basemap
leouieda Jan 21, 2019
d74dc6f
Merge branch 'test-gmt-master' of github.com:GenericMappingTools/gmt-…
leouieda Jan 21, 2019
f72a706
The lib dir is lib64
leouieda Jan 21, 2019
b977d70
Set the library path using GMT_LIBRARY_PATH
leouieda Jan 21, 2019
87a6517
Update install docs
leouieda Jan 21, 2019
b115d20
Remove unnecessary dependencies
leouieda Jan 21, 2019
0f01277
Try to not build GMT with debug or testing
leouieda Jan 21, 2019
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
52 changes: 46 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ language: generic
# Use the container builds so we don't need sudo priviledges
sudo: false

cache:
directories:
- gmt-master/build

# Only build pushes to the master branch and tags. This avoids the double
# builds than happen when working on a branch instead of a fork.
branches:
Expand All @@ -14,6 +18,34 @@ branches:
# Regex to build tagged commits with version numbers
- /\d+\.\d+(\.\d+)?(\S*)?$/

# Set the Ubuntu version for the Linux builds
dist: xenial

# GMT dependencies for the Linux and OSX builds
addons:
apt:
packages:
- cmake
- build-essential
- libcurl4-gnutls-dev
- libnetcdf-dev
- libgdal1-dev
- libfftw3-dev
- libpcre3-dev
- liblapack-dev
- ghostscript
- curl
homebrew:
packages:
- cmake
- curl
- netcdf
- gdal
- fftw
- pcre2
- ghostscript
- curl

# Define environment variables common to all builds
env:
global:
Expand All @@ -23,12 +55,15 @@ env:
# TWINE_PASSWORD to deploy to PyPI
- secure: "md4fgPt9RC/sCoN5//5PcNHLUd9gWQGewV5hFpWW88MRTjxTng1Zfs8r7SqlF2AkEEepFfyzq0BEe9c3FMAnFbec3KmqdlQen4V8xDbLrcTlvkPlTrYGbAScUvdhhqojB//hMHoTD4KvxAv9CiUwFBO4hCMmj2buWHUbV9Ksu5WCW9mF/gkt/hIuYAU6Mbwt8PiYyMgUpzMHO1vruofcWRaVnvKwmBqHB0ae86D4/drpwn4CWjlM12WUnphT2bssiyPkw24FZtCN6kPVta6bLZKBxu0bZpw2vbXuUG+Yh19Q4mp8wNYT3XSHJf8Hl5LfujF48+cLWu+6rlCkdcelyVylhWLFc3rGOONAv4G8jWW2yNSz/bLQfJnMpd81fQEu5eySmFxB7mdB0uyKpvIG1jMJQ73LlYKakKLAPdYhMFyQAHoX9gvCE3S4QR95DBMi5gM/pZubOCcMLdjPHB5JKpJHSjxbOzyVwgmsUIEgd5Bi2vZvvYQXn1plk4xpQ3PhXc+/gi33bzY89mKcfOn0HJ2pD1vLqDXRCBsMCakoLZ0JB/6bacaz4FngbsGWuQ+I1cz20lJGL/MSi9bW1G7Uoidt3GXXWDmXrWt70vIXlLIxr8XV0Mu/rPbauGgWE+ZSYEfvdM5sP+FNF7vQ5de+Fkvzg5Z3tTfR+O1W+d7+vM4="
- TWINE_USERNAME=Leonardo.Uieda
# Paths for GMT installation
- INSTALLDIR="$HOME/gmt-install-dir"
- COASTLINEDIR="$INSTALLDIR/coast"
- PATH="$INSTALLDIR/bin:$PATH"
- LD_LIBRARY_PATH="$INSTALLDIR/lib:$LD_LIBRARY_PATH"
- GMT_LIBRARY_PATH="$INSTALLDIR/lib"
# The file with the listed requirements to be installed by conda
- CONDA_REQUIREMENTS=requirements.txt
- CONDA_REQUIREMENTS_DEV=requirements-dev.txt
# Get GMT6 from conda-forge development channel
- CONDA_INSTALL_EXTRA="gmt=6.0.0*"
- CONDA_EXTRA_CHANNEL=conda-forge/label/dev
# These variables control which actions are performed in a build
- TEST=false
- CHECK=false
Expand All @@ -44,8 +79,7 @@ matrix:
env:
- PYTHON=3.6
- CHECK=true
# Don't need to install everything just to run the style checks
- CONDA_INSTALL_EXTRA="black flake8 pylint"
- CONDA_INSTALL_EXTRA="black flake8 pylint=2.2.2"
- CONDA_REQUIREMENTS=""
- CONDA_REQUIREMENTS_DEV=""
- name: "Linux - Python 3.7"
Expand All @@ -54,14 +88,15 @@ matrix:
- PYTHON=3.7
- TEST=true
- BUILD_DOCS=true
- name: "Linux - Python 3.6 (also deploys)"
- name: "Linux - Python 3.6 (deploy)"
os: linux
env:
- PYTHON=3.6
- TEST=true
- BUILD_DOCS=true
- DEPLOY_DOCS=true
- DEPLOY_PYPI=true
- CONDA_INSTALL_EXTRA="twine"
- name: "Mac - Python 3.7"
os: osx
env:
Expand All @@ -76,6 +111,11 @@ matrix:
- BUILD_DOCS=true

before_install:
# Build and install GMT from the master branch
- if [ "$TEST" == "true" ]; then
bash helpers/build-gmt-master.sh;
fi
- cd "$TRAVIS_BUILD_DIR"
# Get the Fatiando CI scripts
- git clone https://github.com/fatiando/continuous-integration.git
# Download and install miniconda and setup dependencies
Expand Down
59 changes: 12 additions & 47 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Installing

.. note::

**This package is in early stages of development.**
🚨 **This package is in early stages of design and implementation.** 🚨

We welcome any feedback and ideas!
Let us know by submitting
Expand All @@ -29,23 +29,14 @@ doesn't interfere with any other Python installations in your system.
Which GMT?
----------

You'll need GMT 6, the latest development version available from
You'll need the latest development version available from
`the GitHub repository <https://github.com/GenericMappingTools/gmt>`__.
GMT/Python is based on GMT 6, **which has not yet been officially released**.

We need the very latest GMT since there are many changes being made to the C API in
We need the very latest GMT since there are many changes being made to GMT itself in
response to the development of GMT/Python, mainly the new
`modern execution mode <http:https://gmt.soest.hawaii.edu/projects/gmt/wiki/Modernization>`__.

**GMT 6 has not been officially released** yet.
However, we provide compiled conda packages of the development version for Linux and Mac
through `conda-forge <https://github.com/conda-forge/gmt-feedstock/>`__.
You can also
`build GMT from source <http:https://gmt.soest.hawaii.edu/projects/gmt/wiki/BuildingGMT>`__
instead,
which is untested and we would love to get feedback from anyone who tries.

We recommend following the instructions further on to install GMT 6.


Dependencies
------------
Expand All @@ -62,44 +53,18 @@ The following are optional (but recommended) dependencies:
* `IPython <https://ipython.org/>`__: For embedding the figures in Jupyter notebooks.


Installing GMT and other dependencies
-------------------------------------

Before installing GMT/Python, we must install GMT itself along with the other
dependencies.
The easiest way to do this is using the ``conda`` package manager.
We recommend working in an isolated
`conda environment <https://conda.io/docs/user-guide/tasks/manage-environments.html>`__
to avoid issues with competing versions of GMT and its dependencies.

First, we must configure conda to get packages from the
`conda-forge channel <https://conda-forge.org/>`__ (the order is important)::

conda config --prepend channels conda-forge/label/dev
conda config --prepend channels conda-forge
Installing GMT
--------------

Now we can create a new conda environment with Python and all our dependencies installed
(we'll call it ``gmt-python`` but you can change it to whatever you want)::

conda create --name gmt-python python=3.6 pip numpy pandas xarray packaging ipython gmt=6.0.0*

Activate the environment by running::

source activate gmt-python

From now on, all commands will take place inside the environment and won't affect your
default installation.
Unfortunately, you'll have to build GMT from source in order to get GMT/Python working.
Please follow the instructions at http:https://gmt.soest.hawaii.edu/projects/gmt/wiki/BuildingGMT

.. note::

**Currently, this only works on Linux and macOS.**

We don't have a GMT conda package for Windows
(`we're working on it <https://github.com/conda-forge/gmt-feedstock>`__).
If you know how to
build GMT from source, you can do that instead of the ``conda install
gmt``. This is untested and we would love to get feedback from anyone who
tries.
We used to maintain conda packages for the latest GMT. That caused many problems and
was very difficult to maintain updated. We have opted to not do that anymore so that
we can develop more quickly. Once GMT 6 is officially released, we'll have conda
packages available again. Please bear with us.


Installing GMT/Python
Expand Down
3 changes: 0 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: gmt-python
channels:
- conda-forge
- conda-forge/label/dev
dependencies:
- python=3.6
- pip
- gmt=6.0.0*
- numpy
- pandas
- xarray
Expand All @@ -25,4 +23,3 @@ dependencies:
- sphinx_rtd_theme
- nbsphinx
- numpydoc
- twine
8 changes: 0 additions & 8 deletions gmt/base_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,6 @@ def basemap(self, **kwargs):
{J}
{R}
{B}
D : str
``'[unit]xmin/xmax/ymin/ymax[r][+sfile][+t]'``
Draw a simple map insert box on the map. Requires *F*.
F : bool or str
Without further options, draws a rectangular border around any map
insert (*D*), map scale (*L*) or map rose (*T*).
L : str
``'[g|j|J|n|x]refpoint'``
Draws a simple map scale centered on the reference point specified.
Expand All @@ -466,8 +460,6 @@ def basemap(self, **kwargs):
kwargs = self._preprocess(**kwargs)
if not ("B" in kwargs or "L" in kwargs or "T" in kwargs):
raise GMTInvalidInput("At least one of B, L, or T must be specified.")
if "D" in kwargs and "F" not in kwargs:
raise GMTInvalidInput("Option D requires F to be specified as well.")
with Session() as lib:
lib.call_module("basemap", build_arg_string(kwargs))

Expand Down
Binary file removed gmt/tests/baseline/test_basemap_d.png
Binary file not shown.
15 changes: 0 additions & 15 deletions gmt/tests/test_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,6 @@ def test_basemap_required_args():
fig.basemap(R="10/70/-3/8", J="X4i/3i")


@pytest.mark.mpl_image_compare
def test_basemap_d():
"Make sure the D option works"
fig = Figure()
fig.basemap(R="10/70/-300/800", J="X3i/5i", B="af", D="30/35/-200/500", F=True)
return fig


def test_basemap_d_raises():
"Make sure the D raises an error when F not given."
fig = Figure()
with pytest.raises(GMTInvalidInput):
fig.basemap(R="10/70/-300/800", J="X3i/5i", B="af", D="30/35/-200/500")


@pytest.mark.mpl_image_compare
def test_basemap():
"Create a simple basemap plot"
Expand Down
6 changes: 3 additions & 3 deletions gmt/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_figure_region_country_codes():
def test_figure_savefig_exists():
"Make sure the saved figure has the right name"
fig = Figure()
fig.basemap(region="10/70/-300/800", J="X3i/5i", B="af", D="30/35/-200/500", F=True)
fig.basemap(region="10/70/-300/800", J="X3i/5i", B="af")
prefix = "test_figure_savefig_exists"
for fmt in "png pdf jpg bmp eps tif".split():
fname = ".".join([prefix, fmt])
Expand All @@ -60,7 +60,7 @@ def test_figure_savefig_exists():
def test_figure_savefig_transparent():
"Check if fails when transparency is not supported"
fig = Figure()
fig.basemap(region="10/70/-300/800", J="X3i/5i", B="af", D="30/35/-200/500", F=True)
fig.basemap(region="10/70/-300/800", J="X3i/5i", B="af")
prefix = "test_figure_savefig_transparent"
for fmt in "pdf jpg bmp eps tif".split():
fname = ".".join([prefix, fmt])
Expand Down Expand Up @@ -112,6 +112,6 @@ def mock_psconvert(*args, **kwargs): # pylint: disable=unused-argument
def test_figure_show():
"Test that show creates the correct file name and deletes the temp dir"
fig = Figure()
fig.basemap(R="10/70/-300/800", J="X3i/5i", B="af", D="30/35/-200/500", F=True)
fig.basemap(R="10/70/-300/800", J="X3i/5i", B="af")
img = fig.show(width=800)
assert img.width == 800
16 changes: 16 additions & 0 deletions helpers/build-gmt-master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Download and build the GMT master branch. Used by TravisCI.

set -e

mkdir -p "$INSTALLDIR"
mkdir -p "$COASTLINEDIR"
git clone --depth=1 --branch=master https://github.com/GenericMappingTools/gmt.git tmp
Copy link
Member Author

Choose a reason for hiding this comment

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

Why not clone it to gmt-master directly? Any side-effects?

Copy link
Member

Choose a reason for hiding this comment

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

It's because of the cache. I'm having Travis cache gmt-master/build so we don't recompile things that didn't change. But git won't checkout into an existing directory.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it.

mkdir -p gmt-master
cp -r tmp/* gmt-master
rm -rf tmp
cd gmt-master
bash ci/download-coastlines.sh
TEST=false bash ci/build-gmt.sh

set +e
2 changes: 0 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ sphinx
sphinx_rtd_theme
nbsphinx
numpydoc
twine
# The following are installed for checking possible conflicts
basemap