azavea / python-omgeo

OMGeocoder - A python geocoding abstraction layer
http://python-omgeo.readthedocs.io/en/latest/
MIT License
36 stars 14 forks source link

Add HTTP/S support via Requests library #53

Closed hectcastro closed 6 years ago

hectcastro commented 6 years ago

Replace use of urllib and urllib2 with Requests library while attempting to maintain backwards compatibility.

Fixes #52


Testing

(Added @KlaasH because this change impacts Cicero.)

KlaasH commented 6 years ago

Now that there's a dependency, the empty requirements.txt goes from slightly puzzling to deceptive. We should either add the requests requirement to it or figure out a way to make the Read The Docs build work without it (it was added to fix a doc build crash here).

hectcastro commented 6 years ago

I tried to address the requirements.txt issue using the suggestions here. It looks like adding a period to the requirements.txt file leads to the installation of dependencies specified in setup.py:

See: https://github.com/azavea/python-omgeo/pull/53/commits/177224bce261be87ab5a498317ca42eb7dec22e6

$ cat requirements.txt 
.
$ pip install -r requirements.txt                                                                                
Processing /Users/hcastro/Projects/python-omgeo
Collecting requests>=2.18 (from python-omgeo==5.1.0->-r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/cc/15/e1c318dbc20032ffbe5628837ca0de2d5b116ffd1b849c699634010f6a5d/requests-2.19.0-py2.py3-none-any.whl (91kB)             
    100% |████████████████████████████████| 92kB 1.6MB/s
Collecting certifi>=2017.4.17 (from requests>=2.18->python-omgeo==5.1.0->-r requirements.txt (line 1))                                                                           
  Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl                 
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.18->python-omgeo==5.1.0->-r requirements.txt (line 1))                                                                        
  Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl                     
Collecting urllib3<1.24,>=1.21.1 (from requests>=2.18->python-omgeo==5.1.0->-r requirements.txt (line 1))                                                                        
  Downloading https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl (133kB)               
    100% |████████████████████████████████| 143kB 2.7MB/s
Collecting idna<2.8,>=2.5 (from requests>=2.18->python-omgeo==5.1.0->-r requirements.txt (line 1))                                                                               
  Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)                    
    100% |████████████████████████████████| 61kB 2.2MB/s
Building wheels for collected packages: python-omgeo
  Running setup.py bdist_wheel for python-omgeo ... done
  Stored in directory: /Users/hcastro/Library/Caches/pip/wheels/7e/d6/78/68f335908ad47fadd1b70d989ca9ef8304ed4e2db2ecef1a8b                                                      
Successfully built python-omgeo
Installing collected packages: certifi, chardet, urllib3, idna, requests, python-omgeo
Successfully installed certifi-2018.4.16 chardet-3.0.4 idna-2.7 python-omgeo-5.1.0 requests-2.19.0 urllib3-1.23                  
hectcastro commented 6 years ago

Some clarification, there aren't any SSL failures on develop with any of the APIs? This is just intended to be proactive, right?

There aren't any failures with the CAs being used for Google API endpoints, but the test endpoints for testing compatibility with future CAs does fail (although, not because of CA issues, but because Python 2.7.6 doesn't support SNI).

See: https://developers.google.com/maps/root-ca-faq#how-do-i-verify-if-my-certificate-store-needs-an-update