Print

Print


@adriansev Ah yeah, this is part of what I was talking about with regards to using a

> CentOS 7 based but has modern versions of CMake

where I built CPython and CMake from source inside.

```
$ docker run --rm neubauergroup/centos-build-base:3.8.11 'python --version --version && cmake --version'
Python 3.8.11 (default, Aug  2 2021, 20:01:57) 
[GCC 8.3.1 20190311 (Red Hat 8.3.1-3)]
cmake version 3.20.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
```

and so indeed the variable name changes between the versions of CMake.

> but i only tried with the system python (i do not use by myself another python as that comes with the experiment distributed software)

Yeah, I realize that is probably what most people are doing and that I'm on my own here a bit if I want to use anything beyond the default software included in CentOS 7, but I've been burned enough times by using the system Python for anything user related that I now always install my own CPython for use and leave the system Python alone for the OS to use by itself (to much happier results I might add!).

Though as XRootD uses

https://github.com/xrootd/xrootd/blob/0e460d7a11702c9935ed9fc1c67f22cb998b6fa4/cmake/XRootDFindLibs.cmake#L126-L135

and [`FindPythonLibs`](https://cmake.org/cmake/help/v3.20/module/FindPythonLibs.html) mentions

> If calling both `find_package(PythonInterp)` and `find_package(PythonLibs)`, call `find_package(PythonInterp)` first to get the currently active Python version by default with a consistent version of `PYTHON_LIBRARIES`.

I realized I can get away with just setting `PYTHON_EXECUTABLE` in CMake to set everything else through [`FindPythonInterp`](https://cmake.org/cmake/help/v3.20/module/FindPythonInterp.html) (which is what I do when building ROOT) — so thanks @adriansev for helping me here remember to read the docs closely. :smile: 

```diff
$ git diff
diff --git a/Dockerfile.centos7 b/Dockerfile.centos7
index bb07f0f..25d8e72 100644
--- a/Dockerfile.centos7
+++ b/Dockerfile.centos7
@@ -22,7 +22,7 @@ RUN python -m pip install --no-cache-dir --upgrade pip wheel && \
     python -m pip install --no-cache-dir --upgrade 'setuptools<='"${SETUPTOOLS_VERSION}"'' && \
     source scl_source enable devtoolset-8 && \
     . /usr/local/venv/bin/activate && \
-    git clone --depth 1 https://github.com/xrootd/xrootd.git \
+    git clone --depth 100 https://github.com/xrootd/xrootd.git \
       --branch "${XROOTD_TAG}" \
       --single-branch \
       xrootd && \
@@ -32,8 +32,7 @@ RUN python -m pip install --no-cache-dir --upgrade pip wheel && \
     echo "https://stackoverflow.com/questions/24174394/cmake-is-not-able-to-find-python-libraries" && \
     cmake \
         -DCMAKE_INSTALL_PREFIX=/usr/local/venv \
-        -DPYTHON_LIBRARY=/usr/local/lib \
-        -DPYTHON_INCLUDE_DIRS=/usr/local/include/python3.8 \
+        -DPYTHON_EXECUTABLE=$(command -v python3) \
         -S xrootd \
         -B build && \
     cmake build -LH && \
```

There I now get the same behavior as I was seeing over on Debian during the build (XRootD Python bindings being built and installed, but under an atypical path in site-packages given the fall back to easy install)

```
/usr/local/venv/lib/python3.8/site-packages/setuptools/dist.py:507: UserWarning: The version specified ('v20220106-30c0899') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
  warnings.warn(
/usr/local/venv/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/local/venv/lib/python3.8/site-packages/setuptools/command/easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/local/venv/lib/python3.8/site-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: v20220106-30c0899 is an invalid version and will not be supported in a future release
  warnings.warn(
zip_safe flag not set; analyzing archive contents...
pyxrootd.__pycache__.client.cpython-38: module references __file__
creating dist
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
creating /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg
Extracting xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg to /usr/local/venv/lib/python3.8/site-packages
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/__init__.py to __init__.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/__init__.py to __init__.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/_version.py to _version.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/copyprocess.py to copyprocess.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/env.py to env.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/file.py to file.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/filesystem.py to filesystem.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/finalize.py to finalize.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/flags.py to flags.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/glob_funcs.py to glob_funcs.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/responses.py to responses.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/url.py to url.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/client/utils.py to utils.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/pyxrootd/__init__.py to __init__.cpython-38.pyc
byte-compiling /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/pyxrootd/client.py to client.cpython-38.pyc
Adding xrootd v20220106-30c0899 to easy-install.pth file
```

and in the built image

```console
$ docker run --rm -ti xrootd-debug:debug-centos-fail
[root@be69546f7c7c /]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@be69546f7c7c /]# python -c 'import pyxrootd; print(pyxrootd); import XRootD; print(XRootD)'
<module 'pyxrootd' from '/usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/pyxrootd/__init__.py'>
<module 'XRootD' from '/usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/XRootD/__init__.py'>
[root@be69546f7c7c /]# ls -lhtr /usr/local/venv/lib/python3.8/site-packages/
total 44K
drwxr-xr-x 2 root root 4.0K Jan  8 22:21 wheel-0.37.1.dist-info
drwxr-xr-x 5 root root 4.0K Jan  8 22:21 wheel
drwxr-xr-x 2 root root 4.0K Jan  8 22:21 pip-21.3.1.dist-info
drwxr-xr-x 5 root root 4.0K Jan  8 22:21 pip
drwxr-xr-x 2 root root 4.0K Jan  8 22:21 setuptools-60.0.0.dist-info
drwxr-xr-x 7 root root 4.0K Jan  8 22:21 setuptools
drwxr-xr-x 6 root root 4.0K Jan  8 22:21 pkg_resources
-rw-r--r-- 1 root root  151 Jan  8 22:21 distutils-precedence.pth
drwxr-xr-x 3 root root 4.0K Jan  8 22:21 _distutils_hack
drwxr-xr-x 5 root root 4.0K Jan  8 22:23 xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg
-rw-r--r-- 1 root root   50 Jan  8 22:23 easy-install.pth
[root@be69546f7c7c /]# ls -lhtr /usr/local/venv/lib/python3.8/site-packages/xrootd-v20220106_30c0899-py3.8-linux-x86_64.egg/
total 12K
drwxr-xr-x 4 root root 4.0K Jan  8 22:23 XRootD
drwxr-xr-x 3 root root 4.0K Jan  8 22:23 pyxrootd
drwxr-xr-x 2 root root 4.0K Jan  8 22:23 EGG-INFO
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/xrootd/xrootd/issues/1579#issuecomment-1008166170
You are receiving this because you are subscribed to this thread.

Message ID: <[log in to unmask]>

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1