[PATCH pynfs] build: convert from deprecated distutils to setuptools

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Link: https://peps.python.org/pep-0632/ [1]
Link: https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html [2]
Link: https://setuptools.pypa.io/en/latest/history.html#v69-0-0 [3]
Signed-off-by: Thomas Bertschinger <tahbertschinger@xxxxxxxxx>
---
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(-)

diff --git a/nfs4.0/setup.py b/nfs4.0/setup.py
index 58349d9..0f8380e 100755
--- a/nfs4.0/setup.py
+++ b/nfs4.0/setup.py
@@ -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:
diff --git a/nfs4.1/setup.py b/nfs4.1/setup.py
index e13170e..bfadea1 100644
--- a/nfs4.1/setup.py
+++ b/nfs4.1/setup.py
@@ -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:
diff --git a/rpc/setup.py b/rpc/setup.py
index 99dad5a..922838f 100644
--- a/rpc/setup.py
+++ b/rpc/setup.py
@@ -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:
diff --git a/setup.py b/setup.py
index 83dc6b5..203514d 100755
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@
 
 from __future__ import print_function
 
-from distutils.core import setup
+from setuptools import setup
 
 import sys
 import os
diff --git a/xdr/setup.py b/xdr/setup.py
index 3acb8a2..3778abb 100644
--- a/xdr/setup.py
+++ b/xdr/setup.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-from distutils.core import setup
+from setuptools import setup
 
 DESCRIPTION = """
 xdrgen
-- 
2.48.1





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux