linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] perf tools: Fix make PYTHON override
@ 2014-07-29  6:57 Namhyung Kim
  2014-07-29  6:57 ` [PATCH v2 2/2] perf tools: Default to python version 2 Namhyung Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Namhyung Kim @ 2014-07-29  6:57 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Paul Mackerras, Namhyung Kim,
	Namhyung Kim, LKML, Jiri Olsa, Thomas Ilsche

Thomas reported that make PYTHON=python2 is not work on some systems.
I can reproduce it on my ArchLinux box too.

This is because it's overridden by config/feature-checks/Makefile
regardless of PYTHON setting.  I guess it's a bug slipped into during
the feature checking change.

Actually, we don't need to check python-config in the feature-checks.
We can just pass appropriate FEATURE_CHECK_*FLAGS.

Reported-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/config/Makefile                | 34 ++++++++++++++++++++-----------
 tools/perf/config/feature-checks/Makefile | 18 ++--------------
 2 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 1f67aa02d240..e05d8f99424d 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -120,6 +120,23 @@ ifdef PARSER_DEBUG
   CFLAGS             += -DPARSER_DEBUG
 endif
 
+ifndef NO_LIBPYTHON
+  override PYTHON := \
+    $(call get-executable-or-default,PYTHON,python)
+  override PYTHON_CONFIG := \
+    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+
+  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
+
+  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
+  PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
+
+  FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
+  FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
+  FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
+  FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
+endif
+
 CFLAGS += -fno-omit-frame-pointer
 CFLAGS += -ggdb3
 CFLAGS += -funwind-tables
@@ -482,21 +499,14 @@ define disable-python_code
   NO_LIBPYTHON := 1
 endef
 
-override PYTHON := \
-  $(call get-executable-or-default,PYTHON,python)
-
-ifndef PYTHON
-  $(call disable-python,python interpreter)
+ifdef NO_LIBPYTHON
+  $(call disable-python)
 else
 
-  PYTHON_WORD := $(call shell-wordify,$(PYTHON))
-
-  ifdef NO_LIBPYTHON
-    $(call disable-python)
+  ifndef PYTHON
+    $(call disable-python,python interpreter)
   else
-
-    override PYTHON_CONFIG := \
-      $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+    PYTHON_WORD := $(call shell-wordify,$(PYTHON))
 
     ifndef PYTHON_CONFIG
       $(call disable-python,python-config tool)
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 6088f8d8a434..72ab2984718e 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -101,25 +101,11 @@ FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 test-libperl.bin:
 	$(BUILD) $(FLAGS_PERL_EMBED)
 
-override PYTHON := python
-override PYTHON_CONFIG := python-config
-
-escape-for-shell-sq =  $(subst ','\'',$(1))
-shell-sq = '$(escape-for-shell-sq)'
-
-PYTHON_CONFIG_SQ = $(call shell-sq,$(PYTHON_CONFIG))
-
-PYTHON_EMBED_LDOPTS = $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
-PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_CCOPTS = $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
-FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
-
 test-libpython.bin:
-	$(BUILD) $(FLAGS_PYTHON_EMBED)
+	$(BUILD)
 
 test-libpython-version.bin:
-	$(BUILD) $(FLAGS_PYTHON_EMBED)
+	$(BUILD)
 
 test-libbfd.bin:
 	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
-- 
2.0.0


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

* [PATCH v2 2/2] perf tools: Default to python version 2
  2014-07-29  6:57 [PATCH v2 1/2] perf tools: Fix make PYTHON override Namhyung Kim
@ 2014-07-29  6:57 ` Namhyung Kim
  2014-08-01 20:21   ` Arnaldo Carvalho de Melo
  2014-07-31 14:38 ` [PATCH v2 1/2] perf tools: Fix make PYTHON override Arnaldo Carvalho de Melo
  2014-08-13  5:17 ` [tip:perf/core] " tip-bot for Namhyung Kim
  2 siblings, 1 reply; 10+ messages in thread
From: Namhyung Kim @ 2014-07-29  6:57 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Paul Mackerras, Namhyung Kim,
	Namhyung Kim, LKML, Jiri Olsa, Thomas Ilsche

According to PEP 394 recommendation [1], it's more portable to use
python2 rather than plain python to refer python binary version 2.

Since there're distros using python3 by default like Arch, and we
don't support python3 (yet), it'd be better using python2 explicitly.

But older versions (prior to 2.7) seem not to provide python2 but just
python.  Given that it's only old version, try python2 first and then
fallback to python.  It'll ensure that it always points to python 2.x.

[1] https://www.python.org/dev/peps/pep-0394

Suggested-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Tested-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/config/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index e05d8f99424d..60177278a357 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -121,8 +121,8 @@ ifdef PARSER_DEBUG
 endif
 
 ifndef NO_LIBPYTHON
-  override PYTHON := \
-    $(call get-executable-or-default,PYTHON,python)
+  PYTHON2 := $(if $(call get-executable,python2),python2,python)
+  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
   override PYTHON_CONFIG := \
     $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
 
-- 
2.0.0


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

* Re: [PATCH v2 1/2] perf tools: Fix make PYTHON override
  2014-07-29  6:57 [PATCH v2 1/2] perf tools: Fix make PYTHON override Namhyung Kim
  2014-07-29  6:57 ` [PATCH v2 2/2] perf tools: Default to python version 2 Namhyung Kim
