project path before system path

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

project path before system path

WingIDE - User mailing list
Hi,

Is there a way to make sure import statements first look into the project directory and only then into the system-wide Python path? When I'm working on a library of which a previous version is installed for production use in the system-wide path, I always pick up the production version.

I tried playing around both with 'use default' and 'use custom $(WING:PROJECT_DIR); ' in the Python path in project properties, but the system-wide installed code always seems to get imported first.  I'm on 5.1.12, BTW.

Cheers,

Peter

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: project path before system path

WingIDE - User mailing list


On 26/01/2017 07:56, Peter Eastman via wingide-users wrote:

> Hi,
>
> Is there a way to make sure import statements first look into the project directory and only then into the system-wide Python path? When I'm working on a library of which a previous version is installed for production use in the system-wide path, I always pick up the production version.
>
> I tried playing around both with 'use default' and 'use custom $(WING:PROJECT_DIR); ' in the Python path in project properties, but the system-wide installed code always seems to get imported first.  I'm on 5.1.12, BTW.
>
> Cheers,
>
> Peter
>
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide
>
Peter,

In Wing and elsewhere the best mechanism it to use venv/virtualenv -
then you have complete control of which libraries are required/available.

--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.
_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: project path before system path

WingIDE - User mailing list
In reply to this post by WingIDE - User mailing list
Peter Bienstman via wingide-users wrote:
> Is there a way to make sure import statements first look into the project directory and only then into the system-wide Python path? When I'm working on a library of which a previous version is installed for production use in the system-wide path, I always pick up the production version.
>
> I tried playing around both with 'use default' and 'use custom $(WING:PROJECT_DIR); ' in the Python path in project properties, but the system-wide installed code always seems to get imported first.I'm on 5.1.12,  BTW.

The given Python Path should be prepended to the system paths.  If
you're in the Python Shell you need to restart it from its Options menu
before the changes take effect.  Take a look at sys.path in the Python
Shell or debugger to see if it's what you expect.

Also, is the module actually in the same directory or some sub-directory
from your *.wpr file?  $(WING:PROJECT_DIR) is the directory of the *.wpr
file that is currently open.  You may need something like
$(WING:PROJECT_DIR)/subdir instead.

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com


_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: project path before system path

WingIDE - User mailing list
Hi,

I've done some further digging, and I don't think the behaviour is as expected.

With the default properties, I get this as environment

Z:\source\arabic_lexical\mnemosyne-texts\mnemosyne3\pyqt_ui
C:\Program Files (x86)\Python35-32\lib\site-packages\Mnemosyne-2.4-py3.5.egg
C:\Program Files (x86)\Python35-32\python35.zip
C:\Program Files (x86)\Python35-32\DLLs
C:\Program Files (x86)\Python35-32\Lib
C:\Program Files (x86)\Python35-32
C:\Program Files (x86)\Python35-32\Lib\site-packages
C:\Program Files (x86)\Python35-32\lib\site-packages\win32
C:\Program Files (x86)\Python35-32\lib\site-packages\win32\lib
C:\Program Files (x86)\Python35-32\Lib\site-packages\pythonwin

This is what I expect, however my main file is not at the top level, but buried in the pyqt_ui directory, so this is not a good path for the library import.

So, I manually add Z:\source\arabic_lexical\mnemosyne-texts, but the environment now becomes:

Z:\source\arabic_lexical\mnemosyne-texts\mnemosyne3\pyqt_ui
C:\Program Files (x86)\Python35-32\lib\site-packages\Mnemosyne-2.4-py3.5.egg
Z:\source\arabic_lexical\mnemosyne-texts
Z:\source\arabic_lexical\mnemosyne-texts\mnemosyne3\pyqt_ui
C:\Program Files (x86)\Python35-32\python35.zip
C:\Program Files (x86)\Python35-32\DLLs
C:\Program Files (x86)\Python35-32\Lib
C:\Program Files (x86)\Python35-32
C:\Program Files (x86)\Python35-32\Lib\site-packages
C:\Program Files (x86)\Python35-32\lib\site-packages\win32
C:\Program Files (x86)\Python35-32\lib\site-packages\win32\lib
C:\Program Files (x86)\Python35-32\Lib\site-packages\pythonwin

I.e., it's not added at the top...

Cheers,

Peter

> -----Original Message-----
> From: Wingware Support [mailto:[hidden email]]
> Sent: 26 January 2017 15:25
> To: Peter Bienstman <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [wingide-users] project path before system path
>
> Peter Bienstman via wingide-users wrote:
> > Is there a way to make sure import statements first look into the project
> directory and only then into the system-wide Python path? When I'm
> working on a library of which a previous version is installed for production use
> in the system-wide path, I always pick up the production version.
> >
> > I tried playing around both with 'use default' and 'use custom
> $(WING:PROJECT_DIR); ' in the Python path in project properties, but the
> system-wide installed code always seems to get imported first.I'm on 5.1.12,
> BTW.
>
> The given Python Path should be prepended to the system paths.  If
> you're in the Python Shell you need to restart it from its Options menu
> before the changes take effect.  Take a look at sys.path in the Python
> Shell or debugger to see if it's what you expect.
>
> Also, is the module actually in the same directory or some sub-directory
> from your *.wpr file?  $(WING:PROJECT_DIR) is the directory of the *.wpr
> file that is currently open.  You may need something like
> $(WING:PROJECT_DIR)/subdir instead.
>
> --
>
> Stephan Deibel
> Wingware | Python IDE
>
> The Intelligent Development Environment for Python Programmers
>
> wingware.com
>

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: project path before system path

WingIDE - User mailing list
Peter Bienstman via wingide-users wrote:
> So, I manually add Z:\source\arabic_lexical\mnemosyne-texts, but the environment now becomes:
>
> Z:\source\arabic_lexical\mnemosyne-texts\mnemosyne3\pyqt_ui
> C:\Program Files (x86)\Python35-32\lib\site-packages\Mnemosyne-2.4-py3.5.egg
> Z:\source\arabic_lexical\mnemosyne-texts

Is this from the freshly restarted Python Shell or the debugger?  If the
debugger, it may be you have code that is adding to sys.path.

Otherwise, I wonder if PYTHONPATH is set and that is being included as
well, and ends up before the Python Path from Project Properties?

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: project path before system path

WingIDE - User mailing list
Hi,

I got that information by clicking the 'Python environment' button in the toolbar. I'm not doing any sys.path manipulations in my Python code. Also, I don't explicitly set any PYTHONPATH...

Cheers,

Peter

> -----Original Message-----
> From: Wingware Support [mailto:[hidden email]]
> Sent: 26 January 2017 20:50
> To: Peter Bienstman <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [wingide-users] project path before system path
>
> Peter Bienstman via wingide-users wrote:
> > So, I manually add Z:\source\arabic_lexical\mnemosyne-texts, but the
> environment now becomes:
> >
> > Z:\source\arabic_lexical\mnemosyne-texts\mnemosyne3\pyqt_ui
> > C:\Program Files (x86)\Python35-32\lib\site-packages\Mnemosyne-2.4-
> py3.5.egg
> > Z:\source\arabic_lexical\mnemosyne-texts
>
> Is this from the freshly restarted Python Shell or the debugger?  If the
> debugger, it may be you have code that is adding to sys.path.
>
> Otherwise, I wonder if PYTHONPATH is set and that is being included as
> well, and ends up before the Python Path from Project Properties?
>
> --
>
> Stephan Deibel
> Wingware | Python IDE
>
> The Intelligent Development Environment for Python Programmers
>
> wingware.com

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: project path before system path

WingIDE - User mailing list
Peter Bienstman via wingide-users wrote:
> I got that information by clicking the 'Python environment' button in the toolbar. I'm not doing any sys.path manipulations in my Python code. Also, I don't explicitly set any PYTHONPATH...

If you're using packages installed by setuptools there may be path
modifications from those as well.  I suspect this may be the case since
you said it was the production version that was always ending up first
on the path.

Also look for .pth files in your site-packages directory that might
account for this.

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide