Re: shebang lines for Python scripts

2012-04-30 Thread Piotr Ożarowski
[Barry Warsaw, 2012-04-25]
  - dh_python{2,3} should rewrite the shebang lines by default, with an option
to disable that.

there wasn't a consensus so I dropped this idea, I think I will add it
as an optional feature in next upload, though.
-- 
Piotr Ożarowski Debian GNU/Linux Developer
www.ozarowski.pl  www.griffith.cc   www.debian.org
GPG Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20120430092325.gj3...@piotro.eu



Re: shebang lines for Python scripts

2012-04-30 Thread Barry Warsaw
On Apr 30, 2012, at 11:23 AM, Piotr Ożarowski wrote:

[Barry Warsaw, 2012-04-25]
  - dh_python{2,3} should rewrite the shebang lines by default, with an option
to disable that.

there wasn't a consensus so I dropped this idea, I think I will add it
as an optional feature in next upload, though.

Cool.  Will the default be rewrite or don't rewrite shebangs?

-Barry


--
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20120430104244.3a3bf...@resist.wooz.org



Re: shebang lines for Python scripts

2012-04-30 Thread Piotr Ożarowski
[Barry Warsaw, 2012-04-30]
 On Apr 30, 2012, at 11:23 AM, Piotr Ożarowski wrote:
 
 [Barry Warsaw, 2012-04-25]
   - dh_python{2,3} should rewrite the shebang lines by default, with an 
  option
 to disable that.
 
 there wasn't a consensus so I dropped this idea, I think I will add it
 as an optional feature in next upload, though.
 
 Cool.  Will the default be rewrite or don't rewrite shebangs?

don't rewrite

I don't remember arguments against making it the default,
will have to dig the IRC/mailing list archives later.
-- 
Piotr Ożarowski Debian GNU/Linux Developer
www.ozarowski.pl  www.griffith.cc   www.debian.org
GPG Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20120430150008.gp3...@piotro.eu



Re: shebang lines for Python scripts

2012-04-30 Thread Barry Warsaw
On Apr 30, 2012, at 05:00 PM, Piotr Ożarowski wrote:

I don't remember arguments against making it the default,
will have to dig the IRC/mailing list archives later.

I'd prefer rewrite since I think /usr/bin/env is almost always the wrong
thing to use in production (though I acknowledge Stefano's use case), but even
if disabled by default, this will let us recommend it and gain experience so
that it might be possible to enable by default later.

Of course, it won't affect packages that use other Python helpers, or no
helpers at all, but we have Debian Python policy for that.

Cheers,
-Barry


--
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20120430111326.5423a...@resist.wooz.org



Re: shebang lines for Python scripts

2012-04-25 Thread Barry Warsaw
Apologies for reviving this thread.  It's recently come up in relation to
other discussions I've had and I did a grep over s/usr/bin to find instances
where /usr/bin/env python was being used.  Stefano reminded me of this
thread, and when I went back and re-read it, I noticed there wasn't resolution
on all the issues.

On Mar 04, 2011, at 11:23 PM, Piotr Ożarowski wrote:

any objections to change all shebangs (that do not match
/usr/bin/python\d(\.\d+) but do math .+python.* regexp) to
/usr/bin/python¹ in dh_python2 and to /usr/bin/python3 in
dh_python3?

(+ an option to disable this behaviour in both helpers)

if yes, should options (-OO, etc.) be removed as well?

[¹] or /usr/bin/python2, depends on PEP 394 status

As a reminder, the issue is that, in development (i.e. upstream) packages,
it's perfectly fine to use /usr/bin/env python on the shebang line.
However, I feel strongly that *installed* Python scripts, should never use
this, and instead should use /usr/bin/python or possibly
/usr/bin/pythonX.Y.

(Stefano brought up a legitimate case where this could prove inconvenient, but
I think it's more important to have a functioning system :).

There were two good proposals in the thread:

 - Debian Python policy should be stronger in its recommendation to use
   /usr/bin/python or /usr/bin/pythonX.Y in the shebang line instead of
   /usr/bin/env python.

 - dh_python{2,3} should rewrite the shebang lines by default, with an option
   to disable that.

I just had a look at D-P policy $1.4.2 and it is stronger now than what Scott
quoted back in March 2011.  Here's what it says now:

1.4.2. Interpreter Location
---

 The preferred specification for the Python interpreter is
 `/usr/bin/python' or `/usr/bin/pythonX.Y'.  This ensures that a
 Debian installation of python is used and all dependencies on
 additional python modules are met.

 Maintainers should not override the Debian Python interpreter using
 `/usr/bin/env python' or `/usr/bin/env pythonX.Y'.  This is not
 advisable as it bypasses Debian's dependency checking and makes the
 package vulnerable to incomplete local installations of python.

I like this.  It strikes the right balance, and strongly discourages using
/usr/bin/env.

On the second point, I don't think Piotr ever implemented shebang line
rewriting.  I think it would be a good idea to have the helpers help you
conform to D-P policy, so I support adding a feature to dh_python{2,3} to do
this, with an option to disable it.

Of course, this won't help packages that don't use the helpers.  They'll still
do the wrong thing unless the packager takes action.  But at least we can
point to the rationale in D-P policy, and this thread to explain why
/usr/bin/env is usually a bad idea.

Cheers,
-Barry


signature.asc
Description: PGP signature


Re: shebang lines for Python scripts

2011-03-05 Thread Piotr Ożarowski
[Jakub Wilk, 2011-03-05]
 I'm not convinced it's only about getting rid of /usr/bin/env. Piotr  
 didn't give any rationale for the proposed changed and his algorithm (as  

sorry, we talked about pytohn-dev thread on #debian-python and when I
saw Barry's mail on debian-python@ I just assumed everyone knows why I'm
proposing it

[...]
 For what it's worth, I'd OK with Python helpers doing this:

 s,^#!\s*/usr/bin/env\s+(python[0-9.]*(-dbg)?)\b,#!/usr/bin/\1,

that's what I wanted since the beginning, sorry for lame regexp (which
was missing a ?, BTW), again, I just assumed everyone read Support
the /usr/bin/python2 symlink upstream thread (and as you can read
there, I'm actually against /usr/bin/python2, my proposal here is just
to make the mess less messy)
-- 
Piotr Ożarowski Debian GNU/Linux Developer
www.ozarowski.pl  www.griffith.cc   www.debian.org
GPG Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20110305201621.gz30...@piotro.eu



Re: shebang lines for Python scripts

2011-03-04 Thread Scott Kitterman
On Friday, March 04, 2011 01:23:40 pm Barry Warsaw wrote:
 So I know many of you are on python-dev, so you might have seen this come
 up, but traffic there can be pretty heavy at times.
 
 Upstream Python recommends that the shebang line for scripts should be
 
 #!/usr/bin/env python
 
 however, this should only apply to *developer* packages, not operating
 system packages.  Doing the above in packages provided by the distro can
 cause those scripts to break, if say a user installs their own Python
 sooner in $PATH, and which is not compatible with the script.
 
 It's also unnecessary for distros because we should know exactly which
 version of Python our scripts work with.  And finally, setuptools will
 rewrite the shebang line when it installs scripts (FSVO 'setuptools' ;).
 
 There's about two such scripts in /usr/bin on my Squeeze machine.  Debian
 policy should be clear that system installed Python scripts should have a
 shebang line hardcoded to a Python executable.  Whether that should be
 /usr/bin/python, /usr/bin/python2, /usr/bin/pythonX.Y or something else is
 a different discussion. ;)  Personally /usr/bin/python seems fine to me
 for now.
 
 -Barry
Currently Python policy says:

1.4.2. Interpreter Location
---

 The preferred specification for the Python interpreter is
 `/usr/bin/python' or `/usr/bin/pythonX.Y'.  This ensures that a
 Debian installation of python is used and all dependencies on
 additional python modules are met.

 If a maintainer would like to provide the user with the possibility to
 override the Debian Python interpreter, he may want to use
 `/usr/bin/env python' or `/usr/bin/env pythonX.Y'.  However this
 is not advisable as it bypasses Debian's dependency checking and makes
 the package vulnerable to incomplete local installations of python.

Is that strong enough?

Scott K


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/201103041415.21944.deb...@kitterman.com



Re: shebang lines for Python scripts

2011-03-04 Thread Barry Warsaw
On Mar 04, 2011, at 02:15 PM, Scott Kitterman wrote:

Currently Python policy says:

1.4.2. Interpreter Location
---

 The preferred specification for the Python interpreter is
 `/usr/bin/python' or `/usr/bin/pythonX.Y'.  This ensures that a
 Debian installation of python is used and all dependencies on
 additional python modules are met.

 If a maintainer would like to provide the user with the possibility to
 override the Debian Python interpreter, he may want to use
 `/usr/bin/env python' or `/usr/bin/env pythonX.Y'.  However this
 is not advisable as it bypasses Debian's dependency checking and makes
 the package vulnerable to incomplete local installations of python.

Is that strong enough?

It's good, but not quite strong enough, because it doesn't give me clear
guidance on what to do when I find a script with a /usr/bin/env shebang line.
How would I know whether it's a deliberate use, or a bug?  Or should I just
file a bug on the offending packages and let the maintainer sort it out?

Cheers,
-Barry


signature.asc
Description: PGP signature


Re: shebang lines for Python scripts

2011-03-04 Thread Piotr Ożarowski
any objections to change all shebangs (that do not match
/usr/bin/python\d(\.\d+) but do math .+python.* regexp) to
/usr/bin/python¹ in dh_python2 and to /usr/bin/python3 in
dh_python3?

(+ an option to disable this behaviour in both helpers)

if yes, should options (-OO, etc.) be removed as well?

[¹] or /usr/bin/python2, depends on PEP 394 status
-- 
Piotr Ożarowski Debian GNU/Linux Developer
www.ozarowski.pl  www.griffith.cc   www.debian.org
GPG Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645


--
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20110304222346.gu30...@piotro.eu



Re: shebang lines for Python scripts

2011-03-04 Thread Stefano Rivera
Hi Piotr (2011.03.05_00:23:46_+0200)
 any objections to change all shebangs (that do not match
 /usr/bin/python\d(\.\d+) but do math .+python.* regexp) to
 /usr/bin/python¹ in dh_python2 and to /usr/bin/python3 in
 dh_python3?

Grumble. I quite like being able to use light (not --no-site-packages)
virtualenvs for development, and being able to execute things like
unit2, twistd, trial, or nose inside the virtualenv.

But I do understand why this is wanted.

SR

-- 
Stefano Rivera
  http://tumbleweed.org.za/
  H: +27 21 465 6908 C: +27 72 419 8559  UCT: x3127


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20110304225248.gi24...@bach.rivera.co.za



Re: shebang lines for Python scripts

2011-03-04 Thread Scott Kitterman
Piotr Ożarowski pi...@debian.org wrote:

any objections to change all shebangs (that do not match 
/usr/bin/python\d(\.\d+) but do math .+python.* regexp) to /usr/bin/python¹ in 
dh_python2 and to /usr/bin/python3 in dh_python3? (+ an option to disable this 
behaviour in both helpers) if yes, should options (-OO, etc.) be removed as 
well? [¹] or /usr/bin/python2, depends on PEP 394 status -- Piotr Ożarowski 
Debian GNU/Linux Developer www.ozarowski.pl www.griffith.cc www.debian.org GPG 
Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645 -- To 
UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org with a subject of 
unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: 
http://lists.debian.org/20110304222346.gu30...@piotro.eu 


I think it's reasonable, but if you think you should do that I think we should 
make the Python policy language on it stronger.

2to3 doesn't seem to convert shebangs, so it would be good if dh_python3 did.

Scott K

Re: shebang lines for Python scripts

2011-03-04 Thread Jakub Wilk

* Piotr Ożarowski pi...@debian.org, 2011-03-04, 23:23:

any objections to change all shebangs (that do not match
/usr/bin/python\d(\.\d+) but do math .+python.* regexp) to
/usr/bin/python¹ in dh_python2 and to /usr/bin/python3 in
dh_python3?


dh_python2 would change /usr/bin/env python3 to /usr/bin/python;
dh_python3 would change /usr/bin/env python to /usr/bin/python3.

No, thank you, that's wrong.


if yes, should options (-OO, etc.) be removed as well?


No.

--
Jakub Wilk


--
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20110305001618.ga9...@jwilk.net



Re: shebang lines for Python scripts

2011-03-04 Thread Piotr Ożarowski
[Jakub Wilk, 2011-03-05]
 * Piotr Ożarowski pi...@debian.org, 2011-03-04, 23:23:
 any objections to change all shebangs (that do not match
 /usr/bin/python\d(\.\d+) but do math .+python.* regexp) to
 /usr/bin/python¹ in dh_python2 and to /usr/bin/python3 in
 dh_python3?

 dh_python2 would change /usr/bin/env python3 to /usr/bin/python;
 dh_python3 would change /usr/bin/env python to /usr/bin/python3.

 No, thank you, that's wrong.

dh_python2 and dh_python3 cannot be used for the same files at the same
time (that's why dh_python2 igores python3-* packages, that's why
dh_python3 ignores python-* packages and that's why you have to use
-N/-p in all other packages if you want to invoke both helpers)
-- 
Piotr Ożarowski Debian GNU/Linux Developer
www.ozarowski.pl  www.griffith.cc   www.debian.org
GPG Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20110305002006.gw30...@piotro.eu



Re: shebang lines for Python scripts

2011-03-04 Thread Jakub Wilk

* Piotr Ożarowski pi...@debian.org, 2011-03-05, 01:20:

any objections to change all shebangs (that do not match
/usr/bin/python\d(\.\d+) but do math .+python.* regexp) to
/usr/bin/python¹ in dh_python2 and to /usr/bin/python3 in
dh_python3?


dh_python2 would change /usr/bin/env python3 to /usr/bin/python;
dh_python3 would change /usr/bin/env python to /usr/bin/python3.

No, thank you, that's wrong.


dh_python2 and dh_python3 cannot be used for the same files at the same
time (that's why dh_python2 igores python3-* packages, that's why
dh_python3 ignores python-* packages and that's why you have to use
-N/-p in all other packages if you want to invoke both helpers)


Wait, what, I cannot have a package that ship both python and python3 
*scripts*?


--
Jakub Wilk


--
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20110305003530.ga2...@jwilk.net



Re: shebang lines for Python scripts

2011-03-04 Thread Piotr Ożarowski
[Jakub Wilk, 2011-03-05]
 * Piotr Ożarowski pi...@debian.org, 2011-03-05, 01:20:
 dh_python2 and dh_python3 cannot be used for the same files at the same
 time (that's why dh_python2 igores python3-* packages, that's why
 dh_python3 ignores python-* packages and that's why you have to use
 -N/-p in all other packages if you want to invoke both helpers)

 Wait, what, I cannot have a package that ship both python and python3  
 *scripts*?

you can:

Piotr Ożarowski wrote:
 (+ an option to disable this behaviour in both helpers)
-- 
Piotr Ożarowski Debian GNU/Linux Developer
www.ozarowski.pl  www.griffith.cc   www.debian.org
GPG Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20110305003920.gy30...@piotro.eu



Re: shebang lines for Python scripts

2011-03-04 Thread Jakub Wilk

* Piotr Ożarowski pi...@debian.org, 2011-03-05, 01:39:
dh_python2 and dh_python3 cannot be used for the same files at the 
same time (that's why dh_python2 igores python3-* packages, that's 
why dh_python3 ignores python-* packages and that's why you have to 
use -N/-p in all other packages if you want to invoke both helpers)


Wait, what, I cannot have a package that ship both python and python3 
*scripts*?


you can:

Piotr Ożarowski wrote:

(+ an option to disable this behaviour in both helpers)


If you're going to push this forward, please call the option 
--without-bugs.


--
Jakub Wilk


--
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20110305010655.ga5...@jwilk.net



Re: shebang lines for Python scripts

2011-03-04 Thread Scott Kitterman
On Friday, March 04, 2011 08:06:55 pm Jakub Wilk wrote:
 * Piotr Ożarowski pi...@debian.org, 2011-03-05, 01:39:
 dh_python2 and dh_python3 cannot be used for the same files at the
 same time (that's why dh_python2 igores python3-* packages, that's
 why dh_python3 ignores python-* packages and that's why you have to
 use -N/-p in all other packages if you want to invoke both helpers)
 
 Wait, what, I cannot have a package that ship both python and python3
 *scripts*?
 
 you can:
 
 Piotr Ożarowski wrote:
 (+ an option to disable this behaviour in both helpers)
 
 If you're going to push this forward, please call the option
 --without-bugs.

I get that you're not in favor of this.  What is the problem with the fixing 
shebangs by default?  If you believe what policy says, /usr/bin/env python is 
something we should only have in Debian packages due to the maintainer 
deciding it's needed for some reason.

Scott K


--
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/201103042115.05173.deb...@kitterman.com