@ 2014-07-31 14:38 ` Arnaldo Carvalho de Melo
  2014-08-13  5:17 ` [tip:perf/core] " tip-bot for Namhyung Kim
  2 siblings, 0 replies; 10+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-07-31 14:38 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Peter Zijlstra, Ingo Molnar, Paul Mackerras, Namhyung Kim, LKML,
	Jiri Olsa, Thomas Ilsche

Em Tue, Jul 29, 2014 at 03:57:19PM +0900, Namhyung Kim escreveu:
> Thomas reported that make PYTHON=python2 is not work on some systems.
> I can reproduce it on my ArchLinux box too.
> 
> This is because it's overridden by config/feature-checks/Makefile
> regardless of PYTHON setting.  I guess it's a bug slipped into during
> the feature checking change.
> 
> Actually, we don't need to check python-config in the feature-checks.
> We can just pass appropriate FEATURE_CHECK_*FLAGS.
> 
> Reported-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Thanks, both patches applied.

- Arnaldo

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

* Re: [PATCH v2 2/2] perf tools: Default to python version 2
  2014-07-29  6:57 ` [PATCH v2 2/2] perf tools: Default to python version 2 Namhyung Kim
@ 2014-08-01 20:21   ` Arnaldo Carvalho de Melo
  2014-08-02 10:56     ` Thomas Ilsche
  0 siblings, 1 reply; 10+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-08-01 20:21 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Peter Zijlstra, Ingo Molnar, Paul Mackerras, Namhyung Kim, LKML,
	Jiri Olsa, Thomas Ilsche

Em Tue, Jul 29, 2014 at 03:57:20PM +0900, Namhyung Kim escreveu:
> According to PEP 394 recommendation [1], it's more portable to use
> python2 rather than plain python to refer python binary version 2.
> 
> Since there're distros using python3 by default like Arch, and we
> don't support python3 (yet), it'd be better using python2 explicitly.
> 
> But older versions (prior to 2.7) seem not to provide python2 but just
> python.  Given that it's only old version, try python2 first and then
> fallback to python.  It'll ensure that it always points to python 2.x.

It should fallback, right?

[acme@fedora14 linux]$ ls -la /usr/bin/python2-config
ls: cannot access /usr/bin/python2-config: No such file or directory
[acme@fedora14 linux]$ ls -la /usr/bin/python-config
lrwxrwxrwx. 1 root root 16 Mar 25 09:43 /usr/bin/python-config -> python2.7-config
[acme@fedora14 linux]$ rpm -qf /usr/bin/python-config 
python-devel-2.7-8.fc14.1.x86_64
[acme@fedora14 linux]$ cat /etc/fedora-release 
Fedora release 14 (Laughlin)
[acme@fedora14 linux]$ 

[acme@fedora14 linux]$ time make O=/tmp/build/perf -C tools/perf install
make: Entering directory `/home/acme/git/linux/tools/perf'
  BUILD:   Doing 'make -j4' parallel build
