I’ve got two issues here:
My main Python installation uses an old version of Autobahn (0.5.1 and 0.5.2 on another machine), which I won’t upgrade anytime soon.
So I’m doing some testing on different versions, even modifiying Autobahn’s code, where I want to use the following structure:
The problem is that init.py reads the version value from pkg_resources, which means that I might end up “using” an older version. I put “using” in quotes since only the displayed version might differ, while the code used is actually the one in the development folder, isn’t it? I wouldn’t be doubting that this is ok if there weren’t the message:
C:\foo\autobahn-test\autobahn_init_.py:20: UserWarning: Module autobahn was already imported from C:\foo\autobahn-test\autobahn_init_.py, but c:\app\python27\lib\site-packages\autobahn-0.5.9-py2.7.egg is being added to sys.path
Is this method, using pgk_resources to get the version number in the init.py file, a standard way of doing these things? Wouldn’t it be better to hard-code the version number right into the init.py file?
So, if my code relies on the version number of Autobahn, then I need to fix the init.py myself? I kind of like the idea of the autobahn folder being self-contained, with no “external references” like the one made with the version number. It helps a lot when testing among different versions, which usually is a good thing to do, before upgrading.
I’ve seen myself forced to use two different versions in the same project, in the same python process, where only their port differed. This is to share the processes memory.
In order to do this I had to rename the autobahn folder which contained the new sources (ie to autobahn_0_5_9) and copy it right into the project directory, and call an import with the renamed folder name. From there I’d import it with
from autobahn_0_5_9.websocket import listenWS as listenWS2
Now, the problem is that since wamp.py and websocket.py make an “import autobahn” call, my renamed autobahn folder, autobahn_0_5_9, will do an “import autobahn” (instead of “import autobahn_0_5_9”) just to get the version which should be its own one, but actually will be the one of the standard easy_install installation. This, plus the odd warning of pkg_resources already mentioned in point 1), makes it an odd behavior.
Wouldn’t it be better to add a new file to autobahn, called version.py, which contained a variable called version containing the string of the version number?
in wamp.py and websocket.py could get replaced by
and all occurrences of
I admit, it’s not as nice as being able to only update the modified code files, but then again, modifying a version number in a file when the version number of the module actually changes solves some really ugly issues.
I have a modified zip file I can send you, so that you can look at the changes, I think that would be quicker that making it via github.