Skip to contentSkip to conversation

python3: silence DeprecationWarnings in python3-config

PATCH In review Ross Burton 4 participants 5 messages Nov 2, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 python3: silence DeprecationWarnings in python3-config

Our patched python3-config uses distutils, but that will emit a DeprecationWarning when imported. This isn't useful when using the output of python3-config to find include paths.

This isn't a huge problem typically as the warning goes to stderr, but some build systems read both stdout and stderr.

---
 meta/recipes-devtools/python/python3/python-config.patch | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/python/python3/python-config.patch +3 -2
index d0ddbbc7fd..c53f646af3 100644
@@ -14,7 +14,6 @@ as appropriate.
 Upstream-Status: Inappropriate [Embedded Specific]
 
 Signed-off-by: Tyler Hall <[email protected]>
-:
 
 ---
  Misc/python-config.in | 10 +++++-----
@@ -24,11 +23,13 @@ diff --git a/Misc/python-config.in b/Misc/python-config.in
 index ebd99da..13e57ae 100644
 --- a/Misc/python-config.in
 +++ b/Misc/python-config.in
-@@ -6,7 +6,7 @@
+@@ -6,7 +6,9 @@
  import getopt
  import os
  import sys
 -import sysconfig
++import warnings
++warnings.filterwarnings("ignore", category=DeprecationWarning)
 +from distutils import sysconfig
  
  valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Ross Burton

Our patched python3-config uses distutils, but that will emit a DeprecationWarning when imported. This isn't useful when using the output of python3-config to find include paths.

So shouldn’t we fix python3-config to not use distutils and switch to setup tools instead ?

I am afraid that masking the warning will come biting soon when this is turned into a hard error

Quoted 54 lines

This isn't a huge problem typically as the warning goes to stderr, but some build systems read both stdout and stderr.

---
 meta/recipes-devtools/python/python3/python-config.patch | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/python/python3/python-config.patch +0 -1
index d0ddbbc7fd..c53f646af3 100644
@@ -14,7 +14,6 @@ as appropriate.
 Upstream-Status: Inappropriate [Embedded Specific]
 
 Signed-off-by: Tyler Hall <[email protected]>
-:
 
 ---
  Misc/python-config.in | 10 +++++-----
@@ -24,11 +23,13 @@ diff --git a/Misc/python-config.in b/Misc/

python-config.in
index ebd99da..13e57ae 100644
--- a/Misc/python-config.in
+++ b/Misc/python-config.in
-@@ -6,7 +6,7 @@
+@@ -6,7 +6,9 @@
import getopt
import os
import sys
-import sysconfig
++import warnings
++warnings.filterwarnings("ignore", category=DeprecationWarning)
+from distutils import sysconfig

valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
--
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#157806):
https://lists.openembedded.org/g/openembedded-core/message/157806
Mute This Topic: https://lists.openembedded.org/mt/86772899/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 3 lines · Khem Raj

So shouldn’t we fix python3-config to not use distutils and switch to setup tools instead ?

I am afraid that masking the warning will come biting soon when this is turned into a hard error

That is a much bigger question that needs to be done, but most likely involves rewriting large chunks of the cross integration as from what I can tell, setuptools doesn't expose sysconfig (and we patch distutils.sysconfig).

We can continue hacking the hack, until we solve this properly. This may happen as part of the pyo3 rust/python problem.

Ross

#3 lore raw
Quoted 6 lines · Ross Burton
Quoted 3 lines · Khem Raj

So shouldn’t we fix python3-config to not use distutils and switch to setup tools instead ?

I am afraid that masking the warning will come biting soon when this is turned into a hard error

Quoted 7 lines

That is a much bigger question that needs to be done, but most likely involves rewriting large chunks of the cross integration as from what I can tell, setuptools doesn't expose sysconfig (and we patch distutils.sysconfig).

We can continue hacking the hack, until we solve this properly. This may happen as part of the pyo3 rust/python problem.

I guess, this patch is fine for what it is solving for now, I was hopeful that converting to not use
distutils would be easy :)

Quoted 2 lines

Ross

#4 lore raw
Quoted 14 lines · Khem Raj
Quoted 3 lines · Ross Burton
Quoted 1 line · Khem Raj

So shouldn’t we fix python3-config to not use distutils and switch to

setup tools instead ?

Quoted 2 lines
Quoted 2 lines

I am afraid that masking the warning will come biting soon when this

is turned into a hard error

Quoted 6 lines

That is a much bigger question that needs to be done, but most likely involves rewriting large chunks of the cross integration as from what I can tell, setuptools doesn't expose sysconfig (and we patch distutils.sysconfig).

Quoted 7 lines
Quoted 2 lines

We can continue hacking the hack, until we solve this properly. This may happen as part of the pyo3 rust/python problem.

I guess, this patch is fine for what it is solving for now, I was hopeful that converting to not use
distutils would be easy :)

The distutils.sysconfig.get_python_inc(plat_specific=True) call has no replacement. It will have to be rewritten.

Quoted 14 lines
Quoted 2 lines

Ross

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#157815):
https://lists.openembedded.org/g/openembedded-core/message/157815
Mute This Topic: https://lists.openembedded.org/mt/86772899/924729
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-