0

I have started experimenting with Crossbar and WAMP (Web Apps Messaging Protocol) and Im in love with this stuff in just a few weeks time. I answered this stack overflow question (Debugging Crossbar.io app in IntelliJ) as well, however, I have a of question about my own solution.

...

Step 2: Create a pyenv with Python 2 for crossbar.io

    $ pyenv virtualenv 2.7.6 crossbar
    $ pyenv activate crossbar
    (crossbar)$ pip install crossbar
    
...

Step 5: Create a pyenv with Python 3 for app components

    $ pyenv virtualenv 3.4.2 app
    $ pyenv activate app
    (app)$ pip install autobahn
    

Step 6: Create a normal PyCharm project with "app" as a local python environment. I mean use python executable from app pyenv as an interpreter.

...

In step 5 of my solution, I have suggested to create a new virtual python environment for the app component.

Step 6 is purely for IDE to auto-complete and find the local packages, libraries and stuffs from the virtual env above. I reckon, the "crossbar" command doesn't know about this virtual env.

So, when I run the app by ~/.pyenv/versions/crossbar/bin/crossbar start command how to make sure to use the python interpreter from the virtual environment instead? I mean from ~/.pyenv/versions/app/bin/python3?

Is it something to do with the config file? I quickly had a look at the docs (http://crossbar.io/docs/Container-Configuration/) but unfortunately did not find any information about Python interpreter at all.

I tried to put "executable": "~/.pyenv/versions/app/bin/python3" in the config file but it obviously doesn't pass the validation. I mean the crossbar check command fails.

Thank you in Advanced.

Community
  • 1
  • 1
Eddie
  • 1,043
  • 8
  • 14

1 Answers1

1

If you want to use Python 3 for your app component, and have that component started by Crossbar.io, that means you want a guest worker.

The way to configure the executable run for the guest worker (which would be Python 3 in your case), is indeed by using the executable parameter.

The docs are sparse, but here.

Your safest bet is by using a fully qualified, absolute path in executable pointing to the Python 3 binary within the virtualenv you want to use for your component.

Note, above applies to guest workers. Crossbar.io native workers include routers and component container. The latter is also able to host Python app components, but only from the same Python that Crossbar.io runs from. The docs (sorry, I know, sparse) is here.

oberstet
  • 21,353
  • 10
  • 64
  • 97
  • Thanks oberstet. I don't mind using twisted at all but, I believe sometimes it is handier to explicitly choose the Python interpreter. Maybe I missed something but I ended up using asyncio based guest workers, however, I need to put the full absolute path in executable. It doesn't bother me too much but is there an easy way to put a relative path instead? So that it becomes easier to version control. Or I can write a bit of script to do it. Anyway thank you very much for your help. – Eddie Jan 07 '15 at 01:58
  • You can also use relative paths for `executable` (relative to where the `config.json` file resides .. that is, `.crossbar` directory) or you can just use `python3` given that the latter can be resolved in the environment of the Crossbar.io node controller process. – oberstet Jan 07 '15 at 09:15