diff mbox series

[V2] python3native, pythonnative: export PYTHON_LIBRARY and PYTHON_INCLUDE_DIR

Message ID 20190904184928.8414-1-raj.khem@gmail.com
State Superseded
Headers show
Series [V2] python3native, pythonnative: export PYTHON_LIBRARY and PYTHON_INCLUDE_DIR | expand

Commit Message

Khem Raj Sept. 4, 2019, 6:49 p.m. UTC
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(+)

-- 
2.23.0

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Comments

Alexander Kanavin Sept. 4, 2019, 6:58 p.m. UTC | #1
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

>
<div dir="ltr"><div>Thanks, this looks good now.</div><div><br></div><div>Alex<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 4 Sep 2019 at 20:49, Khem Raj &lt;<a href="mailto:raj.khem@gmail.com">raj.khem@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">packages can use<br>
<br>
find_package(PythonInterp REQUIRED)<br>
find_package(PythonLibs REQUIRED)<br>
<br>
while we control PYTHON pointing to native py3 the libs and include<br>
directories will then point to build host version, which can result in<br>
unexpected combination and if we are lucky we get errors if its quite<br>
different e.g. py2 libs/includes and py3 executable<br>
<br>
This variable can be then used to export PYTHON_LIBRARY and<br>
PYTHON_INCLUDE_DIR so that above find_packages can work correctly<br>
<br>
see [1] for how it happens in cmake<br>
<br>
LLDB uses it see [2]<br>
<br>
[1] <a href="https://github.com/Kitware/CMake/blob/master/Modules/FindPythonLibs.cmake" rel="noreferrer" target="_blank">https://github.com/Kitware/CMake/blob/master/Modules/FindPythonLibs.cmake</a><br>
[2] <a href="https://github.com/llvm/llvm-project/blob/master/lldb/cmake/modules/LLDBConfig.cmake#L226" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/blob/master/lldb/cmake/modules/LLDBConfig.cmake#L226</a><br>
<br>
Signed-off-by: Khem Raj &lt;<a href="mailto:raj.khem@gmail.com" target="_blank">raj.khem@gmail.com</a>&gt;<br>

---<br>
v2: Use PYTHON_DIR variable<br>
<br>
 meta/classes/python3native.bbclass | 8 ++++++++<br>
 meta/classes/pythonnative.bbclass  | 8 ++++++++<br>
 2 files changed, 16 insertions(+)<br>
<br>
diff --git a/meta/classes/python3native.bbclass b/meta/classes/python3native.bbclass<br>
index a3acaf61bb..768302488b 100644<br>
--- a/meta/classes/python3native.bbclass<br>
+++ b/meta/classes/python3native.bbclass<br>
@@ -9,6 +9,14 @@ DEPENDS_append = &quot; python3-native &quot;<br>
 export STAGING_INCDIR<br>
 export STAGING_LIBDIR<br>
<br>
+# Packages can use<br>
+# find_package(PythonInterp REQUIRED)<br>
+# find_package(PythonLibs REQUIRED)<br>
+# which ends up using libs/includes from build host<br>
+# Therefore pre-empt that effort<br>
+export PYTHON_LIBRARY=&quot;${STAGING_LIBDIR}/${PYTHON_DIR}&quot;<br>
+export PYTHON_INCLUDE_DIR=&quot;${STAGING_INCDIR}/${PYTHON_DIR}&quot;<br>
+<br>
 export _PYTHON_SYSCONFIGDATA_NAME=&quot;_sysconfigdata&quot;<br>
<br>
 # suppress host user&#39;s site-packages dirs.<br>
diff --git a/meta/classes/pythonnative.bbclass b/meta/classes/pythonnative.bbclass<br>
index ae6600cd15..604423b80e 100644<br>
--- a/meta/classes/pythonnative.bbclass<br>
+++ b/meta/classes/pythonnative.bbclass<br>
@@ -12,6 +12,14 @@ DEPENDS_append = &quot; python-native &quot;<br>
 export STAGING_INCDIR<br>
 export STAGING_LIBDIR<br>
<br>
+# Packages can use<br>
+# find_package(PythonInterp REQUIRED)<br>
+# find_package(PythonLibs REQUIRED)<br>
+# which ends up using libs/includes from build host<br>
+# Therefore pre-empt that effort<br>
+export PYTHON_LIBRARY=&quot;${STAGING_LIBDIR}/${PYTHON_DIR}&quot;<br>
+export PYTHON_INCLUDE_DIR=&quot;${STAGING_INCDIR}/${PYTHON_DIR}&quot;<br>
+<br>
 # suppress host user&#39;s site-packages dirs.<br>
 export PYTHONNOUSERSITE = &quot;1&quot;<br>
<br>
-- <br>
2.23.0<br>
<br>
-- <br>
_______________________________________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org" target="_blank">Openembedded-core@lists.openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/mailman/listinfo/openembedded-core</a><br>
</blockquote></div>
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Khem Raj Sept. 4, 2019, 7:25 p.m. UTC | #2
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

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
diff mbox series

Patch

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"