Print

Print


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

Requires PR #1585 to go in first for atomicity.

As directly invoking `python setup.py` is considered deprecated behavior by the PyPA, use `python -m pip install` to install the Python bindings if the Python interpreter has a valid version of pip associated with it.

If there is a valid pip, update pip to the latest release and ensure that setuptools and wheel are installed. Then build and install the Python bindings with `python -m pip install`.

If there is no valid pip, warn the user and given them instructions on how to get pip on their machine. Attempt to still install the Python bindings by falling back on the deprecated `python setup.py build` and `python setup.py install` which will also invoke Easy Install if `setuptools` `v0.60.0+` is used.


Both branches have been tested in Docker image builds

## Building with `python -m pip install`

```console
$ docker run --rm -ti xrootd/xrootd:build-pip-pass 
[root@f6701ee26ac7 /]# python -c "import pyxrootd; print(pyxrootd)"
<module 'pyxrootd' from '/usr/local/venv/lib/python3.8/site-packages/pyxrootd/__init__.py'>
[root@f6701ee26ac7 /]# python -c "import XRootD; print(XRootD)"
<module 'XRootD' from '/usr/local/venv/lib/python3.8/site-packages/XRootD/__init__.py'>
[root@f6701ee26ac7 /]# command -v xrootd
/usr/local/venv/bin/xrootd
[root@f6701ee26ac7 /]# command -v xrdcp
/usr/local/venv/bin/xrdcp
[root@f6701ee26ac7 /]# 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')
>>> myclient
<XRootD.client.filesystem.FileSystem object at 0x7fb564b22fa0>
>>> 
[root@f6701ee26ac7 /]#
```

## Falling back to `python setup.py install`

```console
$ docker run --rm -ti xrootd/xrootd:build-setup-py-pass 
[root@62f223b14e6e /]# python -c "import pyxrootd; print(pyxrootd)"
<module 'pyxrootd' from '/usr/local/venv/lib/python3.8/site-packages/xrootd-v20220111_a98ec84-py3.8-linux-x86_64.egg/pyxrootd/__init__.py'>
[root@62f223b14e6e /]# python -c "import XRootD; print(XRootD)"
<module 'XRootD' from '/usr/local/venv/lib/python3.8/site-packages/xrootd-v20220111_a98ec84-py3.8-linux-x86_64.egg/XRootD/__init__.py'>
[root@62f223b14e6e /]# command -v xrootd
/usr/local/venv/bin/xrootd
[root@62f223b14e6e /]# command -v xrdcp
/usr/local/venv/bin/xrdcp
[root@62f223b14e6e /]# 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')
>>> myclient
<XRootD.client.filesystem.FileSystem object at 0x7f6541b55fa0>
>>> 
[root@62f223b14e6e /]# 
```
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * [Python] Use CPython libraries and setuptools over distuils
  * [Python] Remove unused Python imports
  * [Python] Install Python bindings with pip if available

-- File Changes --

    M bindings/python/CMakeLists.txt (102)
    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/1586.patch
https://github.com/xrootd/xrootd/pull/1586.diff

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