Print

Print


This is part one of two PRs that will address Issue #1579.

As `distutils` and Easy Install are deprecated

c.f.:
* https://setuptools.pypa.io/en/stable/deprecated/distutils-legacy.html
* https://setuptools.pypa.io/en/stable/deprecated/easy_install.html

this PR converts all use of `distutils` to either use existing CPython libraries or
use `setuptool`'s versions of them, as advocated by the PyPA.

* [distutils.sysconfig -> CPython's sysconfig](https://discuss.python.org/t/understanding-site-packages-directories/12959/4)
* distutils.setup -> setuptools.setup
* distutils.core.Extension -> setuptools.Extension
* distutils.spawn -> setuptools._distutils.spawn

The XRootD docs are not clear on how to run the test suite(or at least don't make it easy to find at all), so while I'd really appreciate it if someone could tell me _how_ to do that at there doesn't seem to be any CI hooked up on GitHub here's an example Dockerfile that demonstrates on my fork that things still build fine

```dockerfile
# docker/Dockerfile
ARG BASE_IMAGE=neubauergroup/centos-build-base:3.8.11
FROM ${BASE_IMAGE} as base

SHELL [ "/bin/bash", "-c" ]

RUN yum update -y && \
    yum install -y \
        cmake \
        krb5-devel \
        libuuid-devel \
        libxml2-devel \
        openssl-devel \
        systemd-devel \
        zlib-devel \
        curl \
        git && \
    yum clean all && \
    python -m pip install --no-cache-dir --upgrade pip setuptools wheel

COPY . /code/xrootd

WORKDIR /code
RUN source scl_source enable devtoolset-8 && \
    . /usr/local/venv/bin/activate && \
    cmake \
        -DCMAKE_INSTALL_PREFIX=/usr/local/venv \
        -DPYTHON_EXECUTABLE=$(command -v python3) \
        -S xrootd \
        -B build && \
    cmake build -LH && \
    cmake \
        --build build \
        --clean-first \
        --parallel $(($(nproc) - 1)) && \
    cmake --build build --target install && \
    cd / && \
    rm -rf /code && \
    python -m pip list

WORKDIR /

# Load libraries
ENV LD_LIBRARY_PATH=/usr/local/venv/lib:$LD_LIBRARY_PATH

ENTRYPOINT ["/bin/bash", "-l", "-c"]
CMD ["/bin/bash"]
```

that when built from the top level of my fork with

```
docker build --file docker/Dockerfile --tag xrootd/xrootd:debug-local .
```

still builds okay

```console
$ docker run --rm -ti xrootd/xrootd:debug-local
[root@58ad262bf249 /]# 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@58ad262bf249 /]# python -c "import pyxrootd; print(pyxrootd)"
<module 'pyxrootd' from '/usr/local/venv/lib/python3.8/site-packages/xrootd-v20220110_1d50f8d-py3.8-linux-x86_64.egg/pyxrootd/__init__.py'>
[root@58ad262bf249 /]# python -c "import XRootD; print(XRootD)"
<module 'XRootD' from '/usr/local/venv/lib/python3.8/site-packages/xrootd-v20220110_1d50f8d-py3.8-linux-x86_64.egg/XRootD/__init__.py'>
[root@58ad262bf249 /]# command -v xrootd
/usr/local/venv/bin/xrootd
[root@58ad262bf249 /]# command -v xrdcp
/usr/local/venv/bin/xrdcp
[root@58ad262bf249 /]# python
Python 3.8.11 (default, Aug  2 2021, 20:01:57) 
[GCC 8.3.1 20190311 (Red Hat 8.3.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from XRootD import client
>>> from XRootD.client.flags import DirListFlags, OpenFlags, MkDirFlags, QueryCode
>>> myclient = client.FileSystem('root://someserver:1094')
>>> 
KeyboardInterrupt
>>> 
[root@58ad262bf249 /]# exit
exit
```
You can view, comment on, or merge this pull request online at:

  https://github.com/xrootd/xrootd/pull/1585

-- Commit Summary --

  * [Python] Use CPython libraries and setuptools over distuils
  * [Python] Remove unused Python imports

-- File Changes --

    M bindings/python/setup.py.in (4)
    M bindings/python/setup_pypi.py (5)
    M bindings/python/setup_standalone.py (4)
    M packaging/wheel/setup.py (9)

-- Patch Links --

https://github.com/xrootd/xrootd/pull/1585.patch
https://github.com/xrootd/xrootd/pull/1585.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/xrootd/xrootd/pull/1585
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