Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] python: fix interpreter directive for python scripts
@ 2012-08-11  5:43 Jonathan Liu
  2012-08-22  7:17 ` Maxime Ripard
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Liu @ 2012-08-11  5:43 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Jonathan Liu <net147@gmail.com>
---
 package/python/python.mk | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/package/python/python.mk b/package/python/python.mk
index fae4e5c..783b7b8 100644
--- a/package/python/python.mk
+++ b/package/python/python.mk
@@ -165,6 +165,13 @@ endef
 
 PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
 
+# Fix Python interpreter directive
+define PYTHON_FIX_INTERPRETER
+        sed -i '1s|#!.*python.*|#!/usr/bin/env python|' $(TARGET_DIR)/usr/bin/{easy_install,easy_install-2.7,idle,smtpd.py}
+endef
+
+PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_FIX_INTERPRETER
+
 PYTHON_AUTORECONF = YES
 
 $(eval $(autotools-package))
-- 
1.7.11.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH] python: fix interpreter directive for python scripts
@ 2012-08-11  6:10 Jonathan Liu
  2012-08-11 21:05 ` Thomas Petazzoni
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Liu @ 2012-08-11  6:10 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Jonathan Liu <net147@gmail.com>
---
 package/python/python.mk | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/package/python/python.mk b/package/python/python.mk
index fae4e5c..783b7b8 100644
--- a/package/python/python.mk
+++ b/package/python/python.mk
@@ -165,6 +165,13 @@ endef
 
 PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
 
+# Fix Python interpreter directive
+define PYTHON_FIX_INTERPRETER
+        sed -i '1s|#!.*python.*|#!/usr/bin/env python|' $(TARGET_DIR)/usr/bin/{easy_install,easy_install-2.7,idle,smtpd.py}
+endef
+
+PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_FIX_INTERPRETER
+
 PYTHON_AUTORECONF = YES
 
 $(eval $(autotools-package))
-- 
1.7.11.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH] python: fix interpreter directive for python scripts
  2012-08-11  6:10 [Buildroot] [PATCH] python: fix interpreter directive for python scripts Jonathan Liu
@ 2012-08-11 21:05 ` Thomas Petazzoni
  2012-08-12  6:57   ` Jonathan Liu
  2012-08-12 12:04   ` Jonathan Liu
  0 siblings, 2 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2012-08-11 21:05 UTC (permalink / raw)
  To: buildroot

Le Sat, 11 Aug 2012 16:10:27 +1000,
Jonathan Liu <net147@gmail.com> a ?crit :

> +# Fix Python interpreter directive
> +define PYTHON_FIX_INTERPRETER
> +        sed -i '1s|#!.*python.*|#!/usr/bin/env python|' $(TARGET_DIR)/usr/bin/{easy_install,easy_install-2.7,idle,smtpd.py}
> +endef
> +
> +PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_FIX_INTERPRETER

I agree the paths in those scripts is incorrect, *but*:

 * Should these scripts have been installed in the first place? I don't
   think there are useful for the typical usage of the Python
   interpreter, so maybe we want to get rid of them.

 * Instead of fixing this patch manually in every Python script
   installed, can we investigate on how to fix the root of the problem?
   I'm the one who has reworked the patches that get Python to
   cross-compile, and I know this stuff is really painful, but I think
   it's worth at least trying to understand a bit if there could be a
   way of handling things. From what I remember the problem is that the
   host-python uses its host sysconfig parameters even when building
   things for the target, simply because the whole Python things has
   absolutely zero understanding of the fact that we could be using
   Python on one machine to build stuff that will run on a different
   machine.

Thoughts?

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH] python: fix interpreter directive for python scripts
  2012-08-11 21:05 ` Thomas Petazzoni
@ 2012-08-12  6:57   ` Jonathan Liu
  2012-08-12 12:04   ` Jonathan Liu
  1 sibling, 0 replies; 9+ messages in thread
From: Jonathan Liu @ 2012-08-12  6:57 UTC (permalink / raw)
  To: buildroot

On 12/08/2012 7:05 AM, Thomas Petazzoni wrote:
> Le Sat, 11 Aug 2012 16:10:27 +1000,
> Jonathan Liu<net147@gmail.com>  a ?crit :
>
>> +# Fix Python interpreter directive
>> +define PYTHON_FIX_INTERPRETER
>> +        sed -i '1s|#!.*python.*|#!/usr/bin/env python|' $(TARGET_DIR)/usr/bin/{easy_install,easy_install-2.7,idle,smtpd.py}
>> +endef
>> +
>> +PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_FIX_INTERPRETER
> I agree the paths in those scripts is incorrect, *but*:
>
>   * Should these scripts have been installed in the first place? I don't
>     think there are useful for the typical usage of the Python
>     interpreter, so maybe we want to get rid of them.
Perhaps we could add a config option later on to not install idle and 
smtpd.py.
>
>   * Instead of fixing this patch manually in every Python script
>     installed, can we investigate on how to fix the root of the problem?
>     I'm the one who has reworked the patches that get Python to
>     cross-compile, and I know this stuff is really painful, but I think
>     it's worth at least trying to understand a bit if there could be a
>     way of handling things. From what I remember the problem is that the
>     host-python uses its host sysconfig parameters even when building
>     things for the target, simply because the whole Python things has
>     absolutely zero understanding of the fact that we could be using
>     Python on one machine to build stuff that will run on a different
>     machine.
easy_install and easy_install-2.7 shouldn't be in there apparently. It's 
part of setuptools package.
I've submitted a V2 patch so it only fixes idle and smtpd.py in python 
package. The V2 patch is independant of this setuptools interpreter 
directive issue.

I will see if I can look into fixing the interpreter for the setuptools 
package.

Regards,
Jonathan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH] python: fix interpreter directive for python scripts
  2012-08-11 21:05 ` Thomas Petazzoni
  2012-08-12  6:57   ` Jonathan Liu
@ 2012-08-12 12:04   ` Jonathan Liu
  2012-08-12 13:19     ` Avishay Orpaz
  1 sibling, 1 reply; 9+ messages in thread
From: Jonathan Liu @ 2012-08-12 12:04 UTC (permalink / raw)
  To: buildroot

On 12/08/2012 7:05 AM, Thomas Petazzoni wrote:
> Le Sat, 11 Aug 2012 16:10:27 +1000,
> Jonathan Liu<net147@gmail.com>  a ?crit :
>
>> +# Fix Python interpreter directive
>> +define PYTHON_FIX_INTERPRETER
>> +        sed -i '1s|#!.*python.*|#!/usr/bin/env python|' $(TARGET_DIR)/usr/bin/{easy_install,easy_install-2.7,idle,smtpd.py}
>> +endef
>> +
>> +PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_FIX_INTERPRETER
> I agree the paths in those scripts is incorrect, *but*:
>
>   * Should these scripts have been installed in the first place? I don't
>     think there are useful for the typical usage of the Python
>     interpreter, so maybe we want to get rid of them.
>
>   * Instead of fixing this patch manually in every Python script
>     installed, can we investigate on how to fix the root of the problem?
>     I'm the one who has reworked the patches that get Python to
>     cross-compile, and I know this stuff is really painful, but I think
>     it's worth at least trying to understand a bit if there could be a
>     way of handling things. From what I remember the problem is that the
>     host-python uses its host sysconfig parameters even when building
>     things for the target, simply because the whole Python things has
>     absolutely zero understanding of the fact that we could be using
>     Python on one machine to build stuff that will run on a different
>     machine.
I've submitted patch for Python to use fixed path for sys.executable to 
resolve this.

Regards,
Jonathan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH] python: fix interpreter directive for python scripts
  2012-08-12 12:04   ` Jonathan Liu
@ 2012-08-12 13:19     ` Avishay Orpaz
  2012-08-12 14:50       ` Yann E. MORIN
  0 siblings, 1 reply; 9+ messages in thread
From: Avishay Orpaz @ 2012-08-12 13:19 UTC (permalink / raw)
  To: buildroot

I've just ran into this kind of problem. It can be solved per package by
adding "-e /usr/bin/python" to the setup build command.

Avishay

2012/8/12 Jonathan Liu <net147@gmail.com>

> On 12/08/2012 7:05 AM, Thomas Petazzoni wrote:
>
>> Le Sat, 11 Aug 2012 16:10:27 +1000,
>> Jonathan Liu<net147@gmail.com>  a ?crit :
>>
>>  +# Fix Python interpreter directive
>>> +define PYTHON_FIX_INTERPRETER
>>> +        sed -i '1s|#!.*python.*|#!/usr/bin/**env python|'
>>> $(TARGET_DIR)/usr/bin/{easy_**install,easy_install-2.7,idle,**smtpd.py}
>>> +endef
>>> +
>>> +PYTHON_POST_INSTALL_TARGET_**HOOKS += PYTHON_FIX_INTERPRETER
>>>
>> I agree the paths in those scripts is incorrect, *but*:
>>
>>   * Should these scripts have been installed in the first place? I don't
>>     think there are useful for the typical usage of the Python
>>     interpreter, so maybe we want to get rid of them.
>>
>>   * Instead of fixing this patch manually in every Python script
>>     installed, can we investigate on how to fix the root of the problem?
>>     I'm the one who has reworked the patches that get Python to
>>     cross-compile, and I know this stuff is really painful, but I think
>>     it's worth at least trying to understand a bit if there could be a
>>     way of handling things. From what I remember the problem is that the
>>     host-python uses its host sysconfig parameters even when building
>>     things for the target, simply because the whole Python things has
>>     absolutely zero understanding of the fact that we could be using
>>     Python on one machine to build stuff that will run on a different
>>     machine.
>>
> I've submitted patch for Python to use fixed path for sys.executable to
> resolve this.
>
>
> Regards,
> Jonathan
> ______________________________**_________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/**mailman/listinfo/buildroot<http://lists.busybox.net/mailman/listinfo/buildroot>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120812/0dfffc8a/attachment-0001.html>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH] python: fix interpreter directive for python scripts
  2012-08-12 13:19     ` Avishay Orpaz
@ 2012-08-12 14:50       ` Yann E. MORIN
  2012-08-12 15:27         ` Thomas Petazzoni
  0 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2012-08-12 14:50 UTC (permalink / raw)
  To: buildroot

Jonathan, Avishay, Thomas, All,

On Sunday 12 August 2012 15:19:17 Avishay Orpaz wrote:
> I've just ran into this kind of problem. It can be solved per package by
> adding "-e /usr/bin/python" to the setup build command.

Or introduce a new package infrastrucutre, like for autotools-based and
cmake-based packages. For example, we could add a "pysetup" (or whatver)
infrastructure:

  $(eval $(pysetup-package))

Which would automatically call ./setup in the package directory, passing the
proper arguments, instead of reimplementing that in every python packages?

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH] python: fix interpreter directive for python scripts
  2012-08-12 14:50       ` Yann E. MORIN
@ 2012-08-12 15:27         ` Thomas Petazzoni
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2012-08-12 15:27 UTC (permalink / raw)
  To: buildroot

Le Sun, 12 Aug 2012 16:50:03 +0200,
"Yann E. MORIN" <yann.morin.1998@free.fr> a ?crit :

> Or introduce a new package infrastrucutre, like for autotools-based and
> cmake-based packages. For example, we could add a "pysetup" (or whatver)
> infrastructure:
> 
>   $(eval $(pysetup-package))
> 
> Which would automatically call ./setup in the package directory, passing the
> proper arguments, instead of reimplementing that in every python packages?

Right. We start to have more and more Python-based packages, and it
seems like those using the Python setuptools could benefit from having
a common infrastructure.

Best regards,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH] python: fix interpreter directive for python scripts
  2012-08-11  5:43 Jonathan Liu
@ 2012-08-22  7:17 ` Maxime Ripard
  0 siblings, 0 replies; 9+ messages in thread
From: Maxime Ripard @ 2012-08-22  7:17 UTC (permalink / raw)
  To: buildroot

Hi,

Le 11/08/2012 07:43, Jonathan Liu a ?crit :
> +# Fix Python interpreter directive
> +define PYTHON_FIX_INTERPRETER
> +        sed -i '1s|#!.*python.*|#!/usr/bin/env python|' $(TARGET_DIR)/usr/bin/{easy_install,easy_install-2.7,idle,smtpd.py}
> +endef
> +
> +PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_FIX_INTERPRETER
> +

Could you provide a bit more input on why this patch is needed ?
Did you encounter a bug? Which one?

Thanks,
-- 
Maxime Ripard, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-08-22  7:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-11  6:10 [Buildroot] [PATCH] python: fix interpreter directive for python scripts Jonathan Liu
2012-08-11 21:05 ` Thomas Petazzoni
2012-08-12  6:57   ` Jonathan Liu
2012-08-12 12:04   ` Jonathan Liu
2012-08-12 13:19     ` Avishay Orpaz
2012-08-12 14:50       ` Yann E. MORIN
2012-08-12 15:27         ` Thomas Petazzoni
  -- strict thread matches above, loose matches on Subject: below --
2012-08-11  5:43 Jonathan Liu
2012-08-22  7:17 ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox