@matthewfeickert commented on this pull request.
> +# shutil.which was added in Python 3.3 +# c.f. https://docs.python.org/3/library/shutil.html#shutil.which +try: + from shutil import which +except ImportError: + from distutils.spawn import find_executable as which
In modernizing the Python packaging, it is preferable to use shutil.which
, so if it is available use it. If you're on Python 2, fall back to using distutils.spawn.find_executable
.
In packaging/wheel/install.sh:
> +# Determine if shutil.which is available for a modern Python package install +${6} -c 'import shutil.which' &> /dev/null # $6 holds the python sys.executable +shutil_which_available=$? +if [ "${shutil_which_available}" -ne "0" ]; then + ${6} setup.py install ${3} + res=$? +else + ${6} -m pip install ${3} . + res=$? +fi +unset shutil_which_available
As we're checking for shutil.which
in packaging/wheel/setup.py
then do so here as well. If it exists, then we're able to start modernizing by using python -m pip install
to install the sdist. If no, then fall back to using the deprecated python setup.py install
for the time being.
In packaging/wheel/publish.sh:
> +# Determine if wheel.bdist_wheel is available for wheel.bdist_wheel in setup.py +python3 -c 'import wheel' &> /dev/null +wheel_available=$? +if [ "${wheel_available}" -ne "0" ]; then + python3 -m pip install wheel + res=$? +fi +unset wheel_available + +if [ "$res" -ne "0" ]; then + echo "ERROR: Unable to find wheel and unable to install wheel with '$(command -v python3) -m pip install wheel'." + echo " Please ensure wheel is available to $(command -v python3) and try again." + exit 1 +fi
packaging/wheel/setup.py
contains
so ensure that wheel
actually exists, as python3-wheel
isn't a requirement in the RPM builds and shouldn't be unless it is called upon explicitly. As this is an sdist build, then there's no reason to not install the required tools from PyPI and so attempt to do so and warn if you can't.
In packaging/wheel/publish.sh:
> +# Determine if build is available +python3 -c 'import build' &> /dev/null +build_available=$? +if [ "${build_available}" -ne "0" ]; then + python3 -m pip install build + res=$? +fi +unset build_available + +if [ "$res" -ne "0" ]; then + echo "WARNING: Unable to find build and unable to install build from PyPI with '$(command -v python3) -m pip install build'." + echo " Falling back to building sdist with '$(command -v python3) setup.py sdist'." + python3 setup.py sdist +else + python3 -m build --sdist . +fi
As attempting to use the deprecated python setup.py sdist
with a modern setuptools
is going to warn you to not and to use build
(c.f. Issue #1579)
```pytb
/usr/local/venv/lib/python3.9/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.9/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(
then attempt to use build
to perform the sdist build. If it is unable to get build
from PyPI then fall back to python setup.py sdist
with a warning.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.
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