UrDHT / PyUrDHT

Python reference implementation
11 stars 3 forks source link

Confusion between importing vendored 'requests' module and installed module #58

Closed nwautomator closed 8 years ago

nwautomator commented 9 years ago

Looks like in some places we 'import myrequests' (the vendored version) and in others we 'import requests' (the external library dependency). Should we change all references from 'requests' to 'myrequests' or vice-versa (which would require a rename of the 'myrequests' directory to 'requests'). I think the PYTHONPATH variable references the current directory first (in which case we could just use our vendored version), but I'm not sure how that works among different operating systems.

FWIW, on my Linux machine:

Python 3.4.3 (default, Mar 25 2015, 17:13:50) 
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib/python34.zip', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-linux', '/usr/lib/python3./lib-dynload', '/usr/lib/python3.4/site-packages']
>>> 
BrendanBenshoof commented 9 years ago

I'd prefer to make sure that all our code pulls the vendored version (myrequests). Because of the controlled context we are using it in (we control both the client and the server), I feel pretty safe vendoring it forever.

BrendanBenshoof commented 9 years ago

python importing is a pain. I changed the name to make it more transparent.

my initial fast hack to move the code over was

import myrequests as requests
nwautomator commented 9 years ago

Looks like websocketProxy.py is still importing the external module: https://github.com/UrDHT/PyUrDHT/blob/master/websocketProxy.py#L20

I can fix this since you're taking the day off.

nwautomator commented 9 years ago

Seems I broked this on my last attempt. Gonna make another branch with the same issue number and try again.

mmcd commented 9 years ago

Noesis:PyUrDHT michael$ python3 main.py Joining Network joined with: [{"id":"QmZAanMgeVCDL4ohdgpPNBwv72G51HDzHGFgzRboF49Wo5", "addr":"http://45.79.205.125:8002/", "wsAddr":"ws:/45.79.205.125:8003"}, {"id":"Qma398WBMbK3zx86itr6FFivoDs3Cf6RY8t7TcXZU8Kjpv", "addr":"http://131.96.131.65:8000/", "wsAddr":"ws:/131.96.131.65:8001"}, {"id":"QmZzKeRNwM7S2xxEJtzcofuXB5WmCUVzyt3YfpSeaDqSRv", "addr":"http://50.180.212.141:8000/", "wsAddr":"ws:/50.180.212.141:8001"}, {"id":"QmdhGqHbLTi9BLJNaQ3xwoW73dWXHe9fiK2dwFPpKdKx3b", "addr":"http://23.239.18.252:9000/", "wsAddr":"ws:/23.239.18.252:9001"}] Node up and Running {"id":"QmNhMeS7xyVawGKiydXLGDaZomv6X2Hk5v5FxLWM6nuKLo", "addr":"http://131.96.253.88:8000/", "wsAddr":"ws:/131.96.253.88:8001"} started websocket proxy Process Process-1: Traceback (most recent call last): File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap self.run() File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/multiprocessing/process.py", line 93, in run self._target(_self._args, *_self._kwargs) File "/Users/michael/Git/PyUrDHT/websocketProxy.py", line 20, in main import requests ImportError: No module named 'requests'

just happened on main branch with fresh install

BrendanBenshoof commented 9 years ago

yeah, the reason this is not closed is that it is not fixed yet. Chris wrote a faulty patch and Andrew merged without checking it and I rolled it back.