Repository: conan-io/conan-center-index

Issue:
[package] boost/1.78.0: fails to find Python
The recipe seems to fail finding Python 3.10.
Building Boost manually works, so it suggests the problem is with the Conan recipe.
also getting warnings about distutils package being deprecated.

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **boost/1.78.0**
  * Operating System+version: **Manjaro (fresh install)**
  * Compiler+version: **GCC 11.1**
  * Conan version: **conan 1.44.0**
  * Python version: **Python 3.10.1**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.libcxx=libstdc++
build_type=Release
[options]
[conf]
[build_requires]
[env]
```


### Steps to reproduce (Include if Applicable)
call `conan install . --build=outdated` with the follow recipe:
```
[requires]
boost/1.78.0

[options]
boost:without_python=False
```


### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
conan install . --build=outdated
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=11
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sys; print('{}.{}'.format(sys.version_info[0], sys.version_info[1]))"
bzip2/1.0.8: Package is up to date
libbacktrace/cci.20210118: Package is up to date
zlib/1.2.11: Package is up to date
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sys; print('{}.{}'.format(sys.version_info[0], sys.version_info[1]))"
boost/1.78.0: WARN: Package binary is corrupted, removing: 090a15e8d2c710a571a6883f9c69f86ba3d1e028
b2/4.5.0: Package is up to date
conanfile.txt: Installing package
Requirements
    boost/1.78.0 from 'conancenter' - Cache
    bzip2/1.0.8 from 'conancenter' - Cache
    libbacktrace/cci.20210118 from 'conancenter' - Cache
    zlib/1.2.11 from 'conancenter' - Cache
Packages
    boost/1.78.0:090a15e8d2c710a571a6883f9c69f86ba3d1e028 - Build
    bzip2/1.0.8:c32092bf4d4bb47cf962af898e02823f499b017e - Cache
    libbacktrace/cci.20210118:dfbe50feef7f3c6223a476cd5aeadb687084a646 - Cache
    zlib/1.2.11:dfbe50feef7f3c6223a476cd5aeadb687084a646 - Cache
Build requirements
    b2/4.5.0 from 'conancenter' - Cache
Build requirements packages
    b2/4.5.0:4db1be536558d833e52e862fd84d64d75c2b3656 - Cache

Installing (downloading, building) binaries...
b2/4.5.0: Already installed!
bzip2/1.0.8: Already installed!
bzip2/1.0.8: Appending PATH environment variable: /home/vm/.conan/data/bzip2/1.0.8/_/_/package/c32092bf4d4bb47cf962af898e02823f499b017e/bin
libbacktrace/cci.20210118: Already installed!
zlib/1.2.11: Already installed!
boost/1.78.0: Applying build-requirement: b2/4.5.0
boost/1.78.0: WARN: Build folder is dirty, removing it: /home/vm/.conan/data/boost/1.78.0/_/_/build/090a15e8d2c710a571a6883f9c69f86ba3d1e028
boost/1.78.0: Building your package in /home/vm/.conan/data/boost/1.78.0/_/_/build/090a15e8d2c710a571a6883f9c69f86ba3d1e028
boost/1.78.0: Generator txt created conanbuildinfo.txt
boost/1.78.0: Aggregating env generators
boost/1.78.0: Calling build()
WARN: replace_in_file didn't find pattern '/* thread_local */' in '/home/vm/.conan/data/boost/1.78.0/_/_/source/source_subfolder/boost/stacktrace/detail/libbacktrace_impls.hpp' file.
WARN: replace_in_file didn't find pattern '/* static __thread */' in '/home/vm/.conan/data/boost/1.78.0/_/_/source/source_subfolder/boost/stacktrace/detail/libbacktrace_impls.hpp' file.
WARN: replace_in_file didn't find pattern 'local generic-os = [ set.difference $(all-os) : aix darwin vxworks solaris osf hpux ] ;' in '/home/vm/.conan/data/boost/1.78.0/_/_/source/source_subfolder/tools/build/src/tools/gcc.jam' file.
WARN: replace_in_file didn't find pattern 'local no-threading = android beos haiku sgi darwin vxworks ;' in '/home/vm/.conan/data/boost/1.78.0/_/_/source/source_subfolder/tools/build/src/tools/gcc.jam' file.
WARN: replace_in_file didn't find pattern '    <conditional>@numa' in '/home/vm/.conan/data/boost/1.78.0/_/_/source/source_subfolder/libs/fiber/build/Jamfile.v2' file.
boost/1.78.0: WARN: Patching user-config.jam
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sys; print('{}.{}'.format(sys.version_info[0], sys.version_info[1]))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_path('include'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_path('platinclude'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_config_var('INCLUDEPY'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_config_var('INCLUDEDIR'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_python_inc())"
boost/1.78.0: (failed)
boost/1.78.0: checking /usr/include/python3.10/Python.h
boost/1.78.0: found Python.h: /usr/include/python3.10/Python.h
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_config_var('LIBRARY'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_config_var('LDLIBRARY'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_config_var('LIBDIR'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_config_var('multiarchsubdir'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import distutils.sysconfig as du_sysconfig; print(du_sysconfig.get_config_var('multiarchsubdir'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_config_var('WITH_DYLD'))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sys; print('{}.{}'.format(sys.version_info[0], sys.version_info[1]))"
boost/1.78.0: running "/usr/bin/python" -c "from __future__ import print_function; import sys; print(getattr(sys, 'abiflags', ''))"
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython3.10.so
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython3.10.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python.dylib
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python3.10.dylib
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python310.dylib
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python.so
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python3.10.so
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python310.so
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python.dll.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python3.10.dll.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python310.dll.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python3.10.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/python310.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython.dylib
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython3.10.dylib
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython310.dylib
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython.so
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython3.10.so
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython310.so
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython.dll.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython3.10.dll.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython310.dll.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython3.10.a
boost/1.78.0: checking /usr/lib/<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
None/libpython310.a
boost/1.78.0: 
boost/1.78.0: ERROR: Package '090a15e8d2c710a571a6883f9c69f86ba3d1e028' build failed
boost/1.78.0: WARN: Build folder /home/vm/.conan/data/boost/1.78.0/_/_/build/090a15e8d2c710a571a6883f9c69f86ba3d1e028
ERROR: boost/1.78.0: Invalid configuration: couldn't locate python libraries - make sure you have installed python development files
```

</details>



Discussion:
replacing:
```python
    def _get_python_var(self, name):
        """
        obtain value of python variable, either by sysconfig, or by distutils.sysconfig
        :param name: name of variable to be queried (such as LIBRARY or LDLIBRARY)
        :return: value of python sysconfig variable
        """
        return self._get_python_sc_var(name) or self._get_python_du_var(name)
```

with:
```python
    def _get_python_var(self, name):
        """
        obtain value of python variable, either by sysconfig, or by distutils.sysconfig
        :param name: name of variable to be queried (such as LIBRARY or LDLIBRARY)
        :return: value of python sysconfig variable
        """
        return self._get_python_sc_var(name)
```

fixes the problem and the deprecation warnings.

Resolving patch:
diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py
--- a/recipes/boost/all/conanfile.py
+++ b/recipes/boost/all/conanfile.py
@@ -584,8 +584,16 @@ def _get_python_var(self, name):
         obtain value of python variable, either by sysconfig, or by distutils.sysconfig
         :param name: name of variable to be queried (such as LIBRARY or LDLIBRARY)
         :return: value of python sysconfig variable
+
+        NOTE: distutils is deprecated and breaks the recipe since Python 3.10
         """
-        return self._get_python_sc_var(name) or self._get_python_du_var(name)
+        python_version_parts = self.info.options.python_version.split('.')
+        python_major = int(python_version_parts[0])
+        python_minor = int(python_version_parts[1])
+        if(python_major >= 3 and python_minor >= 10):
+            return self._get_python_sc_var(name)
+        else:
+            return self._get_python_sc_var(name) or self._get_python_du_var(name)
 
     def _detect_python_version(self):
         """


Test patch: