All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] python3native, pythonnative: export PYTHON_LIBRARY and PYTHON_INCLUDE_DIR
@ 2019-09-04 18:49 Khem Raj
  2019-09-04 18:58 ` Alexander Kanavin
  0 siblings, 1 reply; 3+ messages in thread
From: Khem Raj @ 2019-09-04 18:49 UTC (permalink / raw)
  To: openembedded-core

packages can use

find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED)

while we control PYTHON pointing to native py3 the libs and include
directories will then point to build host version, which can result in
unexpected combination and if we are lucky we get errors if its quite
different e.g. py2 libs/includes and py3 executable

This variable can be then used to export PYTHON_LIBRARY and
PYTHON_INCLUDE_DIR so that above find_packages can work correctly

see [1] for how it happens in cmake

LLDB uses it see [2]

[1] https://github.com/Kitware/CMake/blob/master/Modules/FindPythonLibs.cmake
[2] https://github.com/llvm/llvm-project/blob/master/lldb/cmake/modules/LLDBConfig.cmake#L226

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2: Use PYTHON_DIR variable

 meta/classes/python3native.bbclass | 8 ++++++++
 meta/classes/pythonnative.bbclass  | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/meta/classes/python3native.bbclass b/meta/classes/python3native.bbclass
index a3acaf61bb..768302488b 100644
--- a/meta/classes/python3native.bbclass
+++ b/meta/classes/python3native.bbclass
@@ -9,6 +9,14 @@ DEPENDS_append = " python3-native "
 export STAGING_INCDIR
 export STAGING_LIBDIR
 
+# Packages can use
+# find_package(PythonInterp REQUIRED)
+# find_package(PythonLibs REQUIRED)
+# which ends up using libs/includes from build host
+# Therefore pre-empt that effort
+export PYTHON_LIBRARY="${STAGING_LIBDIR}/${PYTHON_DIR}"
+export PYTHON_INCLUDE_DIR="${STAGING_INCDIR}/${PYTHON_DIR}"
+
 export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
 
 # suppress host user's site-packages dirs.
diff --git a/meta/classes/pythonnative.bbclass b/meta/classes/pythonnative.bbclass
index ae6600cd15..604423b80e 100644
--- a/meta/classes/pythonnative.bbclass
+++ b/meta/classes/pythonnative.bbclass
@@ -12,6 +12,14 @@ DEPENDS_append = " python-native "
 export STAGING_INCDIR
 export STAGING_LIBDIR
 
+# Packages can use
+# find_package(PythonInterp REQUIRED)
+# find_package(PythonLibs REQUIRED)
+# which ends up using libs/includes from build host
+# Therefore pre-empt that effort
+export PYTHON_LIBRARY="${STAGING_LIBDIR}/${PYTHON_DIR}"
+export PYTHON_INCLUDE_DIR="${STAGING_INCDIR}/${PYTHON_DIR}"
+
 # suppress host user's site-packages dirs.
 export PYTHONNOUSERSITE = "1"
 
-- 
2.23.0



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

* Re: [PATCH V2] python3native, pythonnative: export PYTHON_LIBRARY and PYTHON_INCLUDE_DIR
  2019-09-04 18:49 [PATCH V2] python3native, pythonnative: export PYTHON_LIBRARY and PYTHON_INCLUDE_DIR Khem Raj
@ 2019-09-04 18:58 ` Alexander Kanavin
  2019-09-04 19:25   ` Khem Raj
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Kanavin @ 2019-09-04 18:58 UTC (permalink / raw)
  To: Khem Raj; +Cc: OE-core

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

Thanks, this looks good now.

Alex

On Wed, 4 Sep 2019 at 20:49, Khem Raj <raj.khem@gmail.com> wrote:

> packages can use
>
> find_package(PythonInterp REQUIRED)
> find_package(PythonLibs REQUIRED)
>
> while we control PYTHON pointing to native py3 the libs and include
> directories will then point to build host version, which can result in
> unexpected combination and if we are lucky we get errors if its quite
> different e.g. py2 libs/includes and py3 executable
>
> This variable can be then used to export PYTHON_LIBRARY and
> PYTHON_INCLUDE_DIR so that above find_packages can work correctly
>
> see [1] for how it happens in cmake
>
> LLDB uses it see [2]
>
> [1]
> https://github.com/Kitware/CMake/blob/master/Modules/FindPythonLibs.cmake
> [2]
> https://github.com/llvm/llvm-project/blob/master/lldb/cmake/modules/LLDBConfig.cmake#L226
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
> v2: Use PYTHON_DIR variable
>
>  meta/classes/python3native.bbclass | 8 ++++++++
>  meta/classes/pythonnative.bbclass  | 8 ++++++++
>  2 files changed, 16 insertions(+)
>
> diff --git a/meta/classes/python3native.bbclass
> b/meta/classes/python3native.bbclass
> index a3acaf61bb..768302488b 100644
> --- a/meta/classes/python3native.bbclass
> +++ b/meta/classes/python3native.bbclass
> @@ -9,6 +9,14 @@ DEPENDS_append = " python3-native "
>  export STAGING_INCDIR
>  export STAGING_LIBDIR
>
> +# Packages can use
> +# find_package(PythonInterp REQUIRED)
> +# find_package(PythonLibs REQUIRED)
> +# which ends up using libs/includes from build host
> +# Therefore pre-empt that effort
> +export PYTHON_LIBRARY="${STAGING_LIBDIR}/${PYTHON_DIR}"
> +export PYTHON_INCLUDE_DIR="${STAGING_INCDIR}/${PYTHON_DIR}"
> +
>  export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
>
>  # suppress host user's site-packages dirs.
> diff --git a/meta/classes/pythonnative.bbclass
> b/meta/classes/pythonnative.bbclass
> index ae6600cd15..604423b80e 100644
> --- a/meta/classes/pythonnative.bbclass
> +++ b/meta/classes/pythonnative.bbclass
> @@ -12,6 +12,14 @@ DEPENDS_append = " python-native "
>  export STAGING_INCDIR
>  export STAGING_LIBDIR
>
> +# Packages can use
> +# find_package(PythonInterp REQUIRED)
> +# find_package(PythonLibs REQUIRED)
> +# which ends up using libs/includes from build host
> +# Therefore pre-empt that effort
> +export PYTHON_LIBRARY="${STAGING_LIBDIR}/${PYTHON_DIR}"
> +export PYTHON_INCLUDE_DIR="${STAGING_INCDIR}/${PYTHON_DIR}"
> +
>  # suppress host user's site-packages dirs.
>  export PYTHONNOUSERSITE = "1"
>
> --
> 2.23.0
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>

[-- Attachment #2: Type: text/html, Size: 3905 bytes --]

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

* Re: [PATCH V2] python3native, pythonnative: export PYTHON_LIBRARY and PYTHON_INCLUDE_DIR
  2019-09-04 18:58 ` Alexander Kanavin
@ 2019-09-04 19:25   ` Khem Raj
  0 siblings, 0 replies; 3+ messages in thread
From: Khem Raj @ 2019-09-04 19:25 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: OE-core

wait for v3 on this I am doing a build which is still not done yet.

On Wed, Sep 4, 2019 at 11:58 AM Alexander Kanavin
<alex.kanavin@gmail.com> wrote:
>
> Thanks, this looks good now.
>
> Alex
>
> On Wed, 4 Sep 2019 at 20:49, Khem Raj <raj.khem@gmail.com> wrote:
>>
>> packages can use
>>
>> find_package(PythonInterp REQUIRED)
>> find_package(PythonLibs REQUIRED)
>>
>> while we control PYTHON pointing to native py3 the libs and include
>> directories will then point to build host version, which can result in
>> unexpected combination and if we are lucky we get errors if its quite
>> different e.g. py2 libs/includes and py3 executable
>>
>> This variable can be then used to export PYTHON_LIBRARY and
>> PYTHON_INCLUDE_DIR so that above find_packages can work correctly
>>
>> see [1] for how it happens in cmake
>>
>> LLDB uses it see [2]
>>
>> [1] https://github.com/Kitware/CMake/blob/master/Modules/FindPythonLibs.cmake
>> [2] https://github.com/llvm/llvm-project/blob/master/lldb/cmake/modules/LLDBConfig.cmake#L226
>>
>> Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> ---
>> v2: Use PYTHON_DIR variable
>>
>>  meta/classes/python3native.bbclass | 8 ++++++++
>>  meta/classes/pythonnative.bbclass  | 8 ++++++++
>>  2 files changed, 16 insertions(+)
>>
>> diff --git a/meta/classes/python3native.bbclass b/meta/classes/python3native.bbclass
>> index a3acaf61bb..768302488b 100644
>> --- a/meta/classes/python3native.bbclass
>> +++ b/meta/classes/python3native.bbclass
>> @@ -9,6 +9,14 @@ DEPENDS_append = " python3-native "
>>  export STAGING_INCDIR
>>  export STAGING_LIBDIR
>>
>> +# Packages can use
>> +# find_package(PythonInterp REQUIRED)
>> +# find_package(PythonLibs REQUIRED)
>> +# which ends up using libs/includes from build host
>> +# Therefore pre-empt that effort
>> +export PYTHON_LIBRARY="${STAGING_LIBDIR}/${PYTHON_DIR}"
>> +export PYTHON_INCLUDE_DIR="${STAGING_INCDIR}/${PYTHON_DIR}"
>> +
>>  export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
>>
>>  # suppress host user's site-packages dirs.
>> diff --git a/meta/classes/pythonnative.bbclass b/meta/classes/pythonnative.bbclass
>> index ae6600cd15..604423b80e 100644
>> --- a/meta/classes/pythonnative.bbclass
>> +++ b/meta/classes/pythonnative.bbclass
>> @@ -12,6 +12,14 @@ DEPENDS_append = " python-native "
>>  export STAGING_INCDIR
>>  export STAGING_LIBDIR
>>
>> +# Packages can use
>> +# find_package(PythonInterp REQUIRED)
>> +# find_package(PythonLibs REQUIRED)
>> +# which ends up using libs/includes from build host
>> +# Therefore pre-empt that effort
>> +export PYTHON_LIBRARY="${STAGING_LIBDIR}/${PYTHON_DIR}"
>> +export PYTHON_INCLUDE_DIR="${STAGING_INCDIR}/${PYTHON_DIR}"
>> +
>>  # suppress host user's site-packages dirs.
>>  export PYTHONNOUSERSITE = "1"
>>
>> --
>> 2.23.0
>>
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core


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

end of thread, other threads:[~2019-09-04 19:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04 18:49 [PATCH V2] python3native, pythonnative: export PYTHON_LIBRARY and PYTHON_INCLUDE_DIR Khem Raj
2019-09-04 18:58 ` Alexander Kanavin
2019-09-04 19:25   ` Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.