config/Makefile:126: The path '/usr/bin/python2-config' is not executable.
config/Makefile:339: No libdw DWARF unwind found, Please install
elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR
config/Makefile:481: Missing perl devel files. Disabling perl scripting
support, consider installing perl-ExtUtils-Embed
config/Makefile:512: No python-config tool was found
config/Makefile:512: Python support will not be built
 
> [1] https://www.python.org/dev/peps/pep-0394
> 
> Suggested-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
> Tested-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/config/Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
> index e05d8f99424d..60177278a357 100644
> --- a/tools/perf/config/Makefile
> +++ b/tools/perf/config/Makefile
> @@ -121,8 +121,8 @@ ifdef PARSER_DEBUG
>  endif
>  
>  ifndef NO_LIBPYTHON
> -  override PYTHON := \
> -    $(call get-executable-or-default,PYTHON,python)
> +  PYTHON2 := $(if $(call get-executable,python2),python2,python)
> +  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
>    override PYTHON_CONFIG := \
>      $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
>  
> -- 
> 2.0.0

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

* Re: [PATCH v2 2/2] perf tools: Default to python version 2
  2014-08-01 20:21   ` Arnaldo Carvalho de Melo
@ 2014-08-02 10:56     ` Thomas Ilsche
  2014-08-02 13:20       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Ilsche @ 2014-08-02 10:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Peter Zijlstra, Ingo Molnar, Paul Mackerras,
	Namhyung Kim, LKML, Jiri Olsa, Thomas Ilsche

[-- Attachment #1: Type: text/plain, Size: 3449 bytes --]


Zitat von Arnaldo Carvalho de Melo <acme@kernel.org>:

> Em Tue, Jul 29, 2014 at 03:57:20PM +0900, Namhyung Kim escreveu:
>> According to PEP 394 recommendation [1], it's more portable to use
>> python2 rather than plain python to refer python binary version 2.
>>
>> Since there're distros using python3 by default like Arch, and we
>> don't support python3 (yet), it'd be better using python2 explicitly.
>>
>> But older versions (prior to 2.7) seem not to provide python2 but just
>> python.  Given that it's only old version, try python2 first and then
>> fallback to python.  It'll ensure that it always points to python 2.x.
>
> It should fallback, right?

Yes.

> [acme@fedora14 linux]$ ls -la /usr/bin/python2-config
> ls: cannot access /usr/bin/python2-config: No such file or directory
> [acme@fedora14 linux]$ ls -la /usr/bin/python-config
> lrwxrwxrwx. 1 root root 16 Mar 25 09:43 /usr/bin/python-config ->  
> python2.7-config

Appearently this fedora package symlinks python -> python2 but does not so for
python2-config. The Makefile looks for either python2 or python as fallback and
then assumes that a respective "-config" exists. I think this is a sane assumption.

I guess if this needs to be supported, there needs to be another fallback if
$(PYTHON)-config is not found to try python-config again. However this may
behave weirdly if someone has python2, no python2-devel but python3-devel
installed, sets PYTHON=python2 and then still gets a version error. Or we
somehow only fallback if no PYTHON is specified (not sure how to implemented
that elegantly).

Best,
Thomas


> [acme@fedora14 linux]$ rpm -qf /usr/bin/python-config
> python-devel-2.7-8.fc14.1.x86_64
> [acme@fedora14 linux]$ cat /etc/fedora-release
> Fedora release 14 (Laughlin)
> [acme@fedora14 linux]$
>
> [acme@fedora14 linux]$ time make O=/tmp/build/perf -C tools/perf install
> make: Entering directory `/home/acme/git/linux/tools/perf'
>   BUILD:   Doing 'make -j4' parallel build
> config/Makefile:126: The path '/usr/bin/python2-config' is not executable.
> config/Makefile:339: No libdw DWARF unwind found, Please install
> elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR
> config/Makefile:481: Missing perl devel files. Disabling perl scripting
> support, consider installing perl-ExtUtils-Embed
> config/Makefile:512: No python-config tool was found
> config/Makefile:512: Python support will not be built
>
>> [1] https://www.python.org/dev/peps/pep-0394
>>
>> Suggested-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
>> Tested-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>> ---
>>  tools/perf/config/Makefile | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
>> index e05d8f99424d..60177278a357 100644
>> --- a/tools/perf/config/Makefile
>> +++ b/tools/perf/config/Makefile
>> @@ -121,8 +121,8 @@ ifdef PARSER_DEBUG
>>  endif
>>
>>  ifndef NO_LIBPYTHON
>> -  override PYTHON := \
>> -    $(call get-executable-or-default,PYTHON,python)
>> +  PYTHON2 := $(if $(call get-executable,python2),python2,python)
>> +  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
>>    override PYTHON_CONFIG := \
>>      $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
>>
>> --
>> 2.0.0





[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5015 bytes --]

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

* Re: [PATCH v2 2/2] perf tools: Default to python version 2
  2014-08-02 10:56     ` Thomas Ilsche
@ 2014-08-02 13:20       ` Arnaldo Carvalho de Melo
  2014-08-04 13:03         ` [PATCH v3 " Thomas Ilsche
  0 siblings, 1 reply; 10+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-08-02 13:20 UTC (permalink / raw)
  To: Thomas Ilsche
  Cc: Namhyung Kim, Peter Zijlstra, Ingo Molnar, Paul Mackerras,
	Namhyung Kim, LKML, Jiri Olsa

Em Sat, Aug 02, 2014 at 12:56:48PM +0200, Thomas Ilsche escreveu:
> 
> Zitat von Arnaldo Carvalho de Melo <acme@kernel.org>:
> 
> > Em Tue, Jul 29, 2014 at 03:57:20PM +0900, Namhyung Kim escreveu:
> >> According to PEP 394 recommendation [1], it's more portable to use
> >> python2 rather than plain python to refer python binary version 2.
> >>
> >> Since there're distros using python3 by default like Arch, and we
> >> don't support python3 (yet), it'd be better using python2 explicitly.
> >>
> >> But older versions (prior to 2.7) seem not to provide python2 but just
> >> python.  Given that it's only old version, try python2 first and then
> >> fallback to python.  It'll ensure that it always points to python 2.x.
> >
> > It should fallback, right?
> 
> Yes.
> 
> > [acme@fedora14 linux]$ ls -la /usr/bin/python2-config
> > ls: cannot access /usr/bin/python2-config: No such file or directory
> > [acme@fedora14 linux]$ ls -la /usr/bin/python-config
> > lrwxrwxrwx. 1 root root 16 Mar 25 09:43 /usr/bin/python-config ->  
> > python2.7-config
> 
> Appearently this fedora package symlinks python -> python2 but does not so for
> python2-config. The Makefile looks for either python2 or python as fallback and
> then assumes that a respective "-config" exists. I think this is a sane assumption.

Maybe the way python was packaged on f14 is problematic, as you
describe, but the fact is that python support is not working on that
platform after this patch.

Could you please try to prepare a patch that does as you suggest so that
I can try?

Thanks,

- Arnaldo
 
> I guess if this needs to be supported, there needs to be another fallback if
> $(PYTHON)-config is not found to try python-config again. However this may
> behave weirdly if someone has python2, no python2-devel but python3-devel
> installed, sets PYTHON=python2 and then still gets a version error. Or we
> somehow only fallback if no PYTHON is specified (not sure how to implemented
> that elegantly).
> 
> Best,
> Thomas
> 
> 
> > [acme@fedora14 linux]$ rpm -qf /usr/bin/python-config
> > python-devel-2.7-8.fc14.1.x86_64
> > [acme@fedora14 linux]$ cat /etc/fedora-release
> > Fedora release 14 (Laughlin)
> > [acme@fedora14 linux]$
> >
> > [acme@fedora14 linux]$ time make O=/tmp/build/perf -C tools/perf install
> > make: Entering directory `/home/acme/git/linux/tools/perf'
> >   BUILD:   Doing 'make -j4' parallel build
> > config/Makefile:126: The path '/usr/bin/python2-config' is not executable.
> > config/Makefile:339: No libdw DWARF unwind found, Please install
> > elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR
> > config/Makefile:481: Missing perl devel files. Disabling perl scripting
> > support, consider installing perl-ExtUtils-Embed
> > config/Makefile:512: No python-config tool was found
> > config/Makefile:512: Python support will not be built
> >
> >> [1] https://www.python.org/dev/peps/pep-0394
> >>
> >> Suggested-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
> >> Tested-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
> >> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> >> ---
> >>  tools/perf/config/Makefile | 4 ++--
> >>  1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
> >> index e05d8f99424d..60177278a357 100644
> >> --- a/tools/perf/config/Makefile
> >> +++ b/tools/perf/config/Makefile
> >> @@ -121,8 +121,8 @@ ifdef PARSER_DEBUG
> >>  endif
> >>
> >>  ifndef NO_LIBPYTHON
> >> -  override PYTHON := \
> >> -    $(call get-executable-or-default,PYTHON,python)
> >> +  PYTHON2 := $(if $(call get-executable,python2),python2,python)
> >> +  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
> >>    override PYTHON_CONFIG := \
> >>      $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
> >>
> >> --
> >> 2.0.0
> 
> 
> 
> 



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

* [PATCH v3 2/2] perf tools: Default to python version 2
  2014-08-02 13:20       ` Arnaldo Carvalho de Melo
@ 2014-08-04 13:03         ` Thomas Ilsche
  2014-08-04 15:35           ` Arnaldo Carvalho de Melo
  2014-08-13  5:19           ` [tip:perf/core] " tip-bot for Thomas Ilsche
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas Ilsche @ 2014-08-04 13:03 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Peter Zijlstra, Ingo Molnar, Paul Mackerras,
	Namhyung Kim, LKML, Jiri Olsa

On 2014-08-02 15:20, Arnaldo Carvalho de Melo wrote:
> Maybe the way python was packaged on f14 is problematic, as you
> describe, but the fact is that python support is not working on that
> platform after this patch.
> 
> Could you please try to prepare a patch that does as you suggest so that
> I can try?

Please try the patch below.
I tested (compiles and perf script runs) with the combinations:

1) python  -> python2.x, python-config  -> python2.x-config
   python2 N/A,          python2-config N/A

2) python  -> python3.x, python-config  -> python3.x-config
   python2 -> python2.x, python2-config -> python2.x-config

3) python  -> python2.x, python-config  -> python2.x-config
   python2 -> python2.x, python2-config -> python2.x-config

4) python  -> python2.x, python-config  -> python2.x-config
   python2 -> python2.x, python2-config N/A

Based on / replaces the patch 2/2 by Namhyung Kim.

Signed-off-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
---
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 9ee2008..0528cd37 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -104,10 +104,16 @@ ifdef PARSER_DEBUG
 endif
 
 ifndef NO_LIBPYTHON
-  override PYTHON := \
-    $(call get-executable-or-default,PYTHON,python)
+  # Try different combinations to accommodate systems that only have
+  # python[2][-config] in weird combinations but always preferring
+  # python2 and python2-config as per pep-0394. If we catch a
+  # python[-config] in version 3, the version check will kill it.
+  PYTHON2 := $(if $(call get-executable,python2),python2,python)
+  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
+  PYTHON2_CONFIG := \
+    $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
   override PYTHON_CONFIG := \
-    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
 
   PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))

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

* Re: [PATCH v3 2/2] perf tools: Default to python version 2
  2014-08-04 13:03         ` [PATCH v3 " Thomas Ilsche
@ 2014-08-04 15:35           ` Arnaldo Carvalho de Melo
  2014-08-13  5:19           ` [tip:perf/core] " tip-bot for Thomas Ilsche
  1 sibling, 0 replies; 10+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-08-04 15:35 UTC (permalink / raw)
  To: Thomas Ilsche
  Cc: Namhyung Kim, Peter Zijlstra, Ingo Molnar, Paul Mackerras,
	Namhyung Kim, LKML, Jiri Olsa

Em Mon, Aug 04, 2014 at 03:03:15PM +0200, Thomas Ilsche escreveu:
> On 2014-08-02 15:20, Arnaldo Carvalho de Melo wrote:
> > Maybe the way python was packaged on f14 is problematic, as you
> > describe, but the fact is that python support is not working on that
> > platform after this patch.
> > 
> > Could you please try to prepare a patch that does as you suggest so that
> > I can try?
> 
> Please try the patch below.
> I tested (compiles and perf script runs) with the combinations:

Thanks, now it works (my perf/core branch + this patch) on:

fedora14 x86_64
fedora19 x86_64
fedora20 x86_64
RHEL6.3 x86_64
opensuse12.3 i386
ubuntu13.10 x86_64 

- Arnaldo

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

* [tip:perf/core] perf tools: Fix make PYTHON override
  2014-07-29  6:57 [PATCH v2 1/2] perf tools: Fix make PYTHON override Namhyung Kim
  2014-07-29  6:57 ` [PATCH v2 2/2] perf tools: Default to python version 2 Namhyung Kim
  2014-07-31 14:38 ` [PATCH v2 1/2] perf tools: Fix make PYTHON override Arnaldo Carvalho de Melo
@ 2014-08-13  5:17 ` tip-bot for Namhyung Kim
  2 siblings, 0 replies; 10+ messages in thread
From: tip-bot for Namhyung Kim @ 2014-08-13  5:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
	namhyung.kim, namhyung, jolsa, thomas.ilsche, tglx

Commit-ID:  56c7d79e49776084b852e451bda5f59dc3bcf894
Gitweb:     http://git.kernel.org/tip/56c7d79e49776084b852e451bda5f59dc3bcf894
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Tue, 29 Jul 2014 15:57:19 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 12 Aug 2014 12:03:04 -0300

perf tools: Fix make PYTHON override

Thomas reported that make PYTHON=python2 is not work on some systems.  I
can reproduce it on my ArchLinux box too.

This is because it's overridden by config/feature-checks/Makefile
regardless of PYTHON setting.  I guess it's a bug slipped into during
the feature checking change.

Actually, we don't need to check python-config in the feature-checks.
We can just pass appropriate FEATURE_CHECK_*FLAGS.

Reported-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Link: http://lkml.kernel.org/r/1406617040-26909-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/config/Makefile                | 34 ++++++++++++++++++++-----------
 tools/perf/config/feature-checks/Makefile | 18 ++--------------
 2 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 1f67aa0..e05d8f9 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -120,6 +120,23 @@ ifdef PARSER_DEBUG
   CFLAGS             += -DPARSER_DEBUG
 endif
 
+ifndef NO_LIBPYTHON
+  override PYTHON := \
+    $(call get-executable-or-default,PYTHON,python)
+  override PYTHON_CONFIG := \
+    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+
+  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
+
+  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
+  PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
+
+  FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
+  FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
+  FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
+  FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
+endif
+
 CFLAGS += -fno-omit-frame-pointer
 CFLAGS += -ggdb3
 CFLAGS += -funwind-tables
@@ -482,21 +499,14 @@ define disable-python_code
   NO_LIBPYTHON := 1
 endef
 
-override PYTHON := \
-  $(call get-executable-or-default,PYTHON,python)
-
-ifndef PYTHON
-  $(call disable-python,python interpreter)
+ifdef NO_LIBPYTHON
+  $(call disable-python)
 else
 
-  PYTHON_WORD := $(call shell-wordify,$(PYTHON))
-
-  ifdef NO_LIBPYTHON
-    $(call disable-python)
+  ifndef PYTHON
+    $(call disable-python,python interpreter)
   else
-
-    override PYTHON_CONFIG := \
-      $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+    PYTHON_WORD := $(call shell-wordify,$(PYTHON))
 
     ifndef PYTHON_CONFIG
       $(call disable-python,python-config tool)
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 6088f8d..72ab298 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -101,25 +101,11 @@ FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 test-libperl.bin:
 	$(BUILD) $(FLAGS_PERL_EMBED)
 
-override PYTHON := python
-override PYTHON_CONFIG := python-config
-
-escape-for-shell-sq =  $(subst ','\'',$(1))
-shell-sq = '$(escape-for-shell-sq)'
-
-PYTHON_CONFIG_SQ = $(call shell-sq,$(PYTHON_CONFIG))
-
-PYTHON_EMBED_LDOPTS = $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
-PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_CCOPTS = $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
-FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
-
 test-libpython.bin:
-	$(BUILD) $(FLAGS_PYTHON_EMBED)
+	$(BUILD)
 
 test-libpython-version.bin:
-	$(BUILD) $(FLAGS_PYTHON_EMBED)
+	$(BUILD)
 
 test-libbfd.bin:
 	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl

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

* [tip:perf/core] perf tools: Default to python version 2
  2014-08-04 13:03         ` [PATCH v3 " Thomas Ilsche
  2014-08-04 15:35           ` Arnaldo Carvalho de Melo
@ 2014-08-13  5:19           ` tip-bot for Thomas Ilsche
  1 sibling, 0 replies; 10+ messages in thread
From: tip-bot for Thomas Ilsche @ 2014-08-13  5:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, namhyung,
	jolsa, thomas.ilsche, tglx

Commit-ID:  d6a947fb6cdff3a19db93895c746f70b5903a965
Gitweb:     http://git.kernel.org/tip/d6a947fb6cdff3a19db93895c746f70b5903a965
Author:     Thomas Ilsche <thomas.ilsche@tu-dresden.de>
AuthorDate: Mon, 4 Aug 2014 15:03:15 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 12 Aug 2014 12:03:08 -0300

perf tools: Default to python version 2

According to PEP 394 recommendation [1], it's more portable to use
python2 rather than plain python to refer python binary version 2.

Since there're distros using python3 by default like Arch, and we don't
support python3 (yet), it'd be better using python2 explicitly.

But older versions (prior to 2.7) seem not to provide python2 but just
python.  Given that it's only old version, try python2 first and then
fallback to python.  It'll ensure that it always points to python 2.x.

I tested (compiles and perf script runs) with the combinations:

1) python  -> python2.x, python-config  -> python2.x-config
   python2 N/A,          python2-config N/A

2) python  -> python3.x, python-config  -> python3.x-config
   python2 -> python2.x, python2-config -> python2.x-config

3) python  -> python2.x, python-config  -> python2.x-config
   python2 -> python2.x, python2-config -> python2.x-config

4) python  -> python2.x, python-config  -> python2.x-config
   python2 -> python2.x, python2-config N/A

