bugWeeChat - Bugs: bug #35320, sys.path is incorrect when running...

 
 

bug #35320: sys.path is incorrect when running in a python virtualenv

Submitted by:  Jamie Kirkpatrick <jkp>
Submitted on:  Tue 17 Jan 2012 10:03:04 AM UTC  
 
Category: script API pluginsSeverity: 3 - Normal
Item Group: otherStatus: None
Privacy: PublicAssigned to: Sebastien Helleu <flashcode>
Originator Name: Open/Closed: Open
Release: 0.3.6IRC nick: jkp

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 17 Jan 2012 02:06:47 PM UTC, comment #2:

The main problem it can create is that it will mean stuff installed in the virtualenv only will not be found when you try to import it. It's simple to prove.

1. Setup a virtualenv
2. Activate that virtualenv
3. Install pybuffer.py in python/autoload
4. Run weechat-curses
5. Create a pybuffer (/pybuffer)
6. Try to import your module.

This will fail because PYTHONPATH is incorrect for the python instance you are running.

You can confirm that you are running the virtualenv'd instance by doing:

import sys
print sys.executable

Actually this points to a wider issue with the Python plugin implementation. When you build your python extension loader you hard-link it to a specific version of Python but it is not obvious to the user which version of Python that is. Experienced developers will probably be able to figure these kinds of issues out but its fairly non-intuitive.

Jamie Kirkpatrick <jkp>
Tue 17 Jan 2012 02:00:48 PM UTC, comment #1:

Hi,

What kind of problems could that cause? Do you know a way to see the problem, maybe by writing a script?

Or if you know how to fix, a patch would be welcome, if you can write one (and it must be compatible with Python 3.x, since now the devel version supports both Python 2.x and 3.x).

Sebastien Helleu <flashcode>
Project AdministratorIn charge of this item.
Tue 17 Jan 2012 10:03:04 AM UTC, original submission:

The sys.path variable in a wee-chat python plugin is incorrect: this is because you use "python_path = PySys_GetObject ("path");" to get the original value but this will not take into account the extra directories added by virtualenv.

It would probably be better to use the output from "python -c 'import sys; print sys.path'" to determine the original value because that will take into account virtualenv environmental settings.

Jamie Kirkpatrick <jkp>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by flashcode (Posted a comment)
  • -unavailable- added by jkp (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 19 Jan 2012 05:39:46 PM UTCflashcodeStatusNeed Info=>None
      Release1.1-dev=>0.3.6
    Tue 17 Jan 2012 02:00:48 PM UTCflashcodeStatusNone=>Need Info
      Assigned toNone=>flashcode

    Back to the top


    Powered by Savane 3.1-cleanup