Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] python: Use fixed path for sys.executable
@ 2012-08-12 12:06 Jonathan Liu
  2012-08-12 16:18 ` Thomas Petazzoni
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Liu @ 2012-08-12 12:06 UTC (permalink / raw)
  To: buildroot

The path to the Python interpreter is returned by sys.executable.
However, setuptools uses sys.executable to generate the shebang
interpreter directive used for entry point scripts that will run
on the target system. In this case, it will return the path of the
host Python interpreter when it should be the path of the Python
interpreter on the target.

To fix this, just return a fixed path of /usr/bin/python for
sys.executable.

Signed-off-by: Jonathan Liu <net147@gmail.com>
---
 package/python/python-2.7-114-sys-executable.patch | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 package/python/python-2.7-114-sys-executable.patch

diff --git a/package/python/python-2.7-114-sys-executable.patch b/package/python/python-2.7-114-sys-executable.patch
new file mode 100644
index 0000000..1a6b73c
--- /dev/null
+++ b/package/python/python-2.7-114-sys-executable.patch
@@ -0,0 +1,32 @@
+Use fixed path for sys.executable
+
+The path to the Python interpreter is returned by sys.executable.
+However, setuptools uses sys.executable to generate the shebang
+interpreter directive used for entry point scripts that will run
+on the target system. In this case, it will return the path of the
+host Python interpreter when it should be the path of the Python
+interpreter on the target.
+
+To fix this, just return a fixed path of /usr/bin/python for
+sys.executable.
+
+Signed-off-by: Jonathan Liu <net147@gmail.com>
+---
+ Modules/getpath.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+Index: Python-2.7.2/Modules/getpath.c
+===================================================================
+--- Python-2.7.2.orig/Modules/getpath.c
++++ Python-2.7.2/Modules/getpath.c
+@@ -686,9 +686,7 @@ Py_GetExecPrefix(void)
+ char *
+ Py_GetProgramFullPath(void)
+ {
+-    if (!module_search_path)
+-        calculate_path();
+-    return progpath;
++    return "/usr/bin/python";
+ }
+ 
+ 
-- 
1.7.11.3

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

* [Buildroot] [PATCH] python: Use fixed path for sys.executable
  2012-08-12 12:06 [Buildroot] [PATCH] python: Use fixed path for sys.executable Jonathan Liu
@ 2012-08-12 16:18 ` Thomas Petazzoni
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni @ 2012-08-12 16:18 UTC (permalink / raw)
  To: buildroot

Le Sun, 12 Aug 2012 22:06:05 +1000,
Jonathan Liu <net147@gmail.com> a ?crit :

> +Index: Python-2.7.2/Modules/getpath.c
> +===================================================================
> +--- Python-2.7.2.orig/Modules/getpath.c
> ++++ Python-2.7.2/Modules/getpath.c
> +@@ -686,9 +686,7 @@ Py_GetExecPrefix(void)
> + char *
> + Py_GetProgramFullPath(void)
> + {
> +-    if (!module_search_path)
> +-        calculate_path();
> +-    return progpath;
> ++    return "/usr/bin/python";
> + }

The 'python' package builds both a host variant and a target variant.
While this solves the problem for the target variant, it may now create
a problem for the host variant, no? Maybe in practice there is no
problem, I don't know.

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] 2+ messages in thread

end of thread, other threads:[~2012-08-12 16:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-12 12:06 [Buildroot] [PATCH] python: Use fixed path for sys.executable Jonathan Liu
2012-08-12 16:18 ` Thomas Petazzoni

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