Based on / replaces the patch 2/2 by Namhyung Kim.

[1] https://www.python.org/dev/peps/pep-0394

Based-on-patch-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/53DF8493.6070206@tu-dresden.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/config/Makefile | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index e05d8f9..75d4c23 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -121,10 +121,16 @@ ifdef PARSER_DEBUG
 endif
 
 ifndef NO_LIBPYTHON
-  override PYTHON := \
-    $(call get-executable-or-default,PYTHON,python)
+  # Try different combinations to accommodate systems that only have
+  # python[2][-config] in weird combinations but always preferring
+  # python2 and python2-config as per pep-0394. If we catch a
+  # python[-config] in version 3, the version check will kill it.
+  PYTHON2 := $(if $(call get-executable,python2),python2,python)
+  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
+  PYTHON2_CONFIG := \
+    $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
   override PYTHON_CONFIG := \
-    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
 
   PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
 

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

end of thread, other threads:[~2014-08-13  5:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-29  6:57 [PATCH v2 1/2] perf tools: Fix make PYTHON override Namhyung Kim
2014-07-29  6:57 ` [PATCH v2 2/2] perf tools: Default to python version 2 Namhyung Kim
2014-08-01 20:21   ` Arnaldo Carvalho de Melo
2014-08-02 10:56     ` Thomas Ilsche
2014-08-02 13:20       ` Arnaldo Carvalho de Melo
2014-08-04 13:03         ` [PATCH v3 " Thomas Ilsche
2014-08-04 15:35           ` Arnaldo Carvalho de Melo
2014-08-13  5:19           ` [tip:perf/core] " tip-bot for Thomas Ilsche
2014-07-31 14:38 ` [PATCH v2 1/2] perf tools: Fix make PYTHON override Arnaldo Carvalho de Melo
2014-08-13  5:17 ` [tip:perf/core] " tip-bot for Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).