From: Jeff Layton <jlayton@kernel.org>
To: Petr Vorel <pvorel@suse.cz>
Cc: linux-nfs@vger.kernel.org, Calum Mackay <calum.mackay@oracle.com>,
Michael Moese <mmoese@suse.com>
Subject: Re: [PATCH 1/1] Allow to fallback to xdrlib if xdrlib3 not available
Date: Wed, 12 Feb 2025 08:53:38 -0500 [thread overview]
Message-ID: <e5ff0c6ac9ecbf0ebb7a1ecce55e17885eedf543.camel@kernel.org> (raw)
In-Reply-To: <20250212134713.GA2044610@pevik>
On Wed, 2025-02-12 at 14:47 +0100, Petr Vorel wrote:
> Hi Jeff,
>
> > On Wed, 2025-02-12 at 14:23 +0100, Petr Vorel wrote:
> > > On certain environments it might be difficult to install xdrlib3 via pip
> > > (e.g. python 3.11, which is a default on current Tumbleweed).
>
>
> > I did a "pip install xdrlib3" on Fedora 33 just now, and it has python
> > 3.9. What's the problem you're seeing with SuSE installing it with
> > v3.11?
>
> Yesterday I did not notice missing ply, I saw only missing xdrgen
> (xdr/xdrgen.py). Therefore I thought that virtualenv is mangling PYTHONPATH.
> Obviously installing ply with pip would be enough.
>
> I also thing using a fallback saves the need to use virtualenv on old distros,
> therefore I would prefer this patch to be accepted. If it's not accepted, it
> might be worth to extend info about dependencies.
>
> Kind regards,
> Petr
>
> $ python3 --version
> Python 3.11.11
>
> # pip install xdrlib3
>
> [notice] A new release of pip is available: 24.3.1 -> 25.0.1
> [notice] To update, run: pip install --upgrade pip
> error: externally-managed-environment
>
> × This environment is externally managed
> ╰─> To install Python packages system-wide, try
> zypper install python311-xyz, where xyz is the package
> you are trying to install.
> ...
>
> => let's use virtualenv
>
> # python3 -m virtualenv .venv && . .venv/bin/activate
> created virtual environment CPython3.11.11.final.0-64 in 1466ms
> creator CPython3Posix(dest=/root/pynfs/.venv, clear=False, no_vcs_ignore=False, global=False)
> seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
> added seed packages: pip==24.3.1, setuptools==75.8.0, wheel==0.45.1, xdrlib3==0.1.1
> activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
>
> # pip install xdrlib3
> Requirement already satisfied: xdrlib3 in ./.venv/lib/python3.11/site-packages (0.1.1)
>
> # ./setup.py build
> Moving to xdr
>
>
> Moving to rpc
> Traceback (most recent call last):
> File "/root/pynfs/rpc/./setup.py", line 15, in <module>
> import xdrgen
> ModuleNotFoundError: No module named 'xdrgen'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "/root/pynfs/rpc/./setup.py", line 18, in <module>
> import xdrgen
> File "/root/pynfs/xdr/xdrgen.py", line 235, in <module>
> import ply.lex as lex
> ModuleNotFoundError: No module named 'ply'
>
> Moving to nfs4.1
> Traceback (most recent call last):
> File "/root/pynfs/nfs4.1/./setup.py", line 15, in <module>
> import xdrgen
> ModuleNotFoundError: No module named 'xdrgen'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "/root/pynfs/nfs4.1/./setup.py", line 18, in <module>
> import xdrgen
> File "/root/pynfs/xdr/xdrgen.py", line 235, in <module>
> import ply.lex as lex
> ModuleNotFoundError: No module named 'ply'
>
> Moving to nfs4.0
> /root/pynfs/nfs4.0/./setup.py:7: DeprecationWarning: dep_util is Deprecated. Use functions from setuptools instead.
> from distutils.dep_util import newer_group
> Traceback (most recent call last):
> File "/root/pynfs/nfs4.0/./setup.py", line 11, in <module>
> import xdrgen
> ModuleNotFoundError: No module named 'xdrgen'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "/root/pynfs/nfs4.0/./setup.py", line 14, in <module>
> import xdrgen
> File "/root/pynfs/xdr/xdrgen.py", line 235, in <module>
> import ply.lex as lex
> ModuleNotFoundError: No module named 'ply'
>
> # pip install ply # this fixes it
>
> > BTW, does SuSE have the xdrlib3 module available as a package?
>
> > > Fixes: dfb0b07 ("Move to xdrlib3")
> > > Suggested-by: Michael Moese <mmoese@suse.com>
> > > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > > ---
> > > Hi,
>
> > > I admit it would be safer to check if python is really < 3.13.
>
> > > Kind regards,
> > > Petr
>
> > > README | 2 ++
> > > nfs4.0/lib/rpc/rpc.py | 6 +++++-
> > > nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py | 7 ++++++-
> > > nfs4.0/nfs4lib.py | 6 +++++-
> > > nfs4.0/nfs4server.py | 6 +++++-
> > > rpc/security.py | 6 +++++-
> > > xdr/xdrgen.py | 9 +++++++--
> > > 7 files changed, 35 insertions(+), 7 deletions(-)
>
> > > diff --git a/README b/README
> > > index 8c3ac27..d5214b4 100644
> > > --- a/README
> > > +++ b/README
> > > @@ -19,6 +19,8 @@ python3-standard-xdrlib) or you may install it via pip:
>
> > > pip install xdrlib3
>
> > > +If xdrlib3 is not available fallback to old xdrlib (useful for python < 3.13).
> > > +
> > > You can prepare both versions for use with
>
> > > ./setup.py build
> > > diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py
> > > index 4751790..7a80241 100644
> > > --- a/nfs4.0/lib/rpc/rpc.py
> > > +++ b/nfs4.0/lib/rpc/rpc.py
> > > @@ -9,12 +9,16 @@
>
> > > from __future__ import absolute_import
> > > import struct
> > > -import xdrlib3 as xdrlib
> > > import socket
> > > import select
> > > import threading
> > > import errno
>
> > > +try:
> > > + import xdrlib3 as xdrlib
> > > +except:
> > > + import xdrlib
> > > +
> > > from rpc.rpc_const import *
> > > from rpc.rpc_type import *
> > > import rpc.rpc_pack as rpc_pack
> > > diff --git a/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py b/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py
> > > index 2581a1e..41c6d54 100644
> > > --- a/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py
> > > +++ b/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py
> > > @@ -1,7 +1,12 @@
> > > from .base import SecFlavor, SecError
> > > from rpc.rpc_const import AUTH_SYS
> > > from rpc.rpc_type import opaque_auth
> > > -from xdrlib3 import Packer, Error
> > > +import struct
> > > +
> > > +try:
> > > + from xdrlib3 import Packer, Error
> > > +except:
> > > + from xdrlib import Packer, Error
>
> > > class SecAuthSys(SecFlavor):
> > > # XXX need better defaults
> > > diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
> > > index 2337d8c..92b3c11 100644
> > > --- a/nfs4.0/nfs4lib.py
> > > +++ b/nfs4.0/nfs4lib.py
> > > @@ -41,9 +41,13 @@ import xdrdef.nfs4_const as nfs4_const
> > > from xdrdef.nfs4_const import *
> > > import xdrdef.nfs4_type as nfs4_type
> > > from xdrdef.nfs4_type import *
> > > -from xdrlib3 import Error as XDRError
> > > import xdrdef.nfs4_pack as nfs4_pack
>
> > > +try:
> > > + from xdrlib3 import Error as XDRError
> > > +except:
> > > + from xdrlib import Error as XDRError
> > > +
> > > import nfs_ops
> > > op4 = nfs_ops.NFS4ops()
>
> > > diff --git a/nfs4.0/nfs4server.py b/nfs4.0/nfs4server.py
> > > index 10bf28e..e26cecd 100755
> > > --- a/nfs4.0/nfs4server.py
> > > +++ b/nfs4.0/nfs4server.py
> > > @@ -34,7 +34,11 @@ import time, StringIO, random, traceback, codecs
> > > import StringIO
> > > import nfs4state
> > > from nfs4state import NFS4Error, printverf
> > > -from xdrlib3 import Error as XDRError
> > > +
> > > +try:
> > > + from xdrlib3 import Error as XDRError
> > > +except:
> > > + from xdrlib import Error as XDRError
>
> > > unacceptable_names = [ "", ".", ".." ]
> > > unacceptable_characters = [ "/", "~", "#", ]
> > > diff --git a/rpc/security.py b/rpc/security.py
> > > index 789280c..79e746b 100644
> > > --- a/rpc/security.py
> > > +++ b/rpc/security.py
> > > @@ -3,7 +3,6 @@ from .rpc_const import AUTH_NONE, AUTH_SYS, RPCSEC_GSS, SUCCESS, CALL, \
> > > from .rpc_type import opaque_auth, authsys_parms
> > > from .rpc_pack import RPCPacker, RPCUnpacker
> > > from .gss_pack import GSSPacker, GSSUnpacker
> > > -from xdrlib3 import Packer, Unpacker
> > > from . import rpclib
> > > from .gss_const import *
> > > from . import gss_type
> > > @@ -17,6 +16,11 @@ except ImportError:
> > > import threading
> > > import logging
>
> > > +try:
> > > + from xdrlib3 import Packer, Unpacker
> > > +except:
> > > + from xdrlib import Packer, Unpacker
> > > +
> > > log_gss = logging.getLogger("rpc.sec.gss")
> > > log_gss.setLevel(logging.INFO)
>
> > > diff --git a/xdr/xdrgen.py b/xdr/xdrgen.py
> > > index f802ba8..970ae9d 100755
> > > --- a/xdr/xdrgen.py
> > > +++ b/xdr/xdrgen.py
> > > @@ -1357,8 +1357,13 @@ pack_header = """\
> > > import sys,os
> > > from . import %s as const
> > > from . import %s as types
> > > -import xdrlib3 as xdrlib
> > > -from xdrlib3 import Error as XDRError
> > > +
> > > +try:
> > > + import xdrlib3 as xdrlib
> > > + from xdrlib3 import Error as XDRError
> > > +except:
> > > + import xdrlib as xdrlib
> > > + from xdrlib import Error as XDRError
>
> > > class nullclass(object):
> > > pass
>
> > Acked-by: Jeff Layton <jlayton@kernel.org>
Ok, I don't have any objection to the patch. I was just curious as to
whether SuSE had some problem using pip for this.
Acked-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2025-02-12 13:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-12 13:23 [PATCH 1/1] Allow to fallback to xdrlib if xdrlib3 not available Petr Vorel
2025-02-12 13:27 ` [PATCH pynfs] " Petr Vorel
2025-02-12 13:36 ` [PATCH 1/1] " Jeff Layton
2025-02-12 13:47 ` Petr Vorel
2025-02-12 13:53 ` Jeff Layton [this message]
2025-02-12 15:41 ` Chuck Lever
2025-02-12 20:52 ` Calum Mackay
2025-02-12 21:01 ` Petr Vorel
2025-02-12 21:32 ` Calum Mackay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e5ff0c6ac9ecbf0ebb7a1ecce55e17885eedf543.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=calum.mackay@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=mmoese@suse.com \
--cc=pvorel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox