[Distutils] pkg_resources on Windows

Guy Rozendorn guy at rzn.co.il
Tue Dec 13 15:25:51 CET 2011


If your console_scripts section in setup.py point to a correct entry 
point, then distribute should've created a dev_main.exe executable 
wrapper, and a dev_main-script.py under C:\Python25\Scripts.
The executable wrapper reads the generated python file and extracts the 
pyhton executable path from the shebang file, and calls CreateProcess 
with that python executable.

If you don't have these two files, then, I can guess that either:
* You're using an old version of distribute
* Your setup.py is incorrect.

- Guy

> Andrea Crotti <mailto:andrea.crotti.0 at gmail.com>
> December 13, 2011 4:11 PM
>
> I thought so, but I was surprised to see the shebang line in the 
> script file, so I supposed that it was actually working.
> So if I just make sure that every py file is associated with that 
> particular version of python everything should work,
> right?
> _______________________________________________
> Distutils-SIG maillist - Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig
> Michael Foord <mailto:fuzzyman at gmail.com>
> December 13, 2011 3:08 PM
>
>
> On 13 December 2011 11:40, Andrea Crotti <andrea.crotti.0 at gmail.com 
> <mailto:andrea.crotti.0 at gmail.com>> wrote:
>
>     I have a script installed with "python setup.py develop" on
>     windows 7 in
>     the directory c:\python25\scripts.
>
>     The script looks like:
>
>     #!c:\python25\python.exe
>     # EASY-INSTALL-DEV-SCRIPT: 'psi.devsonly==0.1','dev_main.py'
>     __requires__ = 'psi.devsonly==0.1'
>     from pkg_resources import require; require('psi.devsonly==0.1')
>     del require
>     __file__ = 'h:\\long\\path\\bin\\dev_main.py'
>     execfile(__file__)
>
>     c:\python25\script is actually in the $PATH, but if I try to launch
>     that command it doesn't work because it tries with c:\Python27.
>
>     long\path\git_projs\Psi>dev_main.py -h
>     dev_main.py -h
>     Traceback (most recent call last):
>      File "C:\python25\scripts\dev_main.py", line 4, in <module>
>        from pkg_resources import require; require('psi.devsonly==0.1')
>      File
>     "C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py",
>     line 2603, in <module>
>      File
>     "C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py",
>     line 666, in require
>      File
>     "C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py",
>     line 565, in resolve
>     pkg_resources.DistributionNotFound: psi.devsonly==0.1
>
>
>     This makes me thing that
>     - the shebang is absolutely ignored
>
>
>
> Yes, Windows ignores shebang lines, they're a UNIX convention. Windows 
> uses file associations to decide what program to launch scripts with.
>
> The Windows Python installer associates .py files with python.exe - so 
> the most recent version of Python you installed will have the file 
> association.
>
> For scripts on Windows I *thought* setuptools created .exe wrappers to 
> get round this problem. It may not do this when you use "setup.py 
> develop" though.
>
> All the best,
>
> Michael Foord
>
>     - some other weird bug
>
>     Is there a way to solve this thing?
>     _______________________________________________
>     Distutils-SIG maillist  - Distutils-SIG at python.org
>     <mailto:Distutils-SIG at python.org>
>     http://mail.python.org/mailman/listinfo/distutils-sig
>
>
>
>
> -- 
> http://www.voidspace.org.uk/
>
> May you do good and not evil
> May you find forgiveness for yourself and forgive others
>
> May you share freely, never taking more than you give.
> -- the sqlite blessinghttp://www.sqlite.org/different.html
>
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig
> Andrea Crotti <mailto:andrea.crotti.0 at gmail.com>
> December 13, 2011 1:40 PM
> I have a script installed with "python setup.py develop" on windows 7 in
> the directory c:\python25\scripts.
>
> The script looks like:
>
> #!c:\python25\python.exe
> # EASY-INSTALL-DEV-SCRIPT: 'psi.devsonly==0.1','dev_main.py'
> __requires__ = 'psi.devsonly==0.1'
> from pkg_resources import require; require('psi.devsonly==0.1')
> del require
> __file__ = 'h:\\long\\path\\bin\\dev_main.py'
> execfile(__file__)
>
> c:\python25\script is actually in the $PATH, but if I try to launch
> that command it doesn't work because it tries with c:\Python27.
>
> long\path\git_projs\Psi>dev_main.py -h
> dev_main.py -h
> Traceback (most recent call last):
>   File "C:\python25\scripts\dev_main.py", line 4, in <module>
>     from pkg_resources import require; require('psi.devsonly==0.1')
>   File 
> "C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py", 
> line 2603, in <module>
>   File 
> "C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py", 
> line 666, in require
>   File 
> "C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py", 
> line 565, in resolve
> pkg_resources.DistributionNotFound: psi.devsonly==0.1
>
>
> This makes me thing that
> - the shebang is absolutely ignored
> - some other weird bug
>
> Is there a way to solve this thing?
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20111213/70bf6621/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compose-unknown-contact.jpg
Type: image/jpeg
Size: 770 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20111213/70bf6621/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1211 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20111213/70bf6621/attachment-0003.jpg>


More information about the Distutils-SIG mailing list