build: convert from deprecated distutils to setuptools
Subsystems (2)
PATCH 1/1 build: convert from deprecated distutils to setuptools
According to PEP 632 [1], distutils is obsolete and removed after Python v3.12. Setuptools is the replacement.
There is a migration guide at [2] that suggests the following replacements:
{distutils.core => setuptools}.setup
{distutils => setuptools}.command
distutils.dep_util => setuptools.modified
Prior to setuptools v69.0.0 [3], newer_group was exposed through the now-deprecated setuptools.dep_util instead of setuptools.modified.
Rather than updating distutils.core.Extension, I remove it as it does not appear to be used.
---
I'm not deeply familiar with the Python ecosystem, so it'd be good to have this patch reviewed by someone who is.
I needed these changes to get pynfs to build on an Arch linux system with Python version 3.13.1.
I also tested on an AlmaLinux 8.10 system with Python version 3.6.8 and setuptools version 59.6.0, and it built succesfully for me there.
--- nfs4.0/setup.py | 8 ++++++-- nfs4.1/setup.py | 4 ++-- rpc/setup.py | 4 ++-- setup.py | 2 +- xdr/setup.py | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-)
nfs4.0/setup.py +6 -2
@@ -3,8 +3,12 @@ from __future__ import print_function from __future__ import absolute_import import sys -from distutils.core import setup, Extension -from distutils.dep_util import newer_group +from setuptools import setup +try: + from setuptools.modified import newer_group +except ImportError: + # for older (before v69.0.0) versions of setuptools: + from setuptools.dep_util import newer_group import os import glob try:
nfs4.1/setup.py +2 -2
@@ -1,5 +1,5 @@ -from distutils.core import setup +from setuptools import setup DESCRIPTION = """ nfs4
@@ -8,7 +8,7 @@ nfs4 Add stuff here. """ -from distutils.command.build_py import build_py as _build_py +from setuptools.command.build_py import build_py as _build_py import os from glob import glob try:
rpc/setup.py +2 -2
@@ -1,5 +1,5 @@ -from distutils.core import setup +from setuptools import setup DESCRIPTION = """ rpc
@@ -8,7 +8,7 @@ rpc Add stuff here. """ -from distutils.command.build_py import build_py as _build_py +from setuptools.command.build_py import build_py as _build_py import os from glob import glob try:
setup.py +1 -1
@@ -2,7 +2,7 @@ from __future__ import print_function -from distutils.core import setup +from setuptools import setup import sys import os
xdr/setup.py +1 -1
@@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from distutils.core import setup +from setuptools import setup DESCRIPTION = """ xdrgen
Signature · 1 line
2.48.1
Quoted 25 lines · Thomas Bertschinger
According to PEP 632 [1], distutils is obsolete and removed after Python v3.12. Setuptools is the replacement.
There is a migration guide at [2] that suggests the following replacements:
{distutils.core => setuptools}.setup
{distutils => setuptools}.command
distutils.dep_util => setuptools.modifiedPrior to setuptools v69.0.0 [3],
newer_groupwas exposed through the now-deprecatedsetuptools.dep_utilinstead ofsetuptools.modified.Rather than updating distutils.core.Extension, I remove it as it does not appear to be used.
Link https://peps.python.org/pep-0632/ [1]Signed-off-by Thomas Bertschinger <[email protected]>---
I'm not deeply familiar with the Python ecosystem, so it'd be good to have this patch reviewed by someone who is.
Quoted 5 lines
I needed these changes to get pynfs to build on an Arch linux system with Python version 3.13.1.
I also tested on an AlmaLinux 8.10 system with Python version 3.6.8 and setuptools version 59.6.0, and it built succesfully for me there.
Applied.
I asked a colleague with greater Python expertise than me to review it:
thanks very much for this, Thomas.
cheers,
c.
Quoted 92 lines
--- nfs4.0/setup.py | 8 ++++++-- nfs4.1/setup.py | 4 ++-- rpc/setup.py | 4 ++-- setup.py | 2 +- xdr/setup.py | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-)nfs4.0/setup.py +6
-2@@ -3,8 +3,12 @@ from __future__ import print_function from __future__ import absolute_import import sys -from distutils.core import setup, Extension -from distutils.dep_util import newer_group +from setuptools import setup +try: + from setuptools.modified import newer_group +except ImportError: + # for older (before v69.0.0) versions of setuptools: + from setuptools.dep_util import newer_group import os import glob try:nfs4.1/setup.py +2
-2@@ -1,5 +1,5 @@ -from distutils.core import setup +from setuptools import setup DESCRIPTION = """ nfs4@@ -8,7 +8,7 @@ nfs4 Add stuff here. """ -from distutils.command.build_py import build_py as _build_py +from setuptools.command.build_py import build_py as _build_py import os from glob import glob try:rpc/setup.py +2
-2@@ -1,5 +1,5 @@ -from distutils.core import setup +from setuptools import setup DESCRIPTION = """ rpc@@ -8,7 +8,7 @@ rpc Add stuff here. """ -from distutils.command.build_py import build_py as _build_py +from setuptools.command.build_py import build_py as _build_py import os from glob import glob try:setup.py +1
-1@@ -2,7 +2,7 @@ from __future__ import print_function -from distutils.core import setup +from setuptools import setup import sys import osxdr/setup.py +1
-1@@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from distutils.core import setup +from setuptools import setup DESCRIPTION = """ xdrgen