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

Fixed compatibility issue with pyproj 2.0+ #454

Merged
merged 5 commits into from
Apr 23, 2019
Merged

Fixed compatibility issue with pyproj 2.0+ #454

merged 5 commits into from
Apr 23, 2019

Conversation

pandrey-fr
Copy link
Contributor

Starting with version 2.0, the pyproj.pyproj_datadir constant was deprecated in favor of the pyproj.datadir.get_data_dir() constant.
A minor alteration to Basemap's __init__.py file allows compatibility with both the newer and older versions of pyproj regarding this breaking change.

Starting with version 2.0, the `pyproj.pyproj_datadir` constant was deprecated in favor of the `pyproj.datadir.get_data_dir()` constant.
A minor alteration to Basemap's `__init__.py` file allows compatibility with both the newer and older versions of pyproj regarding this breaking change.
@WeatherGod
Copy link
Member

Hmm, doesn't seem to be working for some of the travis builds (other travis builds are failing due to not having Cython installed.... that seems to be unrelated, I hope).

@pandrey-fr
Copy link
Contributor Author

pandrey-fr commented Mar 13, 2019

The Python 2.6 and 3.4 travis builds failed to install pyproj because they (appear to) lack cython, which is unrelated to my fix (although it is indeed an issue).

For the other travis builds, I think it comes from the fact that epsg is not comprised in pyproj by default (I had this issue on my own machine, and copied the epsg file from /usr/share/proj to the /share/proj subfolder of my pyproj installation, which on the other hand contained most of the other projection files).

So, basically, we have to look into what other things changed with pyproj and how to remediate the issue...

@pandrey-fr
Copy link
Contributor Author

pandrey-fr commented Mar 13, 2019

An alternative could be to try and bypass the pyproj data directory in favor of either /usr/local/share/proj (on Linux) or the PROJ_LIB environment variable (on other platforms or in case the former does not exist). This is in fact what proj.4 does, and what pyproj would do if it did not comprise its own data directory (see this file), which for some reason seems not to include epsg, at least for the latest versions on Linux platforms.

Since version 2.0, pyproj comes with an internal data directory that is used in favor of the one set by the PROJ_LIB environment variable (or, on Linux, of the default proj folder set by PROJ.4). It appears this internal directory sometimes does not contain the epsg file (at least on Linux), which may however be found by looking up those other locations.

This commit therefore adds attempts to look up for the epsg file when it cannot be found in pyproj's internal datadir.
FileNotFoundError is not part of built-in exceptions in Python 2.
This commit allows to use it in Python 3, and replace it with a
RuntimeError in Python 2.
@pandrey-fr
Copy link
Contributor Author

pandrey-fr commented Mar 13, 2019

I updated the code with the previous idea, but the travis builds are still failing, as it appears that the epsg file is not found in any of the expected locations on the machines... I would say it is about a change in the installation of pyproj, but I have not looked it up yet.

@cgohlke
Copy link
Contributor

cgohlke commented Mar 17, 2019

I don't think the epsg file is distributed with "standard" PROJ 6 or pyproj 2. Why not simply include the file in the basemap data directory?

@pandrey-fr
Copy link
Contributor Author

I don't think the epsg file is distributed with "standard" PROJ 6 or pyproj 2. Why not simply include the file in the basemap data directory?

Thank you for confirming this; I will check the licensing of the file and commit a change to include it asap -- it the build passes, @WeatherGod will be able to judge whether it is pertinent to actually make this change to basemap or not.

@pandrey-fr
Copy link
Contributor Author

I have not had time to include the file (and change the code) yet, nor update legal mentions accordingly; but the terms of use of the espg seem to allow its distribution as part of basemap. They can be found here.

TODO: add license file regarding epsg, based
on terms of use, which are found here:
http://www.epsg.org/TermsOfUse.aspx
@pandrey-fr
Copy link
Contributor Author

As expected, adding the file directly as part of basemap fixes the issue, and travis builds succeed - or fail for unrelated issues that seem to be caused by Cython when compiling either pyproj or (for the nightly python version) numpy. I am no expert in Travis, but I would guess it has to do with the virtual machines' configuration...

On the other hand, I did not include a proper licensing of the epsg file (and used one that may be out of date as I did not download the latest from the epsg website). @WeatherGod (or somebody else), would you take care of that, as I am no legal expert nor am entirely clear about the organization of legal mentions in the package?

@pandrey-fr
Copy link
Contributor Author

I went through the travis file and the builds' output stacks, and it appears that:

  • 2.6 fails because of a Cython error
  • nightly fails for similar reasons (maybe due to the installation of cython in "no-compile" mode?)
  • 3.4 fails because it lacks a PROJ_DIR environment variable after starting to install pyproj, (which may be fixed by updating the mahcine's setup, adding an instruction to export said environment variable).

By the way, 2.6 is long-deprecated (as is 2.7, but I can get the point of maintaining it), and 3.4 has been deprecated after the update from March 18th, so do we really need to test for those systems, knowing that in fact people who might chose to stay on those systems can either stop updating their packages or figure out issues that are related to dependencies and not basemap itself?

@WeatherGod
Copy link
Member

So, the failures appear to be related to whenever we build using the internal libgeos. This is a completely separate problem, and I won't hold up this PR over it.

@WeatherGod
Copy link
Member

Where did you download the epsg file from? I need to determine its source in order to place the right license file in the source tree.

@pandrey-fr
Copy link
Contributor Author

Where did you download the epsg file from? I need to determine its source in order to place the right license file in the source tree.

To be honest, I had it on my computer and do not remember exactly where it came from, but probably from an older version of PROJ.4. I went through the history of their repository, and found that the latest version to include epsg coordinates as a flat file is 5.2 ; I am therefore going to make a commit replacing the file I initially updated with the one found here.

On the other hand, I registered on the epsg website in hope to download the latest version of the file, but it now seems to only be distributed as a microsoft database file, which would need conversion to proj4 format - and I don't know how to do that.

@pandrey-fr
Copy link
Contributor Author

I think we should thus refer to PROJ.4's licensing, which can be found here for the version I took the file from, and states that everything (including data files) can be re-used.

@WeatherGod WeatherGod merged commit fa8fc4f into matplotlib:master Apr 23, 2019
@WeatherGod
Copy link
Member

License file was added in PR #460